calabash-android 0.5.16.pre1 → 0.6.0.prelatestcrosswalk

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,7 @@ module Calabash
12
12
  end
13
13
 
14
14
  def keyboard_enter_text(text, options = {})
15
+ wait_for_keyboard
15
16
  perform_action('keyboard_enter_text', text)
16
17
  end
17
18
 
@@ -19,36 +20,62 @@ module Calabash
19
20
  keyboard_enter_text(character[0,1], options)
20
21
  end
21
22
 
23
+ # Appends `text` into the first view matching `uiquery`.
22
24
  def enter_text(uiquery, text, options = {})
23
25
  tap_when_element_exists(uiquery, options)
24
26
  sleep 0.5
27
+ set_selection(-1, -1)
25
28
  keyboard_enter_text(text, options)
26
29
  end
27
30
 
28
31
  def clear_text_in(query_string, options={})
29
- unless query_string.nil?
30
- touch(query_string, options)
31
- sleep 0.5
32
- end
33
-
32
+ touch(query_string, options)
33
+ sleep 0.5
34
34
  clear_text(options)
35
35
  end
36
36
 
37
+ # Clears the text of the currently focused view.
37
38
  def clear_text(options={})
38
- if options.is_a?(String)
39
- puts "Warning: The method clear_text now clears the text in the currently focused view. Use clear_text_in instead"
40
- puts "Notice that clear_text_in only clears the text of the first element matching the given query, not all."
41
- puts "Use query(query, setText: '') to replicate the old behaviour"
39
+ set_selection(-1, -1)
40
+ perform_action("delete_surrounding_text", -1, 0)
41
+ end
42
+
43
+ def escape_quotes(str)
44
+ str.gsub("'", "\\\\'")
45
+ end
42
46
 
43
- clear_text_in(options)
47
+ # Sets the selection of the currently focused view.
48
+ #
49
+ # @param [Integer] selection_start The start of the selection, can be
50
+ # negative to begin counting from the end of the string.
51
+ # @param [Integer] selection_end The end of the selection, can be
52
+ # negative to begin counting from the end of the string.
53
+ def set_selection(selection_start, selection_end)
54
+ perform_action("set_selection", selection_start, selection_end)
55
+ end
56
+
57
+ def keyboard_visible?
58
+ input_method = `#{default_device.adb_command} shell dumpsys input_method`.force_encoding('UTF-8')
59
+ shown = input_method.each_line.grep(/mInputShown\s*=\s*(.*)/){$1}.first.chomp
60
+
61
+ if shown == "true"
62
+ true
63
+ elsif shown == "false"
64
+ false
44
65
  else
45
- perform_action('clear_text')
66
+ raise "Could not detect keyboard visibility. '#{shown}'"
46
67
  end
47
68
  end
48
69
 
49
- def escape_quotes(str)
50
- str.gsub("'", "\\\\'")
70
+ def wait_for_keyboard(opt={})
71
+ params = opt.clone
72
+ params[:timeout_message] ||= "Timed out waiting for the keyboard to appear"
73
+ params[:timeout] ||= 5
74
+
75
+ wait_for(params) do
76
+ keyboard_visible?
77
+ end
51
78
  end
52
79
  end
53
80
  end
