calabash-android 0.5.14 → 0.5.15.coordinate.pre.fix

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96c1911188f20f232889ba00d5e2123b3d9b2bc8
4
- data.tar.gz: dd293371094b4de6770ad1379e3bd43b2660f6a9
3
+ metadata.gz: ccea210d2ad8b6c0f74fc6a19f2596c2f4806efa
4
+ data.tar.gz: 37384b7ac67c4d363980c2290b612a5a955f24d3
5
5
  SHA512:
6
- metadata.gz: dbeebcbeb4ba2938adb07f4678e2eca1854d23af8f60d3088a31cb3ccf54e4d3bd13d06c128b4075dc54711ad26ad7f9190ff4a9a304ac38fd6497e302b85e2a
7
- data.tar.gz: 0cd1b8f01157537924397b90a21ca535a96fe93b7bbb22ff808606cc2d479478b71473d4d760afdb79607d9c27959b9cfe6f01d8103601adf58dd9eb8ad44d17
6
+ metadata.gz: bea9402d6ebfe5b51ba1c47c883db71ea93f69bfb83f64f9959490882c6518be3267e87bfbd1dfeff5a0591dd7c7769a31823f754fa37a463b166a2807269165
7
+ data.tar.gz: 4c82de1321c2abac41fef6ff4618df501112bf9bd30eb578a93687ef532d6d800e846e23679e073cc80d98daa4fb741c68fbd764b061d2cc449a54bb4212da3f
data/CHANGES.txt CHANGED
@@ -1,3 +1,7 @@
1
+ 0.5.13
2
+ Do not depend on any specific version of Cucumber
3
+ Grant all permissions when installing an app on M
4
+
1
5
  0.5.12
2
6
  Fix Calabash WebView queries not working for new Android
3
7
  System WebViews in Lollipop and M.
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.executables = "calabash-android"
16
16
  s.require_paths = ["lib"]
17
17
 
18
- s.add_dependency( "cucumber", '~> 1.3.17' )
18
+ s.add_dependency( "cucumber" )
19
19
  s.add_dependency( "json", '~> 1.8' )
20
20
  s.add_dependency( 'retriable', '>= 1.3.3.1', '< 1.5')
21
21
  s.add_dependency( "slowhandcuke", '~> 0.0.3')
