예제 #1
0
 private RemotePage createPage() {
   PageDescriptor descriptor = spy(new PageDescriptor("foo", TestPage.class));
   UI ui = mock(UI.class);
   RemoteUI uiRenderer = mock(RemoteUI.class);
   when(uiRenderer.getRemoteUIId()).thenReturn("foo");
   RemotePage renderer2 = new RemotePage(ui, uiRenderer, descriptor, mock(PageData.class));
   renderer2.createControl(shell);
   return spy(renderer2);
 }
예제 #2
0
  @Test
  public void testDestroyDoesNotDestroyRootPageRenderer() {
    RemotePage root = createPage();
    PageDescriptor descriptor = root.getDescriptor();
    doReturn(Boolean.TRUE).when(descriptor).isTopLevel();
    PageFlow flow = new PageFlow(root);

    flow.destroy();

    verify(root, never()).destroy();
  }
예제 #3
0
  @Test
  public void testDestroyDoesNotDisposeRootControl() {
    RemotePage root = createPage();
    PageDescriptor descriptor = root.getDescriptor();
    doReturn(Boolean.TRUE).when(descriptor).isTopLevel();
    PageFlow flow = new PageFlow(root);

    flow.destroy();

    assertFalse(root.getControl().isDisposed());
  }
예제 #4
0
  @Test
  public void testDestroyDestroysPageRenderes() {
    RemotePage root = mock(RemotePage.class);
    PageDescriptor descriptor = mock(PageDescriptor.class);
    doReturn(Boolean.TRUE).when(descriptor).isTopLevel();
    when(root.getDescriptor()).thenReturn(descriptor);
    PageFlow flow = new PageFlow(root);
    RemotePage renderer1 = createPage();
    RemotePage renderer2 = createPage();
    flow.add(renderer1);
    flow.add(renderer2);

    flow.destroy();

    InOrder order = inOrder(renderer1, renderer2);
    order.verify(renderer1).destroy();
    order.verify(renderer2).destroy();
  }
예제 #5
0
  @Test
  public void testGetAllRenderers() {
    RemotePage root = mock(RemotePage.class);
    PageDescriptor descriptor = mock(PageDescriptor.class);
    doReturn(Boolean.TRUE).when(descriptor).isTopLevel();
    when(root.getDescriptor()).thenReturn(descriptor);
    PageFlow flow = new PageFlow(root);
    RemotePage renderer1 = createPage();
    RemotePage renderer2 = createPage();
    flow.add(renderer1);
    flow.add(renderer2);

    List<PageRenderer> allPages = flow.getAllRenderers();

    assertEquals(3, allPages.size());
    assertSame(root, allPages.get(0));
    assertSame(renderer1, allPages.get(1));
    assertSame(renderer2, allPages.get(2));
  }
예제 #6
0
  @Test
  public void testDestroyDisposesControls() {
    RemotePage root = mock(RemotePage.class);
    PageDescriptor descriptor = mock(PageDescriptor.class);
    doReturn(Boolean.TRUE).when(descriptor).isTopLevel();
    when(root.getDescriptor()).thenReturn(descriptor);
    PageFlow flow = new PageFlow(root);
    RemotePage renderer1 = createPage();
    RemotePage renderer2 = createPage();
    flow.add(renderer1);
    flow.add(renderer2);

    flow.destroy();

    assertTrue(renderer1.getControl().isDisposed());
    assertTrue(renderer2.getControl().isDisposed());
  }