Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#450 FIX #451

Merged
merged 1 commit into from
Aug 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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