Search in sources :

Example 1 with ModelContext

use of org.eclipse.scout.rt.client.ModelContextProxy.ModelContext in project scout.rt by eclipse.

the class AbstractPageWithTableTest method testModelContextOfInitPageAndInitTable.

@Test
public void testModelContextOfInitPageAndInitTable() {
    IForm mockForm = Mockito.mock(IForm.class);
    IOutline mockOutline = Mockito.mock(IOutline.class);
    ClientRunContexts.copyCurrent().withOutline(mockOutline, true).withForm(mockForm).run(new IRunnable() {

        @Override
        public void run() throws Exception {
            IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
            assertNotNull(desktop);
            desktop.setAvailableOutlines(CollectionUtility.arrayList(new PageWithTableOutline()));
            desktop.setOutline(PageWithTableOutline.class);
            desktop.activateFirstPage();
            IOutline outline = desktop.getOutline();
            assertNotNull(outline);
            assertSame(PageWithTableOutline.class, outline.getClass());
            IPage<?> page = outline.getActivePage();
            assertNotNull(page);
            assertSame(ParentItemTablePage.class, page.getClass());
            ParentItemTablePage tablePage = (ParentItemTablePage) page;
            // init page
            ModelContext initPageContext = tablePage.getInitPageContext();
            assertNotNull(initPageContext);
            assertSame(desktop, initPageContext.getDesktop());
            assertSame(outline, initPageContext.getOutline());
            // no context form must be set
            assertNull(initPageContext.getForm());
            // init table
            ModelContext initTableContext = tablePage.getInitTableContext();
            assertNotNull(initTableContext);
            assertSame(desktop, initTableContext.getDesktop());
            assertSame(outline, initTableContext.getOutline());
            // no context form must be set
            assertNull(initTableContext.getForm());
        }
    });
}
Also used : ModelContext(org.eclipse.scout.rt.client.ModelContextProxy.ModelContext) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IForm(org.eclipse.scout.rt.client.ui.form.IForm) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Example 2 with ModelContext

use of org.eclipse.scout.rt.client.ModelContextProxy.ModelContext in project scout.rt by eclipse.

the class AbstractPageWithNodesTest method testModelContextOfInitPageAndInitTable.

@Test
public void testModelContextOfInitPageAndInitTable() {
    IForm mockForm = Mockito.mock(IForm.class);
    IOutline mockOutline = Mockito.mock(IOutline.class);
    ClientRunContexts.copyCurrent().withOutline(mockOutline, true).withForm(mockForm).run(new IRunnable() {

        @Override
        public void run() throws Exception {
            IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
            assertNotNull(desktop);
            desktop.setAvailableOutlines(CollectionUtility.arrayList(new PageWithNodeOutline()));
            desktop.setOutline(PageWithNodeOutline.class);
            desktop.activateFirstPage();
            IOutline outline = desktop.getOutline();
            assertNotNull(outline);
            assertSame(PageWithNodeOutline.class, outline.getClass());
            IPage<?> page = outline.getActivePage();
            assertNotNull(page);
            assertSame(ParentItemNodePage.class, page.getClass());
            ParentItemNodePage nodePage = (ParentItemNodePage) page;
            // init page
            ModelContext initPageContext = nodePage.getInitPageContext();
            assertNotNull(initPageContext);
            assertSame(desktop, initPageContext.getDesktop());
            assertSame(outline, initPageContext.getOutline());
            // no context form must be set
            assertNull(initPageContext.getForm());
            // init table
            ModelContext initTableContext = nodePage.getInitTableContext();
            assertNotNull(initTableContext);
            assertSame(desktop, initTableContext.getDesktop());
            assertSame(outline, initTableContext.getOutline());
            // no context form must be set
            assertNull(initTableContext.getForm());
        }
    });
}
Also used : ModelContext(org.eclipse.scout.rt.client.ModelContextProxy.ModelContext) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IForm(org.eclipse.scout.rt.client.ui.form.IForm) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test)

Aggregations

ModelContext (org.eclipse.scout.rt.client.ModelContextProxy.ModelContext)2 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)2 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)2 IForm (org.eclipse.scout.rt.client.ui.form.IForm)2 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)2 Test (org.junit.Test)2