Highlight.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. describe('Ext.draw.modifier.Highlight', function () {
  2. describe('filterChanges', function () {
  3. var draw;
  4. afterEach(function () {
  5. Ext.destroy(draw);
  6. });
  7. // A visual test should be the most robust way to test this.
  8. // It's engine specific, but the Canvas engine is used by default on almost every platform,
  9. // except for IE8 and old (pre-Chrome) Android.
  10. (!Ext.isChrome ? xit : it)('should not delete properties from the changes object', function () {
  11. var side = 100;
  12. draw = new Ext.draw.Container({
  13. renderTo: document.body,
  14. engine: 'Ext.draw.engine.Canvas',
  15. width: side,
  16. height: side
  17. });
  18. var surface = draw.getSurface();
  19. var instancing = new Ext.draw.sprite.Instancing({
  20. template: {
  21. type: 'square',
  22. size: 4,
  23. modifiers: 'highlight',
  24. fillStyle: 'red',
  25. translationX: 20,
  26. translationY: 20
  27. }
  28. });
  29. instancing.add({
  30. translationX: 50,
  31. translationY: 50
  32. });
  33. // If something went wrong, the sprite's applyTransformations method
  34. // won't be called before the instance is rendered, and the instance
  35. // will appear at the origin. In this case the second square would render
  36. // at (0,0) as its center on the Canvas.
  37. instancing.add({
  38. translationX: 20,
  39. translationY: 20
  40. });
  41. surface.add(instancing);
  42. surface.renderFrame();
  43. var imageData = surface.canvases[0].dom.getContext('2d').getImageData(0, 0, side, side);
  44. // The data is an array of bytes, 4 bytes for each pixel (RGBA components).
  45. // First pixel should not be red. Meaning square's transform attributes are applied
  46. // correctly.
  47. expect(imageData.data[0]).toBe(0);
  48. expect(imageData.data[1]).toBe(0);
  49. expect(imageData.data[2]).toBe(0);
  50. });
  51. });
  52. });