@@ -0,0 +1,45 @@
1
+ require 'calabash-android/env'
2
+ require 'calabash-android/monkey_helpers'
3
+
4
+ module Calabash
5
+ module Android
6
+ module DragHelpers
7
+ include Calabash::Android::EnvironmentHelpers
8
+ include Calabash::Android::MonkeyHelpers
9
+
10
+ def drag_coordinates(from_x, from_y, to_x, to_y, steps=10, hold_time=0.5, hang_time=0.5)
11
+ log "Dragging from #{from_x},#{from_y} to #{to_x},#{to_y}"
12
+ monkey_move_from(from_x, from_y,
13
+ to_x, to_y,
14
+ hold_time: hold_time,
15
+ hang_time: hang_time,
16
+ steps: steps)
17
+ end
18
+
19
+ def drag_and_drop(from_query, to_query, steps=10, hold_time=0.5, hang_time=0.5)
20
+ wait_for_element_exists(from_query)
21
+ wait_for_element_exists(to_query)
22
+
23
+ from_results = query(from_query)
24
+ to_results = query(to_query)
25
+
26
+ if from_results.any?
27
+ if to_results.any?
28
+ from_rect = from_results.first['rect']
29
+ to_rect = to_results.first['rect']
30
+ from_x = from_rect['center_x']
31
+ from_y = from_rect['center_y']
32
+ to_x = to_rect['center_x']
33
+ to_y = to_rect['center_y']
34
+
35
+ monkey_move_from(from_x, from_y, to_x, to_y, hold_time: hold_time, hang_time: hang_time, steps: steps)
36
+ else
37
+ raise "No matching elements for: #{to_query}"
38
+ end
39
+ else
40
+ raise "No matching elements for: #{from_query}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,125 @@
1
+ require 'calabash-android/env'
2
+
3
+ module Calabash
4
+ module Android
5
+ module MonkeyHelpers
6
+ include Calabash::Android::EnvironmentHelpers
7
+
8
+ MAX_RETRIES = 10
9
+ @@monkey_port = nil
10
+ @@monkey_pid = nil
11
+
12
+ def monkey_move_from(from_x, from_y, to_x, to_y, args={})
13
+ start_monkey
14
+ monkey_touch(:down, from_x, from_y)
15
+ sleep(args.fetch(:hold_time))
16
+
17
+ x_delta = to_x - from_x
18
+ y_delta = to_y - from_y
19
+ steps = args.fetch(:steps)
20
+
21
+ steps.times do |i|
22
+ move_x = (from_x + ((i+1) * (x_delta.to_f / steps))).to_i
23
+ move_y = (from_y + ((i+1) * (y_delta.to_f / steps))).to_i
24
+ monkey_touch(:move, move_x, move_y)
25
+ end
26
+
27
+ sleep(args.fetch(:hang_time))
28
+ monkey_touch(:up, to_x, to_y)
29
+ end
30
+
31
+ def get_monkey_port
32
+ MAX_RETRIES.times do
33
+ port = rand((1024..65535))
34
+ monkey_starter_thread = Thread.new do
35
+ Thread.current[:output]= `#{adb_command} shell monkey --port #{port}`
36
+ end
37
+ sleep(4)
38
+
39
+ output = monkey_starter_thread[:output]
40
+ unless output && output.include?('Error binding to network socket.')
41
+ return port
42
+ end
43
+ end
44
+ raise 'Unable to start monkey on device'
45
+ end
46
+
47
+ def start_monkey
48
+ kill_existing_monkey_processes
49
+ @@monkey_port = get_monkey_port
50
+ monkey_timeout = 10
51
+
52
+ options = {
53
+ :timeout => monkey_timeout,
54
+ :timeout_message => "Monkey did not start on #{@@monkey_port} in #{monkey_timeout} seconds"
55
+ }
56
+
57
+ wait_for(options) {
58
+ perform_action('send_tcp', @@monkey_port, 'sleep 0', true)
59
+ }
60
+ end
61
+
62
+ def existing_monkey_pids
63
+ procs = `#{adb_command} shell ps`
64
+ procs.scan(/.+?\s(?<pid>[0-9]+).+?com.android.commands.monkey\r?\n?/).flatten
65
+ end
66
+
67
+ def kill_monkey_processes_on_device
68
+ existing_monkey_pids.each do |pid|
69
+ `#{adb_command} shell kill -9 #{pid}`
70
+ end
71
+ end
72
+
73
+ def kill_monkey_processes_on_host
74
+ unless xamarin_test_cloud?
75
+ monkey_args = "#{adb_command} shell monkey --port"
76
+ if Env.is_windows?
77
+ processes = `WMIC PATH win32_process GET Commandline, processid /FORMAT:CSV`.split(/\r?\n/).flatten
78
+ processes.each do |process|
79
+ components = process.split(',')
80
+ if components.length > 2 && components[1].index(monkey_args) == 0
81
+ `kill -9 #{components[2]}`
82
+ end
83
+ end
84
+ else
85
+ processes = `ps -xww -o pid,user,args`.split("\n").flatten
86
+ processes.each do |process|
87
+ if process.index(monkey_args) == 0
88
+ pid = process.strip().split(' ')[0].to_i
89
+ `kill -9 #{pid}`
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+ def kill_existing_monkey_processes
97
+ kill_monkey_processes_on_host
98
+ kill_monkey_processes_on_device
99
+ end
100
+
101
+ def monkey_tap(x, y, should_start_monkey=true)
102
+ start_monkey if should_start_monkey
103
+ monkey_touch(:down, x, y)
104
+ monkey_touch(:up, x, y)
105
+ end
106
+
107
+ def monkey_touch(touch_type, x, y)
108
+ case touch_type
109
+ when :move
110
+ perform_action('send_tcp', @@monkey_port, "touch move #{x} #{y}", true)
111
+ when :down
112
+ perform_action('send_tcp', @@monkey_port, "touch down #{x} #{y}", true)
113
+ when :up
114
+ perform_action('send_tcp', @@monkey_port, "touch up #{x} #{y}", true)
115
+ else
116
+ raise "touch_type #{touch_type} is invalid"
117
+ end
118
+ end
119
+
120
+ def adb_command
121
+ default_device.adb_command
122
+ end
123
+ end
124
+ end
125
+ end
@@ -11,6 +11,7 @@ require 'calabash-android/helpers'
11
11
  require 'calabash-android/environment_helpers'
