Example #1
0
 @Test
 public void getsRowCount() throws Exception {
   assertEquals(2, tree.getTreeItem("Node 2").rowCount());
   assertEquals(1, tree.getTreeItem("Node 3").rowCount());
   assertEquals(0, tree.getTreeItem("Node 4").rowCount());
   assertTrue(tree.hasItems());
 }
Example #2
0
  @Test
  public void cellOutOfRangeWithSingleColumnsTree() throws Exception {
    bot.checkBox("Multiple Columns").deselect();
    tree = bot.treeInGroup("Tree");

    assertEquals(0, tree.columnCount());
    runCellOutOfRangeTest(tree.getTreeItem("Node 1"), 1);
  }
Example #3
0
  @Test
  public void getsColumnTextBasedOnRowColumnNumbers() throws Exception {
    bot.checkBox("Multiple Columns").select();
    tree = bot.treeInGroup("Tree");

    assertEquals("2556", tree.cell(1, 2));
    assertEquals("Node 2", tree.cell(1, 0));
    assertEquals("today", tree.cell(3, 3));
  }
Example #4
0
  @Test
  public void getsTextCellBasedOnRowNumberColumnText() throws Exception {
    bot.checkBox("Multiple Columns").select();
    tree = bot.treeInGroup("Tree");

    assertEquals("2556", tree.cell(1, "Size"));
    assertEquals("Node 2", tree.cell(1, "Name"));
    assertEquals("today", tree.cell(3, "Modified"));
  }
Example #5
0
 @Test
 public void canUnCheckANode() throws Exception {
   bot.checkBox("SWT.CHECK").select();
   tree = bot.tree();
   SWTBotTreeItem item = tree.getTreeItem("Node 2");
   item.uncheck();
   assertFalse(tree.getTreeItem("Node 2").isChecked());
   assertTextContains("Selection [13]: SelectionEvent{Tree {} ", listeners);
   assertTextContains("data=null item=TreeItem {Node 2} detail=32", listeners);
 }
Example #6
0
 @Test
 public void setsMultipleSelection() throws Exception {
   bot.radio("SWT.MULTI").click();
   tree = bot.treeInGroup("Tree");
   tree.select(new String[] {"Node 2", "Node 4"});
   assertEquals(2, tree.selectionCount());
   TableCollection selection = tree.selection();
   assertEquals("Node 2", selection.get(0, 0));
   assertEquals("Node 4", selection.get(1, 0));
 }
Example #7
0
 @Test
 public void getsSingleSelection() throws Exception {
   bot.checkBox("Multiple Columns").select();
   tree = bot.treeInGroup("Tree");
   tree.select(2);
   TableCollection selection = tree.selection();
   assertEquals(1, selection.rowCount());
   assertEquals(4, selection.columnCount());
   assertEquals(
       new TableCollection()
           .add(new TableRow(new String[] {"Node 3", "images", "91571", "yesterday"})),
       selection);
 }
Example #8
0
 @Test
 public void expandsNode() throws Exception {
   bot.checkBox("Multiple Columns").select();
   bot.checkBox("Listen").select();
   Widget notifications = bot.textInGroup("Listeners").widget;
   tree = bot.treeInGroup("Tree");
   tree.expandNode("Node 2");
   assertEquals(6, tree.visibleRowCount());
   assertTextContains("Expand [17]: TreeEvent{Tree {} time=", notifications);
   assertTextContains(
       "data=null item=TreeItem {Node 2} detail=0 x=0 y=0 width=0 height=0 stateMask=0 text=null doit=true}",
       notifications);
 }
Example #9
0
 @Test
 public void expandsNodeToMax() throws Exception {
   bot.checkBox("Multiple Columns").select();
   bot.checkBox("Listen").select();
   tree = bot.treeInGroup("Tree");
   tree.expandNode("Node 2", true);
   assertEquals(7, tree.visibleRowCount());
   assertTextContains(
       "data=null item=TreeItem {Node 2} detail=0 x=0 y=0 width=0 height=0 stateMask=0 text=null doit=true}",
       bot.textInGroup("Listeners").widget);
   assertTextContains(
       "data=null item=TreeItem {Node 2.2} detail=0 x=0 y=0 width=0 height=0 stateMask=0 text=null doit=true}",
       bot.textInGroup("Listeners").widget);
 }
Example #10
0
  @Test
  public void getsMultipleSingleSelection() throws Exception {
    bot.radio("SWT.MULTI").click();
    bot.checkBox("Multiple Columns").select();
    tree = bot.treeInGroup("Tree");
    tree.select(new int[] {1, 2});

    TableCollection selection = tree.selection();
    assertEquals("Node 2", selection.get(0, 0));
    assertEquals("databases", selection.get(0, 1));
    assertEquals("2556", selection.get(0, 2));
    assertEquals("tomorrow", selection.get(0, 3));

    assertEquals(
        new TableRow(new String[] {"Node 3", "images", "91571", "yesterday"}), selection.get(1));
  }
Example #11
0
 @Test
 public void checkingATreeThatDoesNotHaveCheckStyleBitsThrowsException() throws Exception {
   try {
     tree.getTreeItem("Node 2").check();
     fail("Expecting an exception");
   } catch (IllegalArgumentException e) {
     assertEquals("The tree does not have the style SWT.CHECK", e.getMessage());
   }
 }
Example #12
0
 @Test
 public void canRightClickOnANode() throws Exception {
   SWTBotTreeItem node = tree.expandNode("Node 2").expandNode("Node 2.2").expandNode("Node 2.2.1");
   bot.button("Clear").click();
   node.contextMenu("getItem(Point) on mouse coordinates").click();
   assertTextContains("Selection [13]: SelectionEvent{Tree {} ", listeners);
   assertTextContains("MenuDetect [35]: Event {type=35 Tree {}", listeners);
   assertTextContains("getItem(Point(Point {", listeners);
 }
Example #13
0
 @Test
 public void canSelectAListOfNodes() throws Exception {
   bot.radio("SWT.MULTI").click();
   tree = bot.tree();
   SWTBotTreeItem node2 = tree.getTreeItem("Node 2").expand();
   bot.button("Clear").click();
   node2.select("Node 2.1", "Node 2.2");
   assertTrue(node2.getNode("Node 2.1").isSelected());
   assertTrue(node2.getNode("Node 2.2").isSelected());
 }
Example #14
0
  @Test
  public void getsColumnTextBasedOnRowColumnNumbers() throws Exception {
    bot.checkBox("Multiple Columns").select();
    tree = bot.treeInGroup("Tree");
    SWTBotTreeItem item = tree.getTreeItem("Node 2");

    assertEquals("2556", item.cell(0, 2));
    assertEquals("Node 2.1", item.cell(0, 0));
    assertEquals("tomorrow", item.cell(1, 3));
  }
Example #15
0
  @Test
  public void getsColumnTextBasedOnColumnNumbers() throws Exception {
    bot.checkBox("Multiple Columns").select();
    tree = bot.treeInGroup("Tree");
    SWTBotTreeItem item = tree.getTreeItem("Node 1");

    assertEquals("Node 1", item.cell(0));
    assertEquals("classes", item.cell(1));
    assertEquals("today", item.cell(3));
    assertEquals("0", item.cell(2));
  }
Example #16
0
 @Test
 public void canToggleANode() throws Exception {
   bot.checkBox("SWT.CHECK").select();
   tree = bot.tree();
   SWTBotTreeItem item = tree.getTreeItem("Node 2");
   assertFalse(item.isChecked());
   item.toggleCheck();
   assertTrue(item.isChecked());
   item.toggleCheck();
   assertFalse(item.isChecked());
 }
Example #17
0
 @Test
 public void getsRow() throws Exception {
   bot.checkBox("Multiple Columns").select();
   tree = bot.treeInGroup("Tree");
   SWTBotTreeItem item = tree.getTreeItem("Node 3");
   TableRow row = item.row();
   assertEquals(4, row.columnCount());
   assertEquals("Node 3", row.get(0));
   assertEquals("images", row.get(1));
   assertEquals("91571", row.get(2));
   assertEquals("yesterday", row.get(3));
 }
Example #18
0
  @Test
  public void getsAllColumnHeadings() throws Exception {
    bot.checkBox("Multiple Columns").select();
    tree = bot.treeInGroup("Tree");
    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("Name");
    arrayList.add("Type");
    arrayList.add("Size");
    arrayList.add("Modified");

    assertEquals(arrayList, tree.columns());
  }
Example #19
0
 @Test
 public void cannotFindANodeWithIncorrectNodeIndex() throws Exception {
   SWTBotTreeItem node = tree.expandNode("Node 2");
   try {
     node.getNode("Node 2.2", 1);
     fail("Was expecting an AssertionFailedException");
   } catch (AssertionFailedException e) {
     assertEquals(
         "assertion failed: The index (1) was more than the number of nodes (1) in the tree.",
         e.getMessage());
   }
 }
Example #20
0
  @Test
  public void canDoubleClickOnANode() throws Exception {
    SWTBotTreeItem treeItem = tree.getTreeItem("Node 2");

    treeItem.doubleClick();

    assertTextContains("MouseDown [3]: MouseEvent{Tree {} ", listeners);
    assertTextContains("Selection [13]: SelectionEvent{Tree {} ", listeners);
    assertTextContains("item=TreeItem {Node 2}", listeners);
    assertTextContains("MouseDoubleClick [8]: MouseEvent{Tree {} ", listeners);
    assertTextContains("DefaultSelection [14]: SelectionEvent{Tree {} ", listeners);
    assertTextContains("MouseUp [4]: MouseEvent{Tree {} ", listeners);
  }
Example #21
0
 private void runCellOutOfRangeTest(SWTBotTreeItem testNode, int columnNumber) throws Exception {
   try {
     testNode.cell(columnNumber);
     fail(
         "Expected IllegalArgumentException since '"
             + testNode.getText()
             + "' does not have column at index ("
             + columnNumber
             + ")");
   } catch (IllegalArgumentException e) {
     String expected =
         "The column index ("
             + columnNumber
             + ") is more than the number of column("
             + tree.columnCount()
             + ") in the tree.";
     assertEquals(expected, e.getMessage());
   }
 }
Example #22
0
  @Test
  public void getNodeBasedOnIndex() throws Exception {
    bot.checkBox("Multiple Columns").select();
    tree = bot.treeInGroup("Tree");
    SWTBotTreeItem item = tree.getTreeItem("Node 2");
    SWTBotTreeItem testNode = item.getNode(0);
    assertEquals("Node 2.1", testNode.getText());

    testNode = item.getNode(1);
    assertEquals("Node 2.2", testNode.getText());

    testNode = testNode.getNode(0);
    assertEquals("Node 2.2.1", testNode.getText());

    try {
      assertEquals(0, testNode.rowCount());
      testNode.getNode(1);
      fail("Expected IllegalArgumentException since 'Node 2.2.1' does not have row at index (1)");
    } catch (IllegalArgumentException e) {
      String expected = "The row number (1) is more than the number of rows(0) in the tree.";
      assertEquals(expected, e.getMessage());
    }
  }
Example #23
0
 @Test
 public void setsSelection() throws Exception {
   tree.select(3);
   assertEquals(1, tree.selectionCount());
 }
Example #24
0
 @Test
 public void getsSelectionCount() throws Exception {
   assertEquals(0, tree.selection().columnCount());
   assertEquals(0, tree.selection().rowCount());
   assertEquals(0, tree.selectionCount());
 }
Example #25
0
 @Test
 public void getsColumnCountOnMultiColumnTree() throws Exception {
   bot.checkBox("Multiple Columns").select();
   tree = bot.treeInGroup("Tree");
   assertEquals(4, tree.columnCount());
 }
Example #26
0
 @Test
 public void getsColumnCount() throws Exception {
   assertEquals(0, tree.columnCount());
 }
Example #27
0
 @Test
 public void getsRowCount() throws Exception {
   assertEquals(4, tree.rowCount());
   assertTrue(tree.hasItems());
 }
Example #28
0
 @Test
 public void getsAllTreeItems() throws Exception {
   SWTBotTreeItem[] items = tree.getAllItems();
   for (int i = 0; i < items.length; i++) assertEquals("Node " + (i + 1), items[i].getText());
 }
Example #29
0
 @Test
 public void canFindANode() throws Exception {
   SWTBotTreeItem node = tree.expandNode("Node 2");
   assertText("Node 2.2", node.getNode("Node 2.2"));
   assertText("Node 2.2", node.getNode("Node 2.2", 0));
 }
Example #30
0
 @Test
 public void unselectsSelection() throws Exception {
   tree.unselect();
   assertEquals(0, tree.selectionCount());
 }