6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.scene;
27
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertSame;
30 import static org.junit.Assert.assertTrue;
31
32 import java.util.Set;
33
34 import org.junit.Before;
35 import org.junit.Test;
36
37 public class Node_lookup_Test {
38 // Group & #root
39 // / \
40 // #a .b.c
41 // / \ \
42 // .d #e .d
43 private Group root, a, bc, d, e, d2;
44
45 @Before public void setup() {
46 root = new Group();
47 root.setId("root");
48 a = new Group();
49 a.setId("a");
50 d = new Group();
51 d.getStyleClass().add("d");
52 e = new Group();
53 e.setId("e");
54 bc = new Group();
55 bc.getStyleClass().addAll("b", "c");
56 d2 = new Group();
57 d2.getStyleClass().add("d");
58 root.getChildren().addAll(a, bc);
59 a.getChildren().addAll(d, e);
60 bc.getChildren().addAll(d2);
61 }
62
63 @Test public void quickTest() {
64 Node found = root.lookup("Group");
65 assertSame(root, found);
66
67 found = root.lookup("#a");
68 assertSame(a, found);
69
70 found = root.lookup("#a > .d");
71 assertSame(d, found);
72
73 found = root.lookup("#e");
74 assertSame(e, found);
75
76 found = root.lookup(".b .d");
77 assertSame(d2, found);
78
79 found = root.lookup(".c .d");
80 assertSame(d2, found);
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package test.javafx.scene;
27
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertSame;
30 import static org.junit.Assert.assertTrue;
31
32 import java.util.Set;
33 import javafx.scene.Group;
34 import javafx.scene.Node;
35 import javafx.scene.ParentShim;
36
37 import org.junit.Before;
38 import org.junit.Test;
39
40 public class Node_lookup_Test {
41 // Group & #root
42 // / \
43 // #a .b.c
44 // / \ \
45 // .d #e .d
46 private Group root, a, bc, d, e, d2;
47
48 @Before public void setup() {
49 root = new Group();
50 root.setId("root");
51 a = new Group();
52 a.setId("a");
53 d = new Group();
54 d.getStyleClass().add("d");
55 e = new Group();
56 e.setId("e");
57 bc = new Group();
58 bc.getStyleClass().addAll("b", "c");
59 d2 = new Group();
60 d2.getStyleClass().add("d");
61 ParentShim.getChildren(root).addAll(a, bc);
62 ParentShim.getChildren(a).addAll(d, e);
63 ParentShim.getChildren(bc).addAll(d2);
64 }
65
66 @Test public void quickTest() {
67 Node found = root.lookup("Group");
68 assertSame(root, found);
69
70 found = root.lookup("#a");
71 assertSame(a, found);
72
73 found = root.lookup("#a > .d");
74 assertSame(d, found);
75
76 found = root.lookup("#e");
77 assertSame(e, found);
78
79 found = root.lookup(".b .d");
80 assertSame(d2, found);
81
82 found = root.lookup(".c .d");
83 assertSame(d2, found);
|