From 80c8aae5bc5f079b0a78a3ed084456e89a3c7bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 12 Feb 2016 20:09:41 +0100 Subject: [PATCH] Implement unit tests for Item#getItems() with overlapping / inside properties. Relates to #961 --- .travis.yml | 4 ++-- test/tests/Item_Getting.js | 42 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc8cc496..91e23d00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ node_js: sudo: false env: matrix: - - CXX=g++-4.8 + - CXX=g++-4.9 global: - secure: QD8wgggmlF0PPOSdQ84JLO9quLMlTDXu3Cg0+UM9yFSyih2ukL/XGn5wxR3B3XmaHfzRqxtrfhjMX6LT7DKFsriolhNVu0kER4zGyrKWK5irxAy2veosyj8qs/R1pXh9qnItlgXrz0fJwpH9o/08q8X+ZjXb0veZ34EMODLbV5zBJXoaHVC6WN62GzInAEEfdB0AEacb44sDIdK++1ujcTFLGnc+LJw8Ck2C/eOWwRhJyiNUrHHTQV3KaM0YtHz+DCz5InC9vWl+BG656AOU5C6PMTvnZ1M3CGfjmXydZoBbDvCQIcB5ylf17tXGoJKevHnmLWm6U3fPVwUwiPiKvisxyNShZw4BEDS7m1b799GnzGOiYsi37aH3G+iAORg1QVqoCAK/yQ77MkkA6a3tlLVHRaInVA6QlFxlbqc8WNlx+fa8lo4L7Y9KPGfr1Bpix/kHQV5JCzKS16Zc7wblTrOvIR/qb8qPfLoxhXi5fUZ3eRuXgR699X1IHJ1LlhkOoBfSiWl88qba01FBLrYSCPeVGb6/N91OFpIlq6eORnzBbc4mtoJSYttvZ45Hu3M5V0KDrGIHr7kNyPThdKr7PVaMXHLCpNrnmBSaxVCU5uhb8Ae3bnLAq/aBxHWZNA8cQ43/s6rS7QqOVJfquXNFYa6V9/QjbU3sJyqIgRzMkAM= addons: @@ -14,7 +14,7 @@ addons: - ubuntu-toolchain-r-test - git-core packages: - - g++-4.8 + - g++-4.9 - git - libcairo2-dev - libpango1.0-dev diff --git a/test/tests/Item_Getting.js b/test/tests/Item_Getting.js index aab2656a..120d0500 100644 --- a/test/tests/Item_Getting.js +++ b/test/tests/Item_Getting.js @@ -215,13 +215,51 @@ test('Project#getItems() overlapping', function() { fillColor: 'red' }); - var rect = new Rectangle(0, 0, 400, 400); + equals(function() { + var matches = project.getItems({ + class: Path, + overlapping: [0, 0, 400, 400] + }); + return matches.length == 1 && matches[0] == path; + }, true); equals(function() { var matches = project.getItems({ class: Path, - overlapping: rect + overlapping: [200, 0, 400, 400] }); return matches.length == 1 && matches[0] == path; }, true); + + equals(function() { + var matches = project.getItems({ + class: Path, + overlapping: [400, 0, 400, 400] + }); + return matches.length == 0; + }, true); +}); + +test('Project#getItems() inside', function() { + var path = new Path.Circle({ + radius: 100, + center: [200, 200], + fillColor: 'red' + }); + + equals(function() { + var matches = project.getItems({ + class: Path, + inside: [0, 0, 400, 400] + }); + return matches.length == 1 && matches[0] == path; + }, true); + + equals(function() { + var matches = project.getItems({ + class: Path, + inside: [200, 0, 400, 400] + }); + return matches.length == 0; + }, true); });