acouchi 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +33 -31
- data/examples/AcouchiSample/AndroidManifest.xml +1 -1
- data/examples/AcouchiSample/Rakefile +1 -29
- data/lib/acouchi/rake/tasks.rb +37 -0
- data/lib/acouchi/solo.rb +3 -0
- data/lib/acouchi/version.rb +1 -1
- data/src/com/acouchi/Acouchi.java +2 -0
- data/src/com/acouchi/MethodExecutor.java +1 -0
- metadata +3 -2
data/README.md
CHANGED
@@ -33,49 +33,51 @@ Cucumber
|
|
33
33
|
|
34
34
|
### PROJECT_ROOT/features/support/env.rb
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
```ruby
|
37
|
+
require "acouchi"
|
38
|
+
require "acouchi/cucumber"
|
39
|
+
require "acouchi/rspec/matchers"
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
|
42
|
+
configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
|
43
|
+
configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
|
43
44
|
|
44
|
-
|
45
|
+
Acouchi::Cucumber.prepare(configuration)
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
def page
|
48
|
+
Acouchi::Cucumber.page
|
49
|
+
end
|
50
|
+
```
|
49
51
|
|
50
52
|
### PROJECT_ROOT/acouchi_configuration.json
|
51
53
|
|
54
|
+
```ruby
|
52
55
|
{
|
53
56
|
"target_package": "com.acouchi.sample",
|
54
57
|
"activity" : "com.acouchi.sample.StartupActivity",
|
55
58
|
"project_path" : ".",
|
56
59
|
"apk" : "AcouchiSample-debug.apk"
|
57
60
|
}
|
61
|
+
```
|
58
62
|
|
59
63
|
### PROJECT_ROOT/Rakefile
|
60
64
|
|
61
|
-
|
62
|
-
require "
|
63
|
-
|
65
|
+
```ruby
|
66
|
+
require "acouchi/rake/tasks
|
67
|
+
```
|
64
68
|
|
65
|
-
|
66
|
-
|
67
|
-
configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
|
68
|
-
Acouchi::ProjectBuilder.new(configuration).build
|
69
|
-
end
|
69
|
+
Running the tests
|
70
|
+
-----------------
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
```
|
73
|
+
rake build #only if you modify the application code
|
74
|
+
cucumber
|
75
|
+
```
|
74
76
|
|
75
77
|
Pressing Keys
|
76
78
|
-------------
|
77
79
|
|
78
|
-
```
|
80
|
+
```ruby
|
79
81
|
page.send_key Acouchi::Solo::MENU
|
80
82
|
page.send_key Acouchi::Solo::LEFT
|
81
83
|
page.send_key Acouchi::Solo::RIGHT
|
@@ -84,7 +86,7 @@ page.send_key Acouchi::Solo::RIGHT
|
|
84
86
|
Modifying Text
|
85
87
|
--------------
|
86
88
|
|
87
|
-
```
|
89
|
+
```ruby
|
88
90
|
# Enter text into the only text area on the page
|
89
91
|
page.enter_text "Hello"
|
90
92
|
|
@@ -101,7 +103,7 @@ page.clear_text 4
|
|
101
103
|
Searching Text
|
102
104
|
--------------
|
103
105
|
|
104
|
-
```
|
106
|
+
```ruby
|
105
107
|
# Check if page has_text
|
106
108
|
page.has_text? "Bla"
|
107
109
|
|
@@ -123,7 +125,7 @@ page.all_content
|
|
123
125
|
Clicking Things
|
124
126
|
---------------
|
125
127
|
|
126
|
-
```
|
128
|
+
```ruby
|
127
129
|
# Check if button with text exists
|
128
130
|
page.has_button? "Clicky"
|
129
131
|
|
@@ -146,7 +148,7 @@ page.click_image 5
|
|
146
148
|
Finding Views
|
147
149
|
-------------
|
148
150
|
|
149
|
-
```
|
151
|
+
```ruby
|
150
152
|
# List the buttons currently on the page
|
151
153
|
page.buttons
|
152
154
|
|
@@ -157,7 +159,7 @@ page.text_views
|
|
157
159
|
Scrolling
|
158
160
|
---------
|
159
161
|
|
160
|
-
```
|
162
|
+
```ruby
|
161
163
|
page.scroll_up
|
162
164
|
page.scroll_down
|
163
165
|
|
@@ -177,7 +179,7 @@ page.scroll_to_right
|
|
177
179
|
Navigating
|
178
180
|
----------
|
179
181
|
|
180
|
-
```
|
182
|
+
```ruby
|
181
183
|
# Press the back button
|
182
184
|
page.go_back
|
183
185
|
```
|
@@ -187,7 +189,7 @@ Waiting
|
|
187
189
|
|
188
190
|
Most methods in acouchi will wait for a while until an element is available.
|
189
191
|
|
190
|
-
```
|
192
|
+
```ruby
|
191
193
|
# Wait for the text "Bla Bla" to appear. Returns true if the text appears.
|
192
194
|
page.wait_for_text "Bla Bla"
|
193
195
|
|
@@ -207,7 +209,7 @@ page.wait_for_text "Bla Bla", {
|
|
207
209
|
RSpec
|
208
210
|
-----
|
209
211
|
|
210
|
-
```
|
212
|
+
```ruby
|
211
213
|
require "acouchi/rspec/matchers"
|
212
214
|
|
213
215
|
# The have_text matcher will now output all page content
|
@@ -222,7 +224,7 @@ Troubleshooting
|
|
222
224
|
|
223
225
|
If it seems that buttons/text aren't being clicked properly, you need to add the following xml to your AndroidManifest.xml:
|
224
226
|
|
225
|
-
```
|
227
|
+
```xml
|
226
228
|
<uses-sdk android:targetSdkVersion="SDK_VERSION" />
|
227
229
|
```
|
228
230
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
android:versionCode="1"
|
5
5
|
android:versionName="1.0">
|
6
6
|
|
7
|
-
<uses-sdk android:targetSdkVersion="
|
7
|
+
<uses-sdk android:targetSdkVersion="13" />
|
8
8
|
|
9
9
|
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
10
10
|
<activity android:name="StartupActivity"
|
@@ -1,29 +1 @@
|
|
1
|
-
require "
|
2
|
-
require "cucumber/rake/task"
|
3
|
-
require "acouchi"
|
4
|
-
require "acouchi/rspec/matchers"
|
5
|
-
|
6
|
-
desc "build project with Acouchi code included"
|
7
|
-
task :build do
|
8
|
-
configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
|
9
|
-
configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
|
10
|
-
configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
|
11
|
-
Acouchi::ProjectBuilder.new(configuration).build
|
12
|
-
end
|
13
|
-
|
14
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
15
|
-
t.cucumber_opts = "features --format pretty"
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "open up an acouchi console"
|
19
|
-
task :console do
|
20
|
-
configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
|
21
|
-
configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
|
22
|
-
configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
|
23
|
-
test_runner = Acouchi::TestRunner.new(configuration)
|
24
|
-
test_runner.start
|
25
|
-
page = Acouchi::Solo.new(configuration)
|
26
|
-
require "pry"
|
27
|
-
binding.pry
|
28
|
-
test_runner.stop
|
29
|
-
end
|
1
|
+
require "acouchi/rake/tasks"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "cucumber"
|
2
|
+
require "cucumber/rake/task"
|
3
|
+
require "acouchi"
|
4
|
+
require "acouchi/rspec/matchers"
|
5
|
+
|
6
|
+
desc "build project with Acouchi code included"
|
7
|
+
task :build do
|
8
|
+
configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
|
9
|
+
configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
|
10
|
+
configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
|
11
|
+
Acouchi::ProjectBuilder.new(configuration).build
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "farm"
|
15
|
+
task :farm do
|
16
|
+
port_range = (7004...10000).to_a
|
17
|
+
%x(adb devices).scan(/.*\tdevice/).map{|device|device.gsub! " device",""}.each do |device|
|
18
|
+
system "ACOUCHI_DEVICE=#{device} ACOUCHI_PORT=#{port_range.sample} rake features &"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "open up an acouchi console"
|
23
|
+
task :console do
|
24
|
+
configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
|
25
|
+
configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
|
26
|
+
configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
|
27
|
+
test_runner = Acouchi::TestRunner.new(configuration)
|
28
|
+
test_runner.start
|
29
|
+
page = Acouchi::Solo.new(configuration)
|
30
|
+
require "pry"
|
31
|
+
binding.pry
|
32
|
+
test_runner.stop
|
33
|
+
end
|
34
|
+
|
35
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
36
|
+
t.cucumber_opts = "features --format progress --format html --out=#{ENV["ACOUCHI_DEVICE"]}.html"
|
37
|
+
end
|
data/lib/acouchi/solo.rb
CHANGED
@@ -137,6 +137,9 @@ module Acouchi
|
|
137
137
|
options = { :body => {:parameters => arguments.to_json} }
|
138
138
|
response = HTTParty.post("http://127.0.0.1:#{@configuration.port}/execute_method/#{name}", options)
|
139
139
|
json = JSON.parse(response.body, :max_nesting => 100)
|
140
|
+
|
141
|
+
puts json
|
142
|
+
|
140
143
|
if json.empty?
|
141
144
|
nil
|
142
145
|
else
|
data/lib/acouchi/version.rb
CHANGED
@@ -10,6 +10,7 @@ import java.util.concurrent.locks.Condition;
|
|
10
10
|
import java.util.concurrent.locks.Lock;
|
11
11
|
import java.util.concurrent.locks.ReentrantLock;
|
12
12
|
|
13
|
+
import android.util.Log;
|
13
14
|
import com.google.gson.Gson;
|
14
15
|
|
15
16
|
import java.io.PrintWriter;
|
@@ -63,6 +64,7 @@ public class Acouchi extends NanoHTTPD
|
|
63
64
|
String methodName = uri.replace("/execute_method/", "");
|
64
65
|
String[] parameters = new Gson().fromJson(params.getProperty("parameters"), String[].class);
|
65
66
|
String jsonResult = new MethodExecutor(solo, methodName, parameters).Execute();
|
67
|
+
|
66
68
|
return new NanoHTTPD.Response(HTTP_OK, MIME_HTML, jsonResult);
|
67
69
|
} catch (Throwable throwable) {
|
68
70
|
return showException(throwable);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acouchi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/acouchi/executables.rb
|
116
116
|
- lib/acouchi/process_launcher.rb
|
117
117
|
- lib/acouchi/project_builder.rb
|
118
|
+
- lib/acouchi/rake/tasks.rb
|
118
119
|
- lib/acouchi/rspec/matchers.rb
|
119
120
|
- lib/acouchi/solo.rb
|
120
121
|
- lib/acouchi/test_runner.rb
|