Path.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. topSuite("Ext.draw.sprite.Path", ['Ext.draw.*'], function() {
  2. beforeEach(function() {
  3. // Silence warnings regarding Sencha download server
  4. spyOn(Ext.log, 'warn');
  5. });
  6. describe("hitTest", function () {
  7. var sprite, surface, container;
  8. beforeEach(function () {
  9. container = new Ext.draw.Container();
  10. surface = new Ext.draw.Surface();
  11. sprite = new Ext.draw.sprite.Circle({
  12. hidden: false,
  13. globalAlpha: 1,
  14. fillOpacity: 1,
  15. strokeOpacity: 1,
  16. fillStyle: 'red',
  17. strokeStyle: 'red',
  18. r: 100,
  19. cx: 100,
  20. cy: 100
  21. });
  22. surface.add(sprite);
  23. container.add(surface);
  24. });
  25. afterEach(function () {
  26. Ext.destroy(sprite, surface, container);
  27. });
  28. it("should return an object with the 'sprite' property set to the sprite itself, " +
  29. "if the sprite is visible and its bounding box and path are hit", function () {
  30. var result = sprite.hitTest([90, 90]);
  31. expect(result && result.sprite).toBe(sprite);
  32. });
  33. it("should return null, if the sprite is visible, its bounding box is hit, but the path isn't", function () {
  34. var result = sprite.hitTest([10, 10]);
  35. expect(result).toBe(null);
  36. });
  37. });
  38. });