Canvas.js 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. topSuite("Ext.draw.engine.Canvas", ['Ext.draw.Container'], function() {
  2. beforeEach(function() {
  3. // Silence warnings regarding Sencha download server
  4. spyOn(Ext.log, 'warn');
  5. });
  6. describe('surface splitting', function () {
  7. var isAndroid51 = navigator.userAgent.search('Android 5.1') >= 0;
  8. // In TeamCity's only "Android@Browser@5.1: Modern Toolkit" the following error is reported: "Expected 16 to be 9."
  9. TODO(isAndroid51).
  10. it("should split the surface into canvas tiles vertically and horizontally based on splitThreshold", function () {
  11. var side = 400,
  12. threshold = 200,
  13. proto = Ext.draw.engine.Canvas.prototype,
  14. originalThreshold = proto.splitThreshold;
  15. proto.splitThreshold = threshold;
  16. var draw = new Ext.draw.Container({
  17. renderTo: Ext.getBody(),
  18. engine: 'Ext.draw.engine.Canvas',
  19. width: side,
  20. height: side
  21. });
  22. var surface = draw.getSurface();
  23. var expectedCanvasCount = Math.pow(Math.ceil((side * (window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI)) / threshold), 2);
  24. expect(surface.bodyElement.select('canvas').elements.length).toBe(expectedCanvasCount);
  25. proto.splitThreshold = originalThreshold;
  26. Ext.destroy(draw);
  27. });
  28. });
  29. });