@Test public void testInterfacesProxiedProperly() throws Exception { WebDriver actual = new PermissiveStubDriver(); final WebDriver webdriver = ThreadGuard.protect(actual); HasTouchScreen hasTouchScreen = (HasTouchScreen) webdriver; assertNotNull(hasTouchScreen); }
@Test public void testProtect() throws Exception { WebDriver actual = new PermissiveStubDriver(); final WebDriver protect = ThreadGuard.protect(actual); final AtomicInteger successes = new AtomicInteger(); Thread foo = new Thread( new Runnable() { public void run() { protect.findElement(By.id("foo")); successes.incrementAndGet(); } }); foo.start(); foo.join(); assertEquals(0, successes.get()); }
@Test public void testProtectSuccess() throws Exception { WebDriver actual = new PermissiveStubDriver(); final WebDriver protect = ThreadGuard.protect(actual); assertNull(protect.findElement(By.id("foo"))); }