Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.TreePath


  }

  @Test
  public void hasChildrenShouldReturnFalseIfTheGivenPathIsNull() {
    // Given a parent is null:
    TreePath parent = null;

    // When asking whether the parent has children:
    boolean hasChildren = content.hasChildren(parent);

    // Then false is returned:
View Full Code Here


  }

  @Test
  public void hasChildrenShouldReturnTrueIfTheGivenPathHasChildren() {
    // Given a parent has children:
    TreePath parent = new TreePath(new Object[]{0, 1, 2});
    TreePath leaf = parent.createChildPath(100);

    ITreePathBuilder builder = mock(ITreePathBuilder.class);
    given(builder.build(any())).willReturn(Arrays.asList(leaf));

    content = create(builder);
View Full Code Here

  }

  @Test
  public void shouldAlwaysReturnTheDataOfTheLatestInput() {
    // Given that an input has already been set:
    List<TreePath> input1 = asList(new TreePath(new Object[]{"a", "b"}));
    ITreePathBuilder builder = mock(ITreePathBuilder.class);
    given(builder.build(input1)).willReturn(input1);
    content = create(builder);
    content.inputChanged(null, null, input1);

    // When new input is set, gets the new root elements:
    TreePath input2 = new TreePath(new Object[]{0, 1});
    given(builder.build(input2)).willReturn(asList(input2));
    content.inputChanged(null, input1, input2);
    Object[] elements = content.getElements(input2);

    // Then data from new input should be returned:
    Object[] expected = new Object[]{input2.getFirstSegment()};
    assertThat(elements, is(expected));
  }
View Full Code Here

public class ForwardingTreePathContentProviderTest
    extends ForwardingStructuredContentProviderTest {
 
  @Test
  public void getChildrenShouldBeDelegated() {
    TreePath parent = TreePath.EMPTY;
    create().getChildren(parent);
    assertCall("getChildren", parent);
  }
View Full Code Here

    assertCall("getParents", child);
  }
 
  @Test
  public void hasChildrenShouldBeDelegated() {
    TreePath parent = TreePath.EMPTY;
    create().hasChildren(parent);
    assertCall("hasChildren", parent);
  }
View Full Code Here

    ITreeContentProvider contentProvider = mock(ITreeContentProvider.class);
    given(contentProvider.getElements(any()))
        .willReturn(new Object[]{bigger, smaller});

    IValueProvider valueProvider = mock(IValueProvider.class);
    given(valueProvider.getValue(new TreePath(new Object[]{bigger})))
        .willReturn(bigger);
    given(valueProvider.getValue(new TreePath(new Object[]{smaller})))
        .willReturn(smaller);

    TreeViewer viewer = new TreeViewer(shell);
    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(new LabelProvider());
View Full Code Here

* Tests for {@link TreePaths}
*/
public class TreePathsTest {

  private static TreePath newPath() {
    return new TreePath(new Object[]{"1", "2", "3"});
  }
View Full Code Here

  @Rule
  public ExpectedException thrown = ExpectedException.none();

  @Test
  public void headPathShouldReturnTheCorrectSubPath() {
    TreePath path = new TreePath(new Object[]{"a", "b", "c"});
    TreePath expected = path.getParentPath();
    TreePath actual = TreePaths.headPath(path, path.getSegmentCount() - 1);
    assertThat(actual, equalTo(expected));
  }
View Full Code Here

    assertThat(actual, equalTo(expected));
  }

  @Test
  public void headPathShouldThrowAnExceptionIfIndexIsGreaterThanThePathLength() {
    TreePath path = newPath();
    thrown.expect(IllegalArgumentException.class);
    TreePaths.headPath(path, path.getSegmentCount() + 1);
  }
View Full Code Here

    TreePaths.headPath(path, path.getSegmentCount() + 1);
  }
 
  @Test
  public void headPathShouldReturnAnEqualPathIfIndexIsEqualToThePathLength() {
    TreePath path = newPath();
    assertThat(TreePaths.headPath(path, path.getSegmentCount()), equalTo(path));
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.TreePath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.