Skip to content

Commit

Permalink
Merge pull request #451 from TikhomirovSergey/master
Browse files Browse the repository at this point in the history
#450 FIX
  • Loading branch information
TikhomirovSergey authored Aug 6, 2016
2 parents bd19d78 + a3065c2 commit 832846a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private Object transformToListenable(Object toBeTransformed) {
return null;
}

Object result = null;
Object result = toBeTransformed;
if (getClassForProxy(toBeTransformed.getClass()) != null) {
result = context.getBean(DefaultBeanConfiguration.COMPONENT_BEAN, toBeTransformed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.util.Collection;
import java.util.List;

public class DefaultListener implements Listener, AppiumWebDriverEventListener, ListensToException,
class DefaultListener implements Listener, AppiumWebDriverEventListener, ListensToException,
SearchingEventListener, NavigationEventListener,
JavaScriptEventListener, ElementEventListener, AlertEventListener,
WindowEventListener, ContextEventListener, RotationEventListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.appium.java_client.events;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;

import io.appium.java_client.events.listeners.AlertListener;
Expand All @@ -18,6 +20,7 @@
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.Capabilities;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class DefaultEventListenerTest extends BaseListenerTest {
Expand Down Expand Up @@ -88,4 +91,11 @@ public void windowEventListener() {
assertThat(super.assertThatWindowListenerWorks(driver, SingleListeners
.listeners.get(WindowListener.class), StringUtils.EMPTY), is(true));
}

@Test
public void whenNonListenableObjectIsReturned() {
Capabilities capabilities = driver.getCapabilities();
assertNotNull(capabilities);
assertEquals(capabilities.asMap().size(), 2);
}
}
14 changes: 13 additions & 1 deletion src/test/java/io/appium/java_client/events/EmptyWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.ContextAware;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.HasCapabilities;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Rotatable;
import org.openqa.selenium.ScreenOrientation;
Expand All @@ -24,15 +26,18 @@
import org.openqa.selenium.internal.FindsByTagName;
import org.openqa.selenium.internal.FindsByXPath;
import org.openqa.selenium.logging.Logs;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class EmptyWebDriver implements WebDriver, ContextAware, Rotatable, FindsByClassName,
FindsByCssSelector, FindsById, FindsByLinkText, FindsByTagName, FindsByXPath,
FindsByAccessibilityId<StubWebElement>, FindsByAndroidUIAutomator<StubWebElement>,
FindsByIosUIAutomation<StubWebElement>, JavascriptExecutor {
FindsByIosUIAutomation<StubWebElement>, JavascriptExecutor, HasCapabilities {

private static List<StubWebElement> createStubList() {
return ImmutableList.of(new StubWebElement(), new StubWebElement());
Expand Down Expand Up @@ -198,6 +203,13 @@ private static List<StubWebElement> createStubList() {
return null;
}

@Override public Capabilities getCapabilities() {
Map<String, Object> map = new HashMap<>();
map.put("0",StringUtils.EMPTY);
map.put("1",StringUtils.EMPTY);
return new DesiredCapabilities(map);
}

private class StubTargetLocator implements TargetLocator {

private final WebDriver driver;
Expand Down

0 comments on commit 832846a

Please sign in to comment.