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. 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 package org.jemmy.swt;
  26 
  27 
  28 import java.io.FileNotFoundException;
  29 
  30 import org.eclipse.swt.widgets.Control;
  31 import org.eclipse.swt.widgets.TabFolder;
  32 import org.eclipse.swt.widgets.Tree;
  33 import org.eclipse.swt.widgets.TreeItem;
  34 import org.jemmy.control.Wrap;
  35 import org.jemmy.input.StringTree;
  36 import org.jemmy.interfaces.Parent;
  37 import org.jemmy.interfaces.Selectable;
  38 import org.testng.annotations.AfterClass;
  39 import org.testng.annotations.AfterMethod;
  40 import org.testng.annotations.BeforeClass;
  41 import org.testng.annotations.BeforeMethod;
  42 import org.testng.annotations.Test;
  43 
  44 /**
  45  *
  46  * @author shura
  47  */
  48 public class TreeTest {
  49 
  50     public TreeTest() {
  51     }
  52 
  53     @BeforeClass
  54     public static void setUpClass() throws Exception {
  55         new Thread(new Runnable() {
  56 
  57             public void run() {
  58                 Items.main(null);
  59             }
  60         }).start();
  61         Thread.sleep(2000);
  62     }
  63 
  64     @AfterClass
  65     public static void tearDownClass() throws Exception {
  66     }
  67     Parent<Control> shell;
  68 
  69     @BeforeMethod
  70     public void setUp() {
  71         shell = Shells.SHELLS.lookup().as(Parent.class, Control.class);
  72     }
  73 
  74     @AfterMethod
  75     public void tearDown() {
  76     }
  77     String[][] trees = new String[][]{
  78         {"zero", "zeroone", "zeroonezero"},
  79         {"1", "TreeItem 10"},
  80         {"TreeItem 0", "zeroone", "TreeItem 010"},
  81         {"1", "10"},
  82         {"0", "00"},
  83         {"1", "11"},
  84         {"0", "01", "010"},
  85         {"0", "01"},
  86         {"one"}
  87     };
  88 
  89     @Test
  90     public void tree() throws InterruptedException, FileNotFoundException {
  91         shell.lookup(TabFolder.class).as(Selectable.class).selector().select("Tree");
  92         final Wrap<? extends Tree> tree = shell.lookup(Tree.class).wrap();
  93         for (String[] path : trees) {
  94             tree.as(StringTree.class, TreeItem.class).select(path);
  95         }
  96         Thread.sleep(1000);
  97     }
  98 
  99 }