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());
}
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();
}
}
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());
}
Aggregations