54
- end
81
+ end
@@ -0,0 +1,192 @@
1
+ module Calabash
2
+ module Android
3
+ class UsageTracker
4
+
5
+ require "httpclient"
6
+
7
+ # @!visibility private
8
+ @@track_usage = true
9
+
10
+ # @!visibility private
11
+ def self.enable_usage_tracking
12
+ @@track_usage = true
13
+ end
14
+
15
+ # @!visibility private
16
+ def self.disable_usage_tracking
17
+ @@track_usage = false
18
+ end
19
+
20
+ # @!visibility private
21
+ def post_usage
22
+ if Calabash::Android::UsageTracker.track_usage? &&
23
+ info_we_are_allowed_to_track != "none"
24
+ begin
25
+ HTTPClient.post(ROUTE, info)
26
+ rescue => e
27
+ message = %Q{ERROR: Could not post usage tracking information:#{$-0}#{e}}
28
+ Calabash::Android::Logging.log_to_file(message)
29
+ end
30
+ end
31
+ end
32
+
33
+ # @!visibility private
34
+ def post_usage_async
35
+ t = Thread.new do
36
+ post_usage
37
+ end
38
+
39
+ m = Thread.current
40
+
41
+ Thread.new do
42
+ loop do
43
+ unless t.alive?
44
+ break
45
+ end
46
+
47
+ unless m.alive?
48
+ t.kill
49
+ break
50
+ end
51
+ end
52
+ end
53
+ nil
54
+ end
55
+
56
+ private
57
+
58
+ # @!visibility private
59
+ def preferences
60
+ Calabash::Android::Preferences.new
61
+ end
62
+
63
+ # @!visibility private
64
+ def user_id
65
+ preferences.user_id
66
+ end
67
+
68
+ # @!visibility private
69
+ def info_we_are_allowed_to_track
70
+ preferences.usage_tracking
71
+ end
72
+
73
+ # @!visibility private
74
+ def self.track_usage?
75
+ @@track_usage && !self.xtc?
76
+ end
77
+
78
+ # @!visibility private
79
+ def self.xtc?
80
+ ENV["XAMARIN_TEST_CLOUD"] == "1"
81
+ end
82
+
83
+ # @!visibility private
84
+ DATA_VERSION = "1.1"
85
+
86
+ # @!visibility private
87
+ WINDOWS = "Windows"
88
+
89
+ # @!visibility private
90
+ OSX = "Darwin"
91
+
92
+ # @!visibility private
93
+ CALABASH_IOS = "iOS"
94
+
95
+ # @!visibility private
96
+ CALABASH_ANDROID = "Android"
97
+
98
+ # @!visibility private
99
+ ROUTE = "http://calabash-ci.macminicolo.net:56789/logEvent"
100
+
101
+ # @!visibility private
102
+ def host_os
103
+ @host_os ||= lambda do
104
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
105
+ WINDOWS
106
+ else
107
+ `uname -s`.chomp
108
+ end
109
+ end.call
110
+ end
111
+
112
+ # @!visibility private
113
+ def host_os_version
114
+ @host_os_version ||= lambda do
115
+ if host_os == WINDOWS
116
+ `ver`.chomp
117
+ elsif host_os == OSX
118
+ `sw_vers -productVersion`.chomp
119
+ else
120
+ `uname -r`.chomp
121
+ end
122
+ end.call
123
+ end
124
+
125
+ # @!visibility private
126
+ def irb?
127
+ $0 == "irb"
128
+ end
129
+
130
+ # @!visibility private
131
+ def ruby_version
132
+ @ruby_version ||= `#{RbConfig.ruby} -v`.chomp
133
+ end
134
+
135
+ # @!visibility private
136
+ def used_bundle_exec?
137
+ Object.const_defined?(:Bundler)
138
+ end
139
+
140
+ # @!visibility private
141
+ def used_cucumber?
142
+ Object.const_defined?(:Cucumber)
143
+ end
144
+
145
+ # @!visibility private
146
+ #
147
+ # Collect a hash of usage info.
148
+ def info
149
+
150
+ allowed = info_we_are_allowed_to_track
151
+
152
+ if allowed == "none"
153
+ raise RuntimeError,
154
+ "This method should not be called if the user does not want to be tracked."
155
+ end
156
+
157
+ # Events only
158
+ hash = {
159
+ :event_name => "session",
160
+ :data_version => DATA_VERSION,
161
+ :user_id => user_id
162
+ }
163
+
164
+ if allowed == "system_info"
165
+ hash.merge!(
166
+ {
167
+ :platform => CALABASH_ANDROID,
168
+ :host_os => host_os,
169
+ :host_os_version => host_os_version,
170
+ :irb => irb?,
171
+ :ruby_version => ruby_version,
172
+ :used_bundle_exec => used_bundle_exec?,
173
+ :used_cucumber => used_cucumber?,
174
+
175
+ :version => Calabash::Android::VERSION,
176
+
177
+ :ci => Calabash::Android::Environment.ci?,
178
+ :jenkins => Calabash::Android::Environment.jenkins?,
179
+ :travis => Calabash::Android::Environment.travis?,
180
+ :circle_ci => Calabash::Android::Environment.circle_ci?,
181
+ :gitlab => Calabash::Android::Environment.gitlab?,
182
+ :teamcity => Calabash::Android::Environment.teamcity?
183
+ }
184
+ )
185
+ end
186
+
187
+ hash
188
+ end
189
+ end
190
+ end
191
+ end
192
+
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.5.16.pre1"
3
+ VERSION = "0.6.0.prelatestcrosswalk"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ module Calabash
14
14
  :post_timeout => 0,
15
15
  :timeout_message => 'Timed out waiting...',
16
16
  :screenshot_on_error => true
17
- }.freeze
17
+ }
18
18
 
19
19
  def wait_for(options_or_timeout=DEFAULT_OPTS, &block)
20
20
  #note Hash is preferred, number acceptable for backwards compat
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.16.pre1
4
+ version: 0.6.0.prelatestcrosswalk
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-12-05 00:00:00.000000000 Z
11
+ date: 2016-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -176,6 +176,118 @@ dependencies:
176
176
  - - "~>"
177
177
  - !ruby/object:Gem::Version
178
178
  version: '3.1'
