honeydew 0.12.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +79 -8
- data/Rakefile +2 -2
- data/examples/cucumber/Gemfile +5 -0
- data/{example → examples/cucumber}/Rakefile +0 -0
- data/{example → examples/cucumber}/features/example.feature +0 -0
- data/{example → examples/cucumber}/features/step_definitions/honeydew_steps.rb +0 -0
- data/examples/rspec/spec/browse_spec.rb +16 -0
- data/examples/rspec/spec/spec_helper.rb +6 -0
- data/honeydew.gemspec +17 -17
- data/honeydew.iml +12 -18
- data/lib/honeydew.rb +1 -72
- data/lib/honeydew/device.rb +79 -44
- data/lib/honeydew/device_actions.rb +32 -100
- data/lib/honeydew/device_commands.rb +36 -23
- data/lib/honeydew/device_matchers.rb +29 -22
- data/lib/honeydew/dsl.rb +1 -1
- data/lib/honeydew/honeydew.rb +82 -0
- data/lib/honeydew/version.rb +1 -1
- data/{android-server → server}/.gitignore +0 -0
- data/{android-server → server}/pom.xml +16 -6
- data/{android-server → server}/repo/com/google/android/uiautomator/4.1.1.4/_maven.repositories +0 -0
- data/{android-server → server}/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.jar +0 -0
- data/{android-server → server}/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.pom +0 -0
- data/{android-server → server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.jar +0 -0
- data/{android-server → server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.pom +0 -0
- data/{android-server → server}/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/maven-metadata-local.xml +0 -0
- data/{android-server → server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/_maven.repositories +0 -0
- data/{android-server → server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.jar +0 -0
- data/{android-server → server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.pom +0 -0
- data/{android-server → server}/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/maven-metadata-local.xml +0 -0
- data/{android-server → server}/repo/commons-jxpath/commons-jxpath/maven-metadata-local.xml +0 -0
- data/server/repo/fi/iki/elonen/nanohttpd-webserver/2.0.3/nanohttpd-webserver-2.0.3.jar +0 -0
- data/server/repo/fi/iki/elonen/nanohttpd-webserver/2.0.3/nanohttpd-webserver-2.0.3.pom +9 -0
- data/server/repo/fi/iki/elonen/nanohttpd-webserver/maven-metadata-local.xml +12 -0
- data/server/repo/fi/iki/elonen/nanohttpd/2.0.3/nanohttpd-2.0.3.jar +0 -0
- data/server/repo/fi/iki/elonen/nanohttpd/2.0.3/nanohttpd-2.0.3.pom +9 -0
- data/server/repo/fi/iki/elonen/nanohttpd/maven-metadata-local.xml +12 -0
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/Action.java +13 -6
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/ActionsExecutor.java +3 -2
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/Command.java +6 -1
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/Result.java +7 -7
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/TestRunner.java +14 -6
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/Click.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/ClickAndWaitForNewWindow.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/DumpWindowHierarchy.java +5 -5
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/HasSettingsMenuItem.java +4 -5
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/InspectOptionInSettingsMenu.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsButtonPresent.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsChildCountEqualTo.java +4 -4
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsElementWithNestedTextPresent.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsOptionInSettingsMenuDisabled.java +1 -1
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsOptionInSettingsMenuEnabled.java +1 -1
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/IsTextPresent.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/LaunchApp.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/LaunchHome.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/LongClick.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/PressBack.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/PressEnter.java +4 -4
- data/server/src/main/java/com/amplify/honeydew_server/actions/ScrollToTextByIndex.java +27 -0
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SelectFromAppsList.java +4 -4
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SelectMenuInSettings.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SetText.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SetTextByIndex.java +2 -2
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/SetTextByLabel.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/Unlock.java +3 -3
- data/{android-server/src/main/java/com/uiautomator_cucumber/android_server → server/src/main/java/com/amplify/honeydew_server}/actions/WakeUp.java +4 -4
- data/server/src/main/java/com/amplify/honeydew_server/httpd/RemoteCommandReceiver.java +66 -0
- data/spec/honeydew/device_matchers_spec.rb +21 -42
- data/spec/honeydew/device_spec.rb +38 -36
- data/spec/spec_helper.rb +2 -25
- metadata +93 -92
- data/android-server/src/main/java/com/uiautomator_cucumber/android_server/httpd/NanoHTTPD.java +0 -1100
- data/android-server/src/main/java/com/uiautomator_cucumber/android_server/httpd/RemoteCommandReceiver.java +0 -64
- data/example/Gemfile +0 -5
- data/example/features/support/hooks.rb +0 -4
- data/lib/honeydew/hooks.rb +0 -0
- data/lib/honeydew/step_definitions.rb +0 -75
- data/lib/tasks/honeydew.rake +0 -7
- data/todo.md +0 -9
@@ -1,9 +1,9 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.UiDevice;
|
4
4
|
import com.android.uiautomator.core.UiObjectNotFoundException;
|
5
|
-
import com.
|
6
|
-
import com.
|
5
|
+
import com.amplify.honeydew_server.Action;
|
6
|
+
import com.amplify.honeydew_server.Result;
|
7
7
|
|
8
8
|
import java.util.Map;
|
9
9
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.*;
|
4
|
-
import com.
|
5
|
-
import com.
|
4
|
+
import com.amplify.honeydew_server.Action;
|
5
|
+
import com.amplify.honeydew_server.Result;
|
6
6
|
|
7
7
|
import java.util.Map;
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.*;
|
4
|
-
import com.
|
5
|
-
import com.
|
4
|
+
import com.amplify.honeydew_server.Action;
|
5
|
+
import com.amplify.honeydew_server.Result;
|
6
6
|
|
7
7
|
import java.util.Map;
|
8
8
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.UiDevice;
|
4
4
|
import com.android.uiautomator.core.UiObjectNotFoundException;
|
5
|
-
import com.
|
6
|
-
import com.
|
5
|
+
import com.amplify.honeydew_server.Action;
|
6
|
+
import com.amplify.honeydew_server.Result;
|
7
7
|
|
8
8
|
import java.util.Map;
|
9
9
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.*;
|
4
|
-
import com.
|
5
|
-
import com.
|
4
|
+
import com.amplify.honeydew_server.Action;
|
5
|
+
import com.amplify.honeydew_server.Result;
|
6
6
|
|
7
7
|
import java.util.Map;
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.*;
|
4
|
-
import com.
|
5
|
-
import com.
|
4
|
+
import com.amplify.honeydew_server.Action;
|
5
|
+
import com.amplify.honeydew_server.Result;
|
6
6
|
|
7
7
|
import java.util.Map;
|
8
8
|
|
@@ -16,4 +16,4 @@ public class PressEnter extends Action {
|
|
16
16
|
getUiDevice().pressEnter();
|
17
17
|
return Result.OK;
|
18
18
|
}
|
19
|
-
}
|
19
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
|
+
|
3
|
+
import android.util.Log;
|
4
|
+
import com.amplify.honeydew_server.Action;
|
5
|
+
import com.amplify.honeydew_server.Result;
|
6
|
+
import com.android.uiautomator.core.*;
|
7
|
+
|
8
|
+
import java.util.Map;
|
9
|
+
|
10
|
+
public class ScrollToTextByIndex extends Action {
|
11
|
+
public ScrollToTextByIndex(UiDevice uiDevice) {
|
12
|
+
super(uiDevice);
|
13
|
+
}
|
14
|
+
|
15
|
+
@Override
|
16
|
+
public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
|
17
|
+
Log.i("ScrollToTextByIndex", "Found index field: " + arguments.get("index"));
|
18
|
+
|
19
|
+
String text = (String) arguments.get("text");
|
20
|
+
int index = Integer.parseInt((String) arguments.get("index"));
|
21
|
+
|
22
|
+
UiSelector scrollSelector = new UiSelector().scrollable(true).index(index);
|
23
|
+
UiScrollable uiScrollable = new UiScrollable(scrollSelector);
|
24
|
+
|
25
|
+
return uiScrollable.scrollTextIntoView(text) ? Result.OK : Result.FAILURE;
|
26
|
+
}
|
27
|
+
}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.*;
|
4
|
-
import com.
|
5
|
-
import com.
|
4
|
+
import com.amplify.honeydew_server.Action;
|
5
|
+
import com.amplify.honeydew_server.Result;
|
6
6
|
|
7
7
|
import java.util.Map;
|
8
8
|
|
@@ -13,7 +13,7 @@ public class SelectFromAppsList extends Action {
|
|
13
13
|
|
14
14
|
@Override
|
15
15
|
public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
|
16
|
-
String appName = (String)
|
16
|
+
String appName = (String)arguments.get("appName");
|
17
17
|
//TODO: Using a better selector
|
18
18
|
UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(false));
|
19
19
|
settingsMenu.setAsVerticalList();
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.*;
|
4
|
-
import com.
|
5
|
-
import com.
|
4
|
+
import com.amplify.honeydew_server.Action;
|
5
|
+
import com.amplify.honeydew_server.Result;
|
6
6
|
|
7
7
|
import java.util.Map;
|
8
8
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.UiDevice;
|
4
4
|
import com.android.uiautomator.core.UiObject;
|
5
5
|
import com.android.uiautomator.core.UiObjectNotFoundException;
|
6
6
|
import com.android.uiautomator.core.UiSelector;
|
7
|
-
import com.
|
8
|
-
import com.
|
7
|
+
import com.amplify.honeydew_server.Action;
|
8
|
+
import com.amplify.honeydew_server.Result;
|
9
9
|
|
10
10
|
import java.util.Map;
|
11
11
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import android.util.*;
|
4
4
|
import com.android.uiautomator.core.*;
|
5
|
-
import com.
|
5
|
+
import com.amplify.honeydew_server.*;
|
6
6
|
|
7
7
|
import java.util.*;
|
8
8
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.UiDevice;
|
4
4
|
import com.android.uiautomator.core.UiObject;
|
5
5
|
import com.android.uiautomator.core.UiObjectNotFoundException;
|
6
6
|
import com.android.uiautomator.core.UiSelector;
|
7
|
-
import com.
|
8
|
-
import com.
|
7
|
+
import com.amplify.honeydew_server.Action;
|
8
|
+
import com.amplify.honeydew_server.Result;
|
9
9
|
|
10
10
|
import java.util.Map;
|
11
11
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.UiDevice;
|
4
4
|
import com.android.uiautomator.core.UiObject;
|
5
5
|
import com.android.uiautomator.core.UiObjectNotFoundException;
|
6
6
|
import com.android.uiautomator.core.UiSelector;
|
7
|
-
import com.
|
8
|
-
import com.
|
7
|
+
import com.amplify.honeydew_server.Action;
|
8
|
+
import com.amplify.honeydew_server.Result;
|
9
9
|
|
10
10
|
import java.util.Map;
|
11
11
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
package com.
|
1
|
+
package com.amplify.honeydew_server.actions;
|
2
2
|
|
3
3
|
import com.android.uiautomator.core.*;
|
4
|
-
import com.
|
5
|
-
import com.
|
4
|
+
import com.amplify.honeydew_server.Action;
|
5
|
+
import com.amplify.honeydew_server.Result;
|
6
6
|
import android.os.RemoteException;
|
7
7
|
|
8
8
|
import java.util.Map;
|
@@ -21,4 +21,4 @@ public class WakeUp extends Action {
|
|
21
21
|
}
|
22
22
|
return Result.OK;
|
23
23
|
}
|
24
|
-
}
|
24
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
package com.amplify.honeydew_server.httpd;
|
2
|
+
|
3
|
+
import android.util.Log;
|
4
|
+
import com.amplify.honeydew_server.ActionsExecutor;
|
5
|
+
import com.amplify.honeydew_server.Command;
|
6
|
+
import com.amplify.honeydew_server.Result;
|
7
|
+
import com.google.gson.Gson;
|
8
|
+
import com.google.gson.reflect.TypeToken;
|
9
|
+
import fi.iki.elonen.NanoHTTPD;
|
10
|
+
|
11
|
+
import java.io.IOException;
|
12
|
+
import java.lang.reflect.Type;
|
13
|
+
import java.util.HashMap;
|
14
|
+
import java.util.Map;
|
15
|
+
|
16
|
+
public class RemoteCommandReceiver extends NanoHTTPD {
|
17
|
+
|
18
|
+
private static final String PLAIN_TEXT = "plain/text";
|
19
|
+
private final ActionsExecutor actionsExecutor;
|
20
|
+
|
21
|
+
private final Response statusOkResponse = new Response("honeydew-server is awaiting commands");
|
22
|
+
private final Response terminateOkResponse = new Response("honeydew-server is stopping");
|
23
|
+
private final Response badRequestResponse = new Response(Response.Status.BAD_REQUEST, PLAIN_TEXT, "Unsupported command");
|
24
|
+
|
25
|
+
private final Gson jsonParser = new Gson();
|
26
|
+
|
27
|
+
public RemoteCommandReceiver(ActionsExecutor actionsExecutor) throws IOException, InterruptedException {
|
28
|
+
super(7120);
|
29
|
+
this.actionsExecutor = actionsExecutor;
|
30
|
+
}
|
31
|
+
|
32
|
+
@Override
|
33
|
+
public Response serve(String uri, Method method, Map<String, String> headers, Map<String, String> params, Map<String, String> files) {
|
34
|
+
if (method == Method.POST && uri.equalsIgnoreCase("/terminate")) {
|
35
|
+
stop();
|
36
|
+
return terminateOkResponse;
|
37
|
+
} else if (method == Method.POST && uri.equalsIgnoreCase("/command")) {
|
38
|
+
return performCommand(params);
|
39
|
+
} else if (method == Method.GET && uri.equalsIgnoreCase("/status")) {
|
40
|
+
return statusOkResponse;
|
41
|
+
}
|
42
|
+
|
43
|
+
return badRequestResponse;
|
44
|
+
}
|
45
|
+
|
46
|
+
private Response performCommand(Map<String, String> params) {
|
47
|
+
String action = params.get("action");
|
48
|
+
String argumentJson = params.get("arguments");
|
49
|
+
Type argumentCollectionType = new TypeToken<Map<String, Object>>(){}.getType();
|
50
|
+
Map<String, Object> arguments = jsonParser.fromJson(argumentJson, argumentCollectionType);
|
51
|
+
|
52
|
+
Log.i(getClass().getName(), String.format("Performing action %s: %s for %s", action, argumentJson, params.toString()));
|
53
|
+
try {
|
54
|
+
Result result = actionsExecutor.execute(new Command(action, arguments));
|
55
|
+
if (result.success == true) {
|
56
|
+
return new Response(result.description);
|
57
|
+
} else {
|
58
|
+
// TODO: NanoHTTPD does not provide a particularly complete set of status codes, so use 416 for now
|
59
|
+
return new Response(Response.Status.RANGE_NOT_SATISFIABLE, PLAIN_TEXT, result.errorMessage);
|
60
|
+
}
|
61
|
+
} catch(Exception exception) {
|
62
|
+
Log.e(getClass().getName(), String.format("Server error while processing command %s: %s", action, exception.toString()));
|
63
|
+
return new Response(Response.Status.INTERNAL_ERROR, PLAIN_TEXT, exception.toString());
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
@@ -1,58 +1,37 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Honeydew::DeviceMatchers do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
let(:device) do
|
5
|
+
Class.new do
|
6
|
+
include Honeydew::DeviceMatchers
|
7
|
+
def perform_assertion; end
|
8
|
+
end.new
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
describe "#has_textview_text" do
|
13
|
-
let (:text) { "some text" }
|
14
|
-
|
15
|
-
it "should perform action for is_text_present" do
|
16
|
-
device.should_receive(:perform_action).with(hash_including({action: "is_text_present"}))
|
17
|
-
|
18
|
-
device.has_textview_text? text
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should retry for a default timeout" do
|
22
|
-
device.should_receive(:perform_action).with(hash_including({retry_until: Honeydew.config.timeout}))
|
23
|
-
|
24
|
-
device.has_textview_text? text
|
25
|
-
end
|
11
|
+
describe '#has_textview_text' do
|
12
|
+
let(:text) { 'some text' }
|
26
13
|
|
27
|
-
it
|
28
|
-
device.should_receive(:
|
14
|
+
it 'should perform action for is_text_present' do
|
15
|
+
device.should_receive(:perform_assertion)
|
16
|
+
.with(:is_text_present,
|
17
|
+
hash_including(text: text, type: 'TextView'),
|
18
|
+
timeout: nil)
|
29
19
|
|
30
20
|
device.has_textview_text? text
|
31
21
|
end
|
32
|
-
|
33
22
|
end
|
34
23
|
|
35
|
-
describe
|
36
|
-
let
|
37
|
-
let
|
38
|
-
|
39
|
-
it "should perform action for is_text_present" do
|
40
|
-
device.should_receive(:perform_action).with(hash_including({action: "is_text_present"}))
|
41
|
-
|
42
|
-
device.has_textview_with_text_and_description? text, description
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should retry for a default timeout" do
|
46
|
-
device.should_receive(:perform_action).with(hash_including({retry_until: Honeydew.config.timeout}))
|
24
|
+
describe '#has_textview_with_text_and_description' do
|
25
|
+
let(:text) { 'some text' }
|
26
|
+
let(:description) { 'some description' }
|
47
27
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
28
|
+
it 'performs the is_text_present action' do
|
29
|
+
device.should_receive(:perform_assertion)
|
30
|
+
.with(:is_text_present,
|
31
|
+
hash_including(text: text, type: 'TextView'),
|
32
|
+
timeout: nil)
|
53
33
|
|
54
34
|
device.has_textview_with_text_and_description? text, description
|
55
35
|
end
|
56
|
-
|
57
36
|
end
|
58
|
-
end
|
37
|
+
end
|
@@ -1,66 +1,68 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Honeydew::Device
|
4
|
-
let(:response) {
|
5
|
-
let(:
|
6
|
-
let(:
|
3
|
+
describe Honeydew::Device do
|
4
|
+
let(:response) { '{"success": true }' }
|
5
|
+
let(:device) { Honeydew::Device.new('ABC123DEF') }
|
6
|
+
let(:device_end_point) do
|
7
|
+
"http://127.0.0.1:#{device.port}"
|
8
|
+
end
|
7
9
|
|
8
10
|
before do
|
9
|
-
|
10
|
-
@device_end_point = "http://127.0.0.1:#{@device.port}"
|
11
|
-
RestClient.stub(:get).with(@device_end_point, params: { "command" => command}).and_return(response)
|
11
|
+
Net::HTTP.stub(:post_form).and_return(response)
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
15
|
-
let(:text) {
|
16
|
-
let(:command)
|
14
|
+
describe '#contains_textview_text?' do
|
15
|
+
let(:text) { 'Ok' }
|
16
|
+
let(:command) do
|
17
|
+
{'action' => 'is_text_present',
|
18
|
+
'arguments' => {'text' => text, 'type' => 'TextView'}}
|
19
|
+
end
|
17
20
|
|
18
|
-
it
|
19
|
-
|
20
|
-
|
21
|
+
it 'should make the call with command is_text_present' do
|
22
|
+
Net::HTTP.should_receive(:post_form).with(device_end_point, params: {'command' => command})
|
23
|
+
device.contains_textview_text?(text)
|
21
24
|
end
|
22
25
|
|
23
|
-
context
|
24
|
-
let(:response) {
|
26
|
+
context 'on successful response' do
|
27
|
+
let(:response) { '{ "success": true }' }
|
25
28
|
|
26
|
-
it
|
27
|
-
|
29
|
+
it 'should return true' do
|
30
|
+
device.contains_textview_text?(text).should be_true
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
31
|
-
context
|
32
|
-
let(:response) {
|
34
|
+
context 'on failure response' do
|
35
|
+
let(:response) { '{ "success": false }' }
|
33
36
|
|
34
|
-
it
|
35
|
-
|
37
|
+
it 'should return false' do
|
38
|
+
device.contains_textview_text?(text).should be_false
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
40
|
-
describe
|
41
|
-
let(:text) {
|
42
|
-
let(:command) { {
|
43
|
+
describe '#contains_button?' do
|
44
|
+
let(:text) { 'Ok' }
|
45
|
+
let(:command) { {'action' => 'is_button_present', 'arguments' => {'text' => text}} }
|
43
46
|
|
44
|
-
it
|
45
|
-
|
46
|
-
|
47
|
+
it 'should make the call with command is_button_present' do
|
48
|
+
Net::HTTP.should_receive(:post_form).with(device_end_point, params: {'command' => command})
|
49
|
+
device.contains_button?(text)
|
47
50
|
end
|
48
51
|
|
49
|
-
context
|
50
|
-
let(:response) {
|
52
|
+
context 'on successful response' do
|
53
|
+
let(:response) { '{ "success": true }' }
|
51
54
|
|
52
|
-
it
|
53
|
-
|
55
|
+
it 'should return true' do
|
56
|
+
device.contains_button?(text).should be_true
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
57
|
-
context
|
58
|
-
let(:response) {
|
60
|
+
context 'on failure response' do
|
61
|
+
let(:response) { '{ "success": false }' }
|
59
62
|
|
60
|
-
it
|
61
|
-
|
63
|
+
it 'should return false' do
|
64
|
+
device.contains_button?(text).should be_false
|
62
65
|
end
|
63
66
|
end
|
64
67
|
end
|
65
|
-
|
66
68
|
end
|