honeydew 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. data/.gitignore +21 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +17 -0
  7. data/android-server/.gitignore +4 -0
  8. data/android-server/pom.xml +215 -0
  9. data/android-server/repo/com/google/android/uiautomator/4.1.1.4/_maven.repositories +4 -0
  10. data/android-server/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.jar +0 -0
  11. data/android-server/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.pom +9 -0
  12. data/android-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
  13. data/android-server/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.pom +56 -0
  14. data/android-server/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/maven-metadata-local.xml +24 -0
  15. data/android-server/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/_maven.repositories +4 -0
  16. data/android-server/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.jar +0 -0
  17. data/android-server/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.pom +9 -0
  18. data/android-server/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/maven-metadata-local.xml +24 -0
  19. data/android-server/repo/commons-jxpath/commons-jxpath/maven-metadata-local.xml +11 -0
  20. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/Action.java +65 -0
  21. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/ActionsExecutor.java +73 -0
  22. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/Command.java +16 -0
  23. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/Result.java +36 -0
  24. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/TestRunner.java +26 -0
  25. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/Click.java +20 -0
  26. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/ClickAndWaitForNewWindow.java +20 -0
  27. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/DumpWindowHierarchy.java +28 -0
  28. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/HasSettingsMenuItem.java +23 -0
  29. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/InspectOptionInSettingsMenu.java +32 -0
  30. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsButtonPresent.java +23 -0
  31. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsChildCountEqualTo.java +26 -0
  32. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsElementWithNestedTextPresent.java +24 -0
  33. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsOptionInSettingsMenuDisabled.java +9 -0
  34. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsOptionInSettingsMenuEnabled.java +9 -0
  35. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsTextPresent.java +19 -0
  36. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/LaunchApp.java +25 -0
  37. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/LaunchHome.java +19 -0
  38. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/LongClick.java +20 -0
  39. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/PressBack.java +19 -0
  40. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/PressEnter.java +19 -0
  41. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SelectFromAppsList.java +24 -0
  42. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SelectMenuInSettings.java +22 -0
  43. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SetText.java +27 -0
  44. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SetTextByIndex.java +25 -0
  45. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SetTextByLabel.java +28 -0
  46. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/Unlock.java +31 -0
  47. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/WakeUp.java +24 -0
  48. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/httpd/NanoHTTPD.java +1100 -0
  49. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/httpd/RemoteCommandReceiver.java +64 -0
  50. data/example/Gemfile +5 -0
  51. data/example/Rakefile +9 -0
  52. data/example/features/example.feature +10 -0
  53. data/example/features/step_definitions/honeydew_steps.rb +1 -0
  54. data/example/features/support/hooks.rb +4 -0
  55. data/honeydew.gemspec +28 -0
  56. data/honeydew.iml +28 -0
  57. data/lib/honeydew/cucumber.rb +4 -0
  58. data/lib/honeydew/device.rb +79 -0
  59. data/lib/honeydew/device_actions.rb +151 -0
  60. data/lib/honeydew/device_commands.rb +84 -0
  61. data/lib/honeydew/device_matchers.rb +52 -0
  62. data/lib/honeydew/dsl.rb +9 -0
  63. data/lib/honeydew/hooks.rb +0 -0
  64. data/lib/honeydew/step_definitions.rb +75 -0
  65. data/lib/honeydew/version.rb +3 -0
  66. data/lib/honeydew.rb +72 -0
  67. data/lib/tasks/honeydew.rake +7 -0
  68. data/spec/honeydew/device_matchers_spec.rb +58 -0
  69. data/spec/honeydew/device_spec.rb +66 -0
  70. data/spec/spec_helper.rb +39 -0
  71. data/todo.md +9 -0
  72. metadata +232 -0
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ bin
19
+ output
20
+ .idea
21
+ log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in honeydew.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Selva
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Honeydew
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'honeydew'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install honeydew
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ desc "build android server"
9
+ task :build_android_server do
10
+ system "cd #{android_server_path} && mvn clean package"
11
+ end
12
+
13
+ def android_server_path
14
+ File.absolute_path(File.join(File.dirname(__FILE__), 'android-server'))
15
+ end
16
+
17
+ task :build => [:spec, :build_android_server]
@@ -0,0 +1,4 @@
1
+ target
2
+ *.iml
3
+ .idea
4
+ *.class
@@ -0,0 +1,215 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
+ <modelVersion>4.0.0</modelVersion>
5
+
6
+ <groupId>uiautomator-cucumber</groupId>
7
+ <artifactId>android-server</artifactId>
8
+ <version>0.0.1-SNAPSHOT</version>
9
+ <packaging>jar</packaging>
10
+ <name>UIAutomator Cucumber - Android Server</name>
11
+
12
+ <properties>
13
+ <platform.version>4.1.1.4</platform.version>
14
+ </properties>
15
+
16
+ <repositories>
17
+ <repository>
18
+ <id>local-repository</id>
19
+ <name>Local Checked in Repo</name>
20
+ <url>file://${project.basedir}/repo</url>
21
+ </repository>
22
+ </repositories>
23
+
24
+ <pluginRepositories>
25
+ <pluginRepository>
26
+ <id>local-repository</id>
27
+ <name>Local Checked in Repo</name>
28
+ <url>file://${project.basedir}/repo</url>
29
+ </pluginRepository>
30
+ </pluginRepositories>
31
+
32
+ <dependencies>
33
+ <dependency>
34
+ <groupId>com.google.android</groupId>
35
+ <artifactId>android</artifactId>
36
+ <version>${platform.version}</version>
37
+ <scope>provided</scope>
38
+ </dependency>
39
+ <dependency>
40
+ <groupId>com.google.android</groupId>
41
+ <artifactId>uiautomator</artifactId>
42
+ <version>${platform.version}</version>
43
+ <scope>provided</scope>
44
+ </dependency>
45
+ <dependency>
46
+ <groupId>junit</groupId>
47
+ <artifactId>junit</artifactId>
48
+ <version>4.10</version>
49
+ <scope>provided</scope>
50
+ </dependency>
51
+ <dependency>
52
+ <groupId>com.google.code.gson</groupId>
53
+ <artifactId>gson</artifactId>
54
+ <version>2.2.2</version>
55
+ </dependency>
56
+ <dependency>
57
+ <groupId>com.google.guava</groupId>
58
+ <artifactId>guava</artifactId>
59
+ <version>14.0</version>
60
+ </dependency>
61
+ <dependency>
62
+ <groupId>commons-lang</groupId>
63
+ <artifactId>commons-lang</artifactId>
64
+ <version>2.6</version>
65
+ </dependency>
66
+ <dependency>
67
+ <groupId>commons-io</groupId>
68
+ <artifactId>commons-io</artifactId>
69
+ <version>2.4</version>
70
+ </dependency>
71
+ </dependencies>
72
+
73
+ <build>
74
+ <testSourceDirectory>${test.directory}</testSourceDirectory>
75
+ <plugins>
76
+ <plugin>
77
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
78
+ <artifactId>android-maven-plugin</artifactId>
79
+ <version>3.5.3</version>
80
+ <configuration>
81
+ <zipalign>
82
+ <verbose>true</verbose>
83
+ </zipalign>
84
+ <undeployBeforeDeploy>true</undeployBeforeDeploy>
85
+ <sdk>
86
+ <platform>16</platform>
87
+ </sdk>
88
+ <lint>
89
+ <skip>true</skip>
90
+ </lint>
91
+ <push>
92
+ <source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
93
+ <destination>/data/local/tmp/</destination>
94
+ </push>
95
+ <attachJar>false</attachJar>
96
+ <dex>
97
+ </dex>
98
+ <test>
99
+ <createReport>true</createReport>
100
+ </test>
101
+ <proguard>
102
+ <skip>true</skip>
103
+ </proguard>
104
+ <uiautomator>
105
+ <skip>false</skip>
106
+ <testClassOrMethods>
107
+ <testClassOrMethod>
108
+ com.uiautomator_cucumber.android_server.TestRunner
109
+ </testClassOrMethod>
110
+ </testClassOrMethods>
111
+ <createReport>true</createReport>
112
+ </uiautomator>
113
+ </configuration>
114
+ <executions>
115
+ <execution>
116
+ <id>install-jar-to-device</id>
117
+ <phase>install</phase>
118
+ <goals>
119
+ <goal>push</goal>
120
+ </goals>
121
+ </execution>
122
+ <execution>
123
+ <id>dex-classes</id>
124
+ <phase>prepare-package</phase>
125
+ <goals>
126
+ <goal>dex</goal>
127
+ </goals>
128
+ </execution>
129
+ <execution>
130
+ <id>ui-test</id>
131
+ <phase>install</phase>
132
+ <goals>
133
+ <goal>uiautomator</goal>
134
+ </goals>
135
+ </execution>
136
+ </executions>
137
+ </plugin>
138
+
139
+ <plugin>
140
+ <artifactId>maven-compiler-plugin</artifactId>
141
+ <version>3.0</version>
142
+ </plugin>
143
+
144
+ <plugin>
145
+ <artifactId>maven-jar-plugin</artifactId>
146
+ <version>2.4</version>
147
+ <configuration>
148
+ <classesDirectory>${project.build.directory}/</classesDirectory>
149
+ <includes>
150
+ <include>classes.dex</include>
151
+ </includes>
152
+ </configuration>
153
+ </plugin>
154
+
155
+ <!-- Quality analysis tools -->
156
+ <plugin>
157
+ <groupId>org.apache.maven.plugins</groupId>
158
+ <artifactId>maven-checkstyle-plugin</artifactId>
159
+ <version>2.9.1</version>
160
+ </plugin>
161
+ <plugin>
162
+ <groupId>org.codehaus.mojo</groupId>
163
+ <artifactId>findbugs-maven-plugin</artifactId>
164
+ <version>2.5.2</version>
165
+ </plugin>
166
+ <plugin>
167
+ <groupId>org.apache.maven.plugins</groupId>
168
+ <artifactId>maven-pmd-plugin</artifactId>
169
+ <version>3.0.1</version>
170
+ </plugin>
171
+ <plugin>
172
+ <artifactId>maven-jarsigner-plugin</artifactId>
173
+ <version>1.2</version>
174
+ </plugin>
175
+ <plugin>
176
+ <artifactId>maven-resources-plugin</artifactId>
177
+ <version>2.5</version>
178
+ <configuration>
179
+ <encoding>UTF-8</encoding>
180
+ </configuration>
181
+ </plugin>
182
+ <plugin>
183
+ <groupId>org.codehaus.mojo</groupId>
184
+ <artifactId>build-helper-maven-plugin</artifactId>
185
+ <version>1.5</version>
186
+ </plugin>
187
+ <!--This plugin's configuration is used to store Eclipse m2e settings
188
+ only. It has no influence on the Maven build itself. -->
189
+ <plugin>
190
+ <groupId>org.eclipse.m2e</groupId>
191
+ <artifactId>lifecycle-mapping</artifactId>
192
+ <version>1.0.0</version>
193
+ <configuration>
194
+ <lifecycleMappingMetadata>
195
+ <pluginExecutions>
196
+ <pluginExecution>
197
+ <pluginExecutionFilter>
198
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
199
+ <artifactId>android-maven-plugin</artifactId>
200
+ <versionRange>[3.2.0,)</versionRange>
201
+ <goals>
202
+ <goal>manifest-update</goal>
203
+ </goals>
204
+ </pluginExecutionFilter>
205
+ <action>
206
+ <execute/>
207
+ </action>
208
+ </pluginExecution>
209
+ </pluginExecutions>
210
+ </lifecycleMappingMetadata>
211
+ </configuration>
212
+ </plugin>
213
+ </plugins>
214
+ </build>
215
+ </project>
@@ -0,0 +1,4 @@
1
+ #NOTE: This is an internal implementation file, its format can be changed without prior notice.
2
+ #Sat Mar 16 21:33:52 IST 2013
3
+ uiautomator-4.1.1.4.pom>=
4
+ uiautomator-4.1.1.4.jar>=
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
+ <modelVersion>4.0.0</modelVersion>
5
+ <groupId>com.google.android</groupId>
6
+ <artifactId>uiautomator</artifactId>
7
+ <version>4.1.1.4</version>
8
+ <description>POM was created from install:install-file</description>
9
+ </project>
@@ -0,0 +1,56 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
+ <modelVersion>4.0.0</modelVersion>
5
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
6
+ <artifactId>android-maven-plugin</artifactId>
7
+ <version>3.5.2-SNAPSHOT</version>
8
+ <description>POM was created from install:install-file</description>
9
+ <dependencies>
10
+ <dependency>
11
+ <groupId>commons-jxpath</groupId>
12
+ <artifactId>commons-jxpath</artifactId>
13
+ <version>1.4-SNAPSHOT</version>
14
+ </dependency>
15
+ <dependency>
16
+ <groupId>org.sonatype.sisu</groupId>
17
+ <artifactId>sisu-inject-plexus</artifactId>
18
+ <version>2.3.2</version>
19
+ </dependency>
20
+ <dependency>
21
+ <groupId>org.apache.maven</groupId>
22
+ <artifactId>maven-model</artifactId>
23
+ <version>3.0.5</version>
24
+ </dependency>
25
+ <dependency>
26
+ <groupId>org.apache.maven</groupId>
27
+ <artifactId>maven-artifact</artifactId>
28
+ <version>3.0.5</version>
29
+ </dependency>
30
+ <dependency>
31
+ <groupId>org.codehaus.plexus</groupId>
32
+ <artifactId>plexus-archiver</artifactId>
33
+ <version>2.3</version>
34
+ </dependency>
35
+ <dependency>
36
+ <groupId>com.android.ddmlib</groupId>
37
+ <artifactId>ddmlib</artifactId>
38
+ <version>r16</version>
39
+ </dependency>
40
+ <dependency>
41
+ <groupId>commons-lang</groupId>
42
+ <artifactId>commons-lang</artifactId>
43
+ <version>2.6</version>
44
+ </dependency>
45
+ <dependency>
46
+ <groupId>commons-io</groupId>
47
+ <artifactId>commons-io</artifactId>
48
+ <version>2.4</version>
49
+ </dependency>
50
+ <dependency>
51
+ <groupId>com.github.rtyley</groupId>
52
+ <artifactId>android-screenshot-paparazzo</artifactId>
53
+ <version>1.6</version>
54
+ </dependency>
55
+ </dependencies>
56
+ </project>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <metadata modelVersion="1.1.0">
3
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
4
+ <artifactId>android-maven-plugin</artifactId>
5
+ <version>3.5.2-SNAPSHOT</version>
6
+ <versioning>
7
+ <snapshot>
8
+ <localCopy>true</localCopy>
9
+ </snapshot>
10
+ <lastUpdated>20130316154827</lastUpdated>
11
+ <snapshotVersions>
12
+ <snapshotVersion>
13
+ <extension>jar</extension>
14
+ <value>3.5.2-SNAPSHOT</value>
15
+ <updated>20130316154827</updated>
16
+ </snapshotVersion>
17
+ <snapshotVersion>
18
+ <extension>pom</extension>
19
+ <value>3.5.2-SNAPSHOT</value>
20
+ <updated>20130316154827</updated>
21
+ </snapshotVersion>
22
+ </snapshotVersions>
23
+ </versioning>
24
+ </metadata>
@@ -0,0 +1,4 @@
1
+ #NOTE: This is an internal implementation file, its format can be changed without prior notice.
2
+ #Sat Mar 16 22:02:48 IST 2013
3
+ commons-jxpath-1.4-SNAPSHOT.jar>=
4
+ commons-jxpath-1.4-SNAPSHOT.pom>=
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
+ <modelVersion>4.0.0</modelVersion>
5
+ <groupId>commons-jxpath</groupId>
6
+ <artifactId>commons-jxpath</artifactId>
7
+ <version>1.4-SNAPSHOT</version>
8
+ <description>POM was created from install:install-file</description>
9
+ </project>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <metadata modelVersion="1.1.0">
3
+ <groupId>commons-jxpath</groupId>
4
+ <artifactId>commons-jxpath</artifactId>
5
+ <version>1.4-SNAPSHOT</version>
6
+ <versioning>
7
+ <snapshot>
8
+ <localCopy>true</localCopy>
9
+ </snapshot>
10
+ <lastUpdated>20130316163248</lastUpdated>
11
+ <snapshotVersions>
12
+ <snapshotVersion>
13
+ <extension>jar</extension>
14
+ <value>1.4-SNAPSHOT</value>
15
+ <updated>20130316163248</updated>
16
+ </snapshotVersion>
17
+ <snapshotVersion>
18
+ <extension>pom</extension>
19
+ <value>1.4-SNAPSHOT</value>
20
+ <updated>20130316163248</updated>
21
+ </snapshotVersion>
22
+ </snapshotVersions>
23
+ </versioning>
24
+ </metadata>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <metadata>
3
+ <groupId>commons-jxpath</groupId>
4
+ <artifactId>commons-jxpath</artifactId>
5
+ <versioning>
6
+ <versions>
7
+ <version>1.4-SNAPSHOT</version>
8
+ </versions>
9
+ <lastUpdated>20130316163248</lastUpdated>
10
+ </versioning>
11
+ </metadata>
@@ -0,0 +1,65 @@
1
+ package com.uiautomator_cucumber.android_server;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObject;
5
+ import com.android.uiautomator.core.UiObjectNotFoundException;
6
+ import com.android.uiautomator.core.UiSelector;
7
+ import com.google.common.base.CaseFormat;
8
+
9
+ import java.util.Map;
10
+
11
+ public abstract class Action {
12
+ protected final UiDevice uiDevice;
13
+
14
+ public Action(UiDevice uiDevice) {
15
+ this.uiDevice = uiDevice;
16
+ }
17
+
18
+ public abstract Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException;
19
+
20
+ public String name() {
21
+ return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, getClass().getSimpleName());
22
+ }
23
+
24
+ protected UiDevice getUiDevice() {
25
+ return uiDevice;
26
+ }
27
+
28
+ protected UiObject getUiObject(Map<String, Object> arguments) {
29
+ ViewSelector viewSelector = new ViewSelector();
30
+
31
+ if (arguments.containsKey("type")) {
32
+ viewSelector.withType((String) arguments.get("type"));
33
+ }
34
+ if (arguments.containsKey("text")) {
35
+ viewSelector.withText((String) arguments.get("text"));
36
+ }
37
+ if (arguments.containsKey("description")) {
38
+ viewSelector.withDescription((String) arguments.get("description"));
39
+ }
40
+ return viewSelector.find();
41
+ }
42
+
43
+ public static class ViewSelector {
44
+ private UiSelector uiSelector = new UiSelector();
45
+
46
+ public ViewSelector withType(String type) {
47
+ uiSelector = uiSelector.className("android.widget." + type);
48
+ return this;
49
+ }
50
+
51
+ public ViewSelector withText(String text) {
52
+ uiSelector = uiSelector.textContains(text);
53
+ return this;
54
+ }
55
+
56
+ public ViewSelector withDescription(String description) {
57
+ uiSelector = uiSelector.description(description);
58
+ return this;
59
+ }
60
+
61
+ public UiObject find() {
62
+ return new UiObject(uiSelector);
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,73 @@
1
+ package com.uiautomator_cucumber.android_server;
2
+
3
+ import android.util.Log;
4
+ import com.android.uiautomator.core.UiDevice;
5
+ import com.uiautomator_cucumber.android_server.actions.*;
6
+
7
+ import java.lang.reflect.Constructor;
8
+ import java.lang.reflect.InvocationTargetException;
9
+ import java.util.HashMap;
10
+ import java.util.Set;
11
+
12
+ import static com.google.common.collect.Sets.newHashSet;
13
+
14
+ public class ActionsExecutor {
15
+
16
+ private final UiDevice uiDevice;
17
+ private final HashMap<String, Action> actions;
18
+
19
+ public ActionsExecutor(UiDevice uiDevice) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
20
+ this.uiDevice = uiDevice;
21
+ actions = new HashMap();
22
+ for (Class<? extends Action> actionClass : allActionClasses()) {
23
+ Constructor<? extends Action> constructor = actionClass.getConstructor(UiDevice.class);
24
+ Action action = constructor.newInstance(getUiDevice());
25
+ Log.d(getClass().getName(), String.format("Registering action: %s", action.name()));
26
+ actions.put(action.name(), action);
27
+ }
28
+ }
29
+
30
+ public Result execute(Command command) {
31
+ String actionName = command.getAction();
32
+ try {
33
+ Action action = actions.get(actionName);
34
+ if (action == null) {
35
+ return new Result("Action: " + actionName + " does not exists");
36
+ }
37
+ return action.execute(command.getArguments());
38
+ } catch (Exception e) {
39
+ return new Result("Exception, on calling " + actionName, e);
40
+ }
41
+ }
42
+
43
+ private static Set<Class<? extends Action>> allActionClasses() {
44
+ Set<Class<? extends Action>> actionClasses = newHashSet();
45
+ actionClasses.add(LaunchApp.class);
46
+ actionClasses.add(LaunchHome.class);
47
+ actionClasses.add(PressBack.class);
48
+ actionClasses.add(PressEnter.class);
49
+ actionClasses.add(WakeUp.class);
50
+ actionClasses.add(IsTextPresent.class);
51
+ actionClasses.add(IsButtonPresent.class);
52
+ actionClasses.add(IsElementWithNestedTextPresent.class);
53
+ actionClasses.add(IsChildCountEqualTo.class);
54
+ actionClasses.add(Click.class);
55
+ actionClasses.add(ClickAndWaitForNewWindow.class);
56
+ actionClasses.add(LongClick.class);
57
+ actionClasses.add(SetText.class);
58
+ actionClasses.add(SetTextByLabel.class);
59
+ actionClasses.add(SetTextByIndex.class);
60
+ actionClasses.add(DumpWindowHierarchy.class);
61
+ actionClasses.add(SelectMenuInSettings.class);
62
+ actionClasses.add(IsOptionInSettingsMenuEnabled.class);
63
+ actionClasses.add(IsOptionInSettingsMenuDisabled.class);
64
+ actionClasses.add(HasSettingsMenuItem.class);
65
+ actionClasses.add(SelectFromAppsList.class);
66
+ actionClasses.add(Unlock.class);
67
+ return actionClasses;
68
+ }
69
+
70
+ private UiDevice getUiDevice() {
71
+ return uiDevice;
72
+ }
73
+ }
@@ -0,0 +1,16 @@
1
+ package com.uiautomator_cucumber.android_server;
2
+
3
+ import java.util.Map;
4
+
5
+ public class Command {
6
+ private String action;
7
+ private Map<String, Object> arguments;
8
+
9
+ public String getAction() {
10
+ return action;
11
+ }
12
+
13
+ public Map<String, Object> getArguments() {
14
+ return arguments;
15
+ }
16
+ }