179
+ - !ruby/object:Gem::Dependency
180
+ name: rspec_junit_formatter
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ - !ruby/object:Gem::Dependency
194
+ name: rspec
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '3.0'
200
+ type: :development
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - "~>"
205
+ - !ruby/object:Gem::Version
206
+ version: '3.0'
207
+ - !ruby/object:Gem::Dependency
208
+ name: pry
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ - !ruby/object:Gem::Dependency
222
+ name: pry-nav
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - ">="
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ type: :development
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - ">="
233
+ - !ruby/object:Gem::Version
234
+ version: '0'
235
+ - !ruby/object:Gem::Dependency
236
+ name: guard-rspec
237
+ requirement: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - ">="
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
242
+ type: :development
243
+ prerelease: false
244
+ version_requirements: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - ">="
247
+ - !ruby/object:Gem::Version
248
+ version: '0'
249
+ - !ruby/object:Gem::Dependency
250
+ name: guard-bundler
251
+ requirement: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ version: '0'
256
+ type: :development
257
+ prerelease: false
258
+ version_requirements: !ruby/object:Gem::Requirement
259
+ requirements:
260
+ - - ">="
261
+ - !ruby/object:Gem::Version
262
+ version: '0'
263
+ - !ruby/object:Gem::Dependency
264
+ name: growl
265
+ requirement: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - ">="
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ type: :development
271
+ prerelease: false
272
+ version_requirements: !ruby/object:Gem::Requirement
273
+ requirements:
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ version: '0'
277
+ - !ruby/object:Gem::Dependency
278
+ name: stub_env
279
+ requirement: !ruby/object:Gem::Requirement
280
+ requirements:
281
+ - - ">="
282
+ - !ruby/object:Gem::Version
283
+ version: '0'
284
+ type: :development
285
+ prerelease: false
286
+ version_requirements: !ruby/object:Gem::Requirement
287
+ requirements:
288
+ - - ">="
289
+ - !ruby/object:Gem::Version
290
+ version: '0'
179
291
  description: 'calabash-android drives tests for native and hybrid Android apps. '
180
292
  email:
181
293
  - jonas@lesspainful.com
@@ -184,14 +296,7 @@ executables:
184
296
  extensions: []
185
297
  extra_rdoc_files: []
186
298
  files:
187
- - ".calabash_settings"
188
- - ".yardopts"
189
- - CHANGES.txt
190
- - ENVIRONMENT_VARIABLES.md
191
- - Gemfile
192
299
  - LICENSE
193
- - README_YARDOC.md
194
- - Rakefile
195
300
  - bin/calabash-android
196
301
  - bin/calabash-android-build.rb
197
302
  - bin/calabash-android-console.rb
@@ -199,7 +304,6 @@ files:
199
304
  - bin/calabash-android-helpers.rb
200
305
  - bin/calabash-android-run.rb
201
306
  - bin/calabash-android-setup.rb
202
- - calabash-android.gemspec
203
307
  - epl-v10.html
204
308
  - features-skeleton/my_first.feature
205
309
  - features-skeleton/step_definitions/calabash_steps.rb
@@ -211,21 +315,24 @@ files:
211
315
  - lib/calabash-android.rb
212
316
  - lib/calabash-android/abase.rb
213
317
  - lib/calabash-android/calabash_steps.rb
214
- - lib/calabash-android/canned_steps.md
215
318
  - lib/calabash-android/color_helper.rb
216
319
  - lib/calabash-android/cucumber.rb
217
320
  - lib/calabash-android/defaults.rb
218
321
  - lib/calabash-android/deprecated_actions.map
322
+ - lib/calabash-android/dot_dir.rb
219
323
  - lib/calabash-android/drag_helpers.rb
220
324
  - lib/calabash-android/env.rb
325
+ - lib/calabash-android/environment.rb
221
326
  - lib/calabash-android/environment_helpers.rb
222
327
  - lib/calabash-android/gestures.rb
223
328
  - lib/calabash-android/helpers.rb
224
329
  - lib/calabash-android/java_keystore.rb
225
330
  - lib/calabash-android/lib/AXMLPrinter2.jar
331
+ - lib/calabash-android/lib/AndroidManifest.xml
226
332
  - lib/calabash-android/lib/TestServer.apk
227
333
  - lib/calabash-android/lib/manifest_extractor.jar
228
334
  - lib/calabash-android/lib/screenshotTaker.jar
335
+ - lib/calabash-android/logging.rb
229
336
  - lib/calabash-android/management/adb.rb
230
337
  - lib/calabash-android/management/app_installation.rb
231
338
  - lib/calabash-android/monkey_helpers.rb
@@ -246,15 +353,15 @@ files:
246
353
  - lib/calabash-android/steps/search_steps.rb
247
354
  - lib/calabash-android/steps/spinner_steps.rb
248
355
  - lib/calabash-android/steps/time_picker_steps.rb
356
+ - lib/calabash-android/store/preferences.rb
249
357
  - lib/calabash-android/text_helpers.rb
250
358
  - lib/calabash-android/touch_helpers.rb
359
+ - lib/calabash-android/usage_tracker.rb
251
360
  - lib/calabash-android/version.rb
252
361
  - lib/calabash-android/wait_helpers.rb
253
- - test-server/AndroidManifest.xml
254
- - test-server/build.xml
255
- - test-server/calabash-js/src/calabash.js
256
362
  homepage: http://github.com/calabash
257
- licenses: []
363
+ licenses:
364
+ - EPL-1.0
258
365
  metadata: {}
259
366
  post_install_message:
260
367
  rdoc_options: []