12
12
  require 'calabash-android/text_helpers'
13
13
  require 'calabash-android/touch_helpers'
14
+ require 'calabash-android/drag_helpers'
14
15
  require 'calabash-android/wait_helpers'
15
16
  require 'calabash-android/version'
16
17
  require 'calabash-android/env'
@@ -27,6 +28,7 @@ module Calabash module Android
27
28
  include Calabash::Android::TextHelpers
28
29
  include Calabash::Android::TouchHelpers
29
30
  include Calabash::Android::WaitHelpers
31
+ include Calabash::Android::DragHelpers
30
32
 
31
33
  def self.extended(base)
32
34
  if (class << base; included_modules.map(&:to_s).include?('Cucumber::RbSupport::RbWorld'); end)
@@ -289,6 +291,10 @@ module Calabash module Android
289
291
  log `#{forward_cmd}`
290
292
  end
291
293
 
294
+ def _sdk_version
295
+ `#{adb_command} shell getprop ro.build.version.sdk`.to_i
296
+ end
297
+
292
298
  def reinstall_apps
293
299
  uninstall_app(package_name(@app_path))
294
300
  uninstall_app(package_name(@test_server_path))
@@ -302,7 +308,12 @@ module Calabash module Android
302
308
  end
303
309
 
304
310
  def install_app(app_path)
305
- cmd = "#{adb_command} install \"#{app_path}\""
311
+ if _sdk_version >= 23
312
+ cmd = "#{adb_command} install -g \"#{app_path}\""
313
+ else
314
+ cmd = "#{adb_command} install \"#{app_path}\""
315
+ end
316
+
306
317
  log "Installing: #{app_path}"
307
318
  result = `#{cmd}`
308
319
  log result
@@ -316,7 +327,12 @@ module Calabash module Android
316
327
  end
317
328
 
318
329
  def update_app(app_path)
319
- cmd = "#{adb_command} install -r \"#{app_path}\""
330
+ if _sdk_version >= 23
331
+ cmd = "#{adb_command} install -rg \"#{app_path}\""
332
+ else
333
+ cmd = "#{adb_command} install -r \"#{app_path}\""
334
+ end
335
+
320
336
  log "Updating: #{app_path}"
321
337
  result = `#{cmd}`
322
338
  log "result: #{result}"
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.5.14"
3
+ VERSION = "0.5.15.coordinate-fix"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,179 +1,179 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.14
4
+ version: 0.5.15.coordinate.pre.fix
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Maturana Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-04 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.17
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.17
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: retriable
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.3.3.1
48
- - - <
48
+ - - "<"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '1.5'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: 1.3.3.1
58
- - - <
58
+ - - "<"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.5'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: slowhandcuke
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: 0.0.3
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ~>
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: 0.0.3
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rubyzip
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ~>
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
81
  version: '1.1'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ~>
86
+ - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '1.1'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: awesome_print
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ~>
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '1.2'
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - ~>
100
+ - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '1.2'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: httpclient
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: 2.3.2
110
- - - <
110
+ - - "<"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '3.0'
113
113
  type: :runtime
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - '>='
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: 2.3.2
120
- - - <
120
+ - - "<"
121
121
  - !ruby/object:Gem::Version
122
122
  version: '3.0'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: escape
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ~>
127
+ - - "~>"
128
128
  - !ruby/object:Gem::Version
