1 /* 2 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.jemmy.swt; 24 25 26 import java.io.FileNotFoundException; 27 28 import org.eclipse.swt.widgets.Control; 29 import org.eclipse.swt.widgets.TabFolder; 30 import org.eclipse.swt.widgets.Tree; 31 import org.eclipse.swt.widgets.TreeItem; 32 import org.jemmy.control.Wrap; 33 import org.jemmy.input.StringTree; 34 import org.jemmy.interfaces.Parent; 35 import org.jemmy.interfaces.Selectable; 36 import org.testng.annotations.AfterClass; 37 import org.testng.annotations.AfterMethod; 38 import org.testng.annotations.BeforeClass; 39 import org.testng.annotations.BeforeMethod; 40 import org.testng.annotations.Test; 41 42 /** 43 * 44 * @author shura 45 */ 46 public class TreeTest { 47 48 public TreeTest() { 49 } 50 51 @BeforeClass 52 public static void setUpClass() throws Exception { 53 new Thread(new Runnable() { 54 55 public void run() { 56 Items.main(null); 57 } 58 }).start(); 59 Thread.sleep(2000); 60 } 61 62 @AfterClass 63 public static void tearDownClass() throws Exception { 64 } 65 Parent<Control> shell; 66 67 @BeforeMethod 68 public void setUp() { 69 shell = Shells.SHELLS.lookup().as(Parent.class, Control.class); 70 } 71 72 @AfterMethod 73 public void tearDown() { 74 } 75 String[][] trees = new String[][]{ 76 {"zero", "zeroone", "zeroonezero"}, 77 {"1", "TreeItem 10"}, 78 {"TreeItem 0", "zeroone", "TreeItem 010"}, 79 {"1", "10"}, 80 {"0", "00"}, 81 {"1", "11"}, 82 {"0", "01", "010"}, 83 {"0", "01"}, 84 {"one"} 85 }; 86 87 @Test 88 public void tree() throws InterruptedException, FileNotFoundException { 89 shell.lookup(TabFolder.class).as(Selectable.class).selector().select("Tree"); 90 final Wrap<? extends Tree> tree = shell.lookup(Tree.class).wrap(); 91 for (String[] path : trees) { 92 tree.as(StringTree.class, TreeItem.class).select(path); 93 } 94 Thread.sleep(1000); 95 } 96 97 }