Search in sources :

Example 1 with TestEnvironmentDesktop

use of org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop in project scout.rt by eclipse.

the class AbstractDesktopTest method testDataChangedSimple.

@Test
public void testDataChangedSimple() {
    TestEnvironmentDesktop desktop = (TestEnvironmentDesktop) IDesktop.CURRENT.get();
    final Holder<Object[]> resultHolder = new Holder<Object[]>(Object[].class);
    desktop.addDataChangeListener(new DataChangeListener() {

        @Override
        public void dataChanged(Object... dataTypes) {
            resultHolder.setValue(dataTypes);
        }
    }, TEST_DATA_TYPE_1, TEST_DATA_TYPE_2);
    desktop.dataChanged(TEST_DATA_TYPE_1, TEST_DATA_TYPE_2);
    verifyDataChanged(resultHolder);
}
Also used : Holder(org.eclipse.scout.rt.platform.holders.Holder) DataChangeListener(org.eclipse.scout.rt.client.ui.DataChangeListener) TestEnvironmentDesktop(org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop) Test(org.junit.Test)

Example 2 with TestEnvironmentDesktop

use of org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop in project scout.rt by eclipse.

the class AbstractDesktopTest method testGeolocationFailure.

@Test(expected = ProcessingException.class)
public void testGeolocationFailure() throws Throwable {
    TestEnvironmentDesktop desktop = (TestEnvironmentDesktop) IDesktop.CURRENT.get();
    Future<Coordinates> coordinatesFurure = desktop.requestGeolocation();
    desktop.getUIFacade().fireGeolocationFailed("-1", "test failure");
    try {
        coordinatesFurure.get();
    } catch (ExecutionException e) {
        throw e.getCause();
    }
}
Also used : Coordinates(org.eclipse.scout.rt.client.ui.Coordinates) ExecutionException(java.util.concurrent.ExecutionException) TestEnvironmentDesktop(org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop) Test(org.junit.Test)

Example 3 with TestEnvironmentDesktop

use of org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop in project scout.rt by eclipse.

the class AbstractDesktopTest method testClosingDoBeforeClosingInternal.

/**
 * {@link AbstractDesktop#doBeforeClosingInternal()}
 */
@Test
// ensures that this test runs with its own clean desktop
@RunWithClientSession(value = TestEnvironmentClientSession.class, provider = ClientSessionProvider.class)
public void testClosingDoBeforeClosingInternal() {
    TestEnvironmentDesktop desktop = (TestEnvironmentDesktop) IDesktop.CURRENT.get();
    boolean closing = desktop.doBeforeClosingInternal();
    assertTrue(closing);
}
Also used : TestEnvironmentDesktop(org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop) Test(org.junit.Test) RunWithClientSession(org.eclipse.scout.rt.testing.client.runner.RunWithClientSession)

Example 4 with TestEnvironmentDesktop

use of org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop in project scout.rt by eclipse.

the class AbstractDesktopTest method testGeolocation.

@Test
public void testGeolocation() throws InterruptedException, ExecutionException {
    TestEnvironmentDesktop desktop = (TestEnvironmentDesktop) IDesktop.CURRENT.get();
    Future<Coordinates> coordinatesFurure = desktop.requestGeolocation();
    desktop.getUIFacade().fireGeolocationDetermined("1.0", "2.0");
    Coordinates coordinates = coordinatesFurure.get();
    assertEquals("1.0", coordinates.getLatitude());
    assertEquals("2.0", coordinates.getLongitude());
}
Also used : Coordinates(org.eclipse.scout.rt.client.ui.Coordinates) TestEnvironmentDesktop(org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop) Test(org.junit.Test)

Example 5 with TestEnvironmentDesktop

use of org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop in project scout.rt by eclipse.

the class AbstractDesktopTest method testDeepLinkHandling.

@Test
public void testDeepLinkHandling() throws Throwable {
    IBean<P_TestDeepLinks> reg = BEANS.getBeanManager().registerClass(P_TestDeepLinks.class);
    try {
        // Create a new desktop, because the IDesktop.CURRENT might be in a state where deep links are not handled (e.g. form open)
        final TestEnvironmentDesktop desktop = new TestEnvironmentDesktop();
        assertFalse(desktop.handleDeepLink(null));
        assertTrue(desktop.handleDeepLink("junittest-ok"));
        assertDeepLinkException(desktop, "junittest");
        assertDeepLinkException(desktop, "junittest-123");
        assertDeepLinkException(desktop, "doesnotexist");
        assertDeepLinkException(desktop, "doesnotexist-123");
    } finally {
        BEANS.getBeanManager().unregisterBean(reg);
    }
}
Also used : TestEnvironmentDesktop(org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop) Test(org.junit.Test)

Aggregations

TestEnvironmentDesktop (org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop)9 Test (org.junit.Test)8 Coordinates (org.eclipse.scout.rt.client.ui.Coordinates)2 DataChangeListener (org.eclipse.scout.rt.client.ui.DataChangeListener)2 Holder (org.eclipse.scout.rt.platform.holders.Holder)2 ExecutionException (java.util.concurrent.ExecutionException)1 RunWithClientSession (org.eclipse.scout.rt.testing.client.runner.RunWithClientSession)1