129
129
  version: 0.0.4
130
130
  type: :runtime
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ~>
134
+ - - "~>"
135
135
  - !ruby/object:Gem::Version
136
136
  version: 0.0.4
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: rake
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - ~>
141
+ - - "~>"
142
142
  - !ruby/object:Gem::Version
143
143
  version: '10.3'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
- - - ~>
148
+ - - "~>"
149
149
  - !ruby/object:Gem::Version
150
150
  version: '10.3'
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: yard
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - ~>
155
+ - - "~>"
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0.8'
158
158
  type: :development
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
- - - ~>
162
+ - - "~>"
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0.8'
165
165
  - !ruby/object:Gem::Dependency
166
166
  name: redcarpet
167
167
  requirement: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - ~>
169
+ - - "~>"
170
170
  - !ruby/object:Gem::Version
171
171
  version: '3.1'
172
172
  type: :development
173
173
  prerelease: false
174
174
  version_requirements: !ruby/object:Gem::Requirement
175
175
  requirements:
176
- - - ~>
176
+ - - "~>"
177
177
  - !ruby/object:Gem::Version
178
178
  version: '3.1'
179
179
  description: 'calabash-android drives tests for native and hybrid Android apps. '
@@ -184,8 +184,8 @@ executables:
184
184
  extensions: []
185
185
  extra_rdoc_files: []
186
186
  files:
187
- - .calabash_settings
188
- - .yardopts
187
+ - ".calabash_settings"
188
+ - ".yardopts"
189
189
  - CHANGES.txt
190
190
  - ENVIRONMENT_VARIABLES.md
191
191
  - Gemfile
@@ -216,16 +216,19 @@ files:
216
216
  - lib/calabash-android/cucumber.rb
217
217
  - lib/calabash-android/defaults.rb
218
218
  - lib/calabash-android/deprecated_actions.map
219
+ - lib/calabash-android/drag_helpers.rb
219
220
  - lib/calabash-android/env.rb
220
221
  - lib/calabash-android/environment_helpers.rb
221
222
  - lib/calabash-android/gestures.rb
222
223
  - lib/calabash-android/helpers.rb
223
224
  - lib/calabash-android/java_keystore.rb
224
225
  - lib/calabash-android/lib/AXMLPrinter2.jar
226
+ - lib/calabash-android/lib/TestServer.apk
225
227
  - lib/calabash-android/lib/manifest_extractor.jar
226
228
  - lib/calabash-android/lib/screenshotTaker.jar
227
229
  - lib/calabash-android/management/adb.rb
228
230
  - lib/calabash-android/management/app_installation.rb
231
+ - lib/calabash-android/monkey_helpers.rb
229
232
  - lib/calabash-android/operations.rb
230
233
  - lib/calabash-android/removed_actions.txt
231
234
  - lib/calabash-android/steps/assert_steps.rb
@@ -250,7 +253,6 @@ files:
250
253
  - test-server/AndroidManifest.xml
251
254
  - test-server/build.xml
252
255
  - test-server/calabash-js/src/calabash.js
253
- - lib/calabash-android/lib/TestServer.apk
254
256
  homepage: http://github.com/calabash
255
257
  licenses: []
256
258
  metadata: {}
@@ -260,17 +262,17 @@ require_paths:
260
262
  - lib
261
263
  required_ruby_version: !ruby/object:Gem::Requirement
262
264
  requirements:
263
- - - '>='
265
+ - - ">="
264
266
  - !ruby/object:Gem::Version
265
267
  version: '0'
266
268
  required_rubygems_version: !ruby/object:Gem::Requirement
267
269
  requirements:
268
- - - '>='
270
+ - - ">"
269
271
  - !ruby/object:Gem::Version
270
- version: '0'
272
+ version: 1.3.1
271
273
  requirements: []
272
274
  rubyforge_project:
273
- rubygems_version: 2.0.2
275
+ rubygems_version: 2.4.5.1
274
276
  signing_key:
275
277
  specification_version: 4
276
278
  summary: Client for calabash-android for automated functional testing on Android