@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());
 }
 @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);
 }
  @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);
  }
 @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());
   }
 }
 @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());
 }
  @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));
  }
  @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));
  }
 @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());
 }
 @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));
 }
Beispiel #10
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);
  }
Beispiel #11
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());
    }
  }