Search in sources :

Example 1 with Coordinates

use of org.eclipse.scout.rt.client.ui.Coordinates in project scout.rt by eclipse.

the class ClientSessionTest method testStopWithBlockingClientCallback.

@Test
public void testStopWithBlockingClientCallback() throws Exception {
    TestingUtility.registerBean(new BeanMetaData(TestEnvironmentClientSession.class));
    TestingUtility.registerBean(new BeanMetaData(JobCompletionDelayOnSessionShutdown.class).withProducer(new IBeanInstanceProducer<JobCompletionDelayOnSessionShutdown>() {

        @Override
        public JobCompletionDelayOnSessionShutdown produce(IBean<JobCompletionDelayOnSessionShutdown> bean) {
            return new JobCompletionDelayOnSessionShutdown() {

                @Override
                protected Long getDefaultValue() {
                    return 1000L;
                }
            };
        }
    }));
    session = BEANS.get(ClientSessionProvider.class).provide(ClientRunContexts.empty().withUserAgent(UserAgents.createDefault()));
    // request a geo location
    Future<Coordinates> geo = ModelJobs.schedule(new Callable<Future<Coordinates>>() {

        @Override
        public Future<Coordinates> call() throws Exception {
            return IDesktop.CURRENT.get().requestGeolocation();
        }
    }, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true))).awaitDoneAndGet();
    assertFalse(geo.isDone());
    // close from ui
    ModelJobs.schedule(new IRunnable() {

        @Override
        public void run() throws Exception {
            session.getDesktop().getUIFacade().closeFromUI(true);
        }
    }, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true))).awaitDone();
    assertTrue(geo.isCancelled());
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBeanInstanceProducer(org.eclipse.scout.rt.platform.IBeanInstanceProducer) Coordinates(org.eclipse.scout.rt.client.ui.Coordinates) JobCompletionDelayOnSessionShutdown(org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) IBean(org.eclipse.scout.rt.platform.IBean) Callable(java.util.concurrent.Callable) TestEnvironmentClientSession(org.eclipse.scout.rt.client.testenvironment.TestEnvironmentClientSession) Test(org.junit.Test)

Example 2 with Coordinates

use of org.eclipse.scout.rt.client.ui.Coordinates 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 Coordinates

use of org.eclipse.scout.rt.client.ui.Coordinates 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)

Aggregations

Coordinates (org.eclipse.scout.rt.client.ui.Coordinates)3 Test (org.junit.Test)3 TestEnvironmentDesktop (org.eclipse.scout.rt.client.testenvironment.ui.desktop.TestEnvironmentDesktop)2 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 JobCompletionDelayOnSessionShutdown (org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown)1 TestEnvironmentClientSession (org.eclipse.scout.rt.client.testenvironment.TestEnvironmentClientSession)1 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)1 IBean (org.eclipse.scout.rt.platform.IBean)1 IBeanInstanceProducer (org.eclipse.scout.rt.platform.IBeanInstanceProducer)1 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)1