calabash-cucumber 0.16.4 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/bin/calabash-ios-generate.rb +61 -10
  3. data/dylibs/libCalabashDyn.dylib +0 -0
  4. data/dylibs/libCalabashDynSim.dylib +0 -0
  5. data/features-skeleton/sample.feature +7 -0
  6. data/features-skeleton/steps/sample_steps.rb +45 -0
  7. data/features-skeleton/support/01_launch.rb +31 -33
  8. data/features-skeleton/support/dry_run.rb +2 -0
  9. data/features-skeleton/support/env.rb +1 -0
  10. data/features-skeleton/support/patches/cucumber.rb +15 -0
  11. data/lib/calabash-cucumber.rb +4 -0
  12. data/lib/calabash-cucumber/actions/instruments_actions.rb +0 -5
  13. data/lib/calabash-cucumber/actions/playback_actions.rb +1 -6
  14. data/lib/calabash-cucumber/connection_helpers.rb +50 -1
  15. data/lib/calabash-cucumber/core.rb +94 -72
  16. data/lib/calabash-cucumber/dot_dir.rb +18 -0
  17. data/lib/calabash-cucumber/launch/simulator_launcher.rb +35 -3
  18. data/lib/calabash-cucumber/launcher.rb +46 -99
  19. data/lib/calabash-cucumber/logging.rb +79 -0
  20. data/lib/calabash-cucumber/playback_helpers.rb +2 -2
  21. data/lib/calabash-cucumber/store/preferences.rb +223 -0
  22. data/lib/calabash-cucumber/uia.rb +0 -43
  23. data/lib/calabash-cucumber/usage_tracker.rb +192 -0
  24. data/lib/calabash-cucumber/version.rb +2 -2
  25. data/lib/calabash-cucumber/wait_helpers.rb +32 -0
  26. data/scripts/.irbrc +19 -4
  27. data/staticlib/calabash.framework.zip +0 -0
  28. data/staticlib/libFrankCalabash.a +0 -0
  29. metadata +31 -19
  30. data/features-skeleton/my_first.feature +0 -12
  31. data/features-skeleton/step_definitions/calabash_steps.rb +0 -1
  32. data/features-skeleton/step_definitions/my_first_steps.rb +0 -4
  33. data/features-skeleton/support/02_pre_stop_hooks.rb +0 -0
@@ -61,49 +61,6 @@ module Calabash
61
61
  end
62
62
  end
63
63
 
64
-
65
- # @!visibility private
66
- def uia_wait_tap(query, options={})
67
- launcher = Calabash::Cucumber::Launcher.launcher_if_used
68
- run_loop = launcher && launcher.active? && launcher.run_loop
69
-
70
- unless run_loop
71
- raise 'The current launcher must be active and be attached to a run_loop'
72
- end
73
-
74
- unless query
75
- raise ArgumentError, "Expected a query argument but got '#{query}'"
76
- end
77
-
78
- strategy = run_loop[:uia_strategy]
79
-
80
- case strategy
81
- when :preferences
82
- path = 'uia-tap'
83
- when :shared_element
84
- path = 'uia-tap-shared'
85
- when :host
86
- lines = ['wait_tap is not supported when using the :host strategy',
87
- 'Please see:',
88
- '',
89
- 'https://github.com/calabash/calabash-ios/issues/675',
90
- '',
91
- 'for details and workarounds'
92
- ]
93
-
94
- raise lines.join("\n")
95
- else
96
- raise "Unknown UIA strategy '#{strategy}'; expected {:host | :preferences | :shared_element}"
97
- end
98
-
99
- res = http({:method => :post, :path => path}, {:query => query}.merge(options))
100
- res = JSON.parse(res)
101
- if res['outcome'] != 'SUCCESS'
102
- raise "wait-uia-tap action failed because: #{res['reason']}\n#{res['details']}"
103
- end
104
- res['results']
105
- end
106
-
107
64
  # Invoke a Calabash query inside the UIAutomation Calabash engine
108
65
  # Note that this traverses the UIA (accessibility) hierarchy.
109
66
  # @example uia query equivalent of "button marked:'Hello'"
@@ -0,0 +1,192 @@
1
+ module Calabash
2
+ module Cucumber
3
+ class UsageTracker
4
+
5
+ require "httpclient"
6
+ require "run_loop"
7
+
8
+ # @!visibility private
9
+ @@track_usage = true
10
+
11
+ # @!visibility private
12
+ def self.enable_usage_tracking
13
+ @@track_usage = true
14
+ end
15
+
16
+ # @!visibility private
17
+ def self.disable_usage_tracking
18
+ @@track_usage = false
19
+ end
20
+
21
+ # @!visibility private
22
+ def post_usage
23
+ if Calabash::Cucumber::UsageTracker.track_usage? &&
24
+ info_we_are_allowed_to_track != "none"
25
+ begin
26
+ HTTPClient.post(ROUTE, info)
27
+ rescue => _
28
+ # do nothing
29
+ # Perhaps we should log?
30
+ end
31
+ end
32
+ end
33
+
34
+ # @!visibility private
35
+ def post_usage_async
36
+ t = Thread.new do
37
+ post_usage
38
+ end
39
+
40
+ m = Thread.current
41
+
42
+ Thread.new do
43
+ loop do
44
+ unless t.alive?
45
+ break
46
+ end
47
+
48
+ unless m.alive?
49
+ t.kill
50
+ break
51
+ end
52
+ end
53
+ end
54
+ nil
55
+ end
56
+
57
+ private
58
+
59
+ # @!visibility private
60
+ def preferences
61
+ Calabash::Cucumber::Preferences.new
62
+ end
63
+
64
+ # @!visibility private
65
+ def user_id
66
+ preferences.user_id
67
+ end
68
+
69
+ # @!visibility private
70
+ def info_we_are_allowed_to_track
71
+ preferences.usage_tracking
72
+ end
73
+
74
+ # @!visibility private
75
+ def self.track_usage?
76
+ @@track_usage && !self.xtc?
77
+ end
78
+
79
+ # @!visibility private
80
+ def self.xtc?
81
+ ENV["XAMARIN_TEST_CLOUD"] == "1"
82
+ end
83
+
84
+ # @!visibility private
85
+ DATA_VERSION = "1.0"
86
+
87
+ # @!visibility private
88
+ WINDOWS = "Windows"
89
+
90
+ # @!visibility private
91
+ OSX = "Darwin"
92
+
93
+ # @!visibility private
94
+ CALABASH_IOS = "iOS"
95
+
96
+ # @!visibility private
97
+ CALABASH_ANDROID = "Android"
98
+
99
+ # @!visibility private
100
+ ROUTE = "http://calabash-ci.macminicolo.net:56789/logEvent"
101
+
102
+ # @!visibility private
103
+ def host_os
104
+ @host_os ||= lambda do
105
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
106
+ WINDOWS
107
+ else
108
+ `uname -s`.chomp
109
+ end
110
+ end.call
111
+ end
112
+
113
+ # @!visibility private
114
+ def host_os_version
115
+ @host_os_version ||= lambda do
116
+ if host_os == WINDOWS
117
+ `ver`.chomp
118
+ elsif host_os == OSX
119
+ `sw_vers -productVersion`.chomp
120
+ else
121
+ `uname -r`.chomp
122
+ end
123
+ end.call
124
+ end
125
+
126
+ # @!visibility private
127
+ def irb?
128
+ $0 == "irb"
129
+ end
130
+
131
+ # @!visibility private
132
+ def ruby_version
133
+ @ruby_version ||= `#{RbConfig.ruby} -v`.chomp
134
+ end
135
+
136
+ # @!visibility private
137
+ def used_bundle_exec?
138
+ Object.const_defined?(:Bundler)
139
+ end
140
+
141
+ # @!visibility private
142
+ def used_cucumber?
143
+ Object.const_defined?(:Cucumber)
144
+ end
145
+
146
+ # @!visibility private
147
+ #
148
+ # Collect a hash of usage info.
149
+ def info
150
+
151
+ allowed = info_we_are_allowed_to_track
152
+
153
+ if allowed == "none"
154
+ raise RuntimeError,
155
+ "This method should not be called if the user does not want to be tracked."
156
+ end
157
+
158
+ # Events only
159
+ hash = {
160
+ :event_name => "session",
161
+ :data_version => DATA_VERSION,
162
+ :user_id => user_id
163
+ }
164
+
165
+ if allowed == "system_info"
166
+ hash.merge!(
167
+ {
168
+ :platform => CALABASH_IOS,
169
+ :host_os => host_os,
170
+ :host_os_version => host_os_version,
171
+ :irb => irb?,
172
+ :ruby_version => ruby_version,
173
+ :used_bundle_exec => used_bundle_exec?,
174
+ :used_cucumber => used_cucumber?,
175
+
176
+ :version => Calabash::Cucumber::VERSION,
177
+
178
+ :ci => RunLoop::Environment.ci?,
179
+ :jenkins => RunLoop::Environment.jenkins?,
180
+ :travis => RunLoop::Environment.travis?,
181
+ :circle_ci => RunLoop::Environment.circle_ci?,
182
+ :teamcity => RunLoop::Environment.teamcity?
183
+ }
184
+ )
185
+ end
186
+
187
+ hash
188
+ end
189
+ end
190
+ end
191
+ end
192
+
@@ -3,10 +3,10 @@ module Calabash
3
3
 
4
4
  # @!visibility public
5
5
  # The Calabash iOS gem version.
6
- VERSION = '0.16.4'
6
+ VERSION = "0.17.0"
7
7
 
8
8
  # @!visibility public
9
9
  # The minimum required version of the Calabash embedded server.
10
- MIN_SERVER_VERSION = '0.16.4'
10
+ MIN_SERVER_VERSION = "0.17.0"
11
11
  end
12
12
  end
@@ -48,6 +48,38 @@ module Calabash
48
48
  :screenshot_on_error => true
49
49
  }
50
50
 
51
+ # Performs the `tap` gesture on the (first) view that matches query `uiquery`.
52
+ #
53
+ # As opposed to `touch`, `wait_tap` is a high-level method that combines:
54
+ #
55
+ # 1. waiting for the view to appear,
56
+ # 2. waiting for animations to complete on the view (and it's parents) and
57
+ # 3. actually tapping the view.
58
+ #
59
+ # This replaces the common pattern:
60
+ #
61
+ # ```
62
+ # wait_for_none_animating
63
+ # wait_for_element_exists("* marked:'log in'")
64
+ # touch("* marked:'log in'")
65
+ # ```
66
+ #
67
+ # By default, taps the center of the view.
68
+ # @see Calabash::Cucumber::Core#touch
69
+ # @see Calabash::Cucumber::Core#touch_point
70
+ # @param {String} uiquery query describing view to tap. Note `nil` is not allowed.
71
+ # @param {Hash} options option for modifying the details of the touch
72
+ # @option options {Hash} :offset (nil) optional offset to tap point. Offset has an `:x` and `:y` key
73
+ # the tap will be performed on the center of the view plus the offset.
74
+ # @option options {Hash} :timeout (30) maximum number of seconds to wait for the view to appear
75
+ # @option options {Hash} :frequency (0.2) polling frequency to for checking if the view is present (>= 0.1)
76
+ # @return {Array<Hash>} serialized version of the tapped view
77
+ def wait_tap(uiquery, options={})
78
+ wait_for_none_animating
79
+ wait_for_element_exists(uiquery, options)
80
+ touch(uiquery, options)
81
+ end
82
+
51
83
  # Waits for a condition to be true. The condition is specified by a given block that is called repeatedly.
52
84
  # If the block returns a 'trueish' value the condition is considered true and
53
85
  # `wait_for` immediately returns.
@@ -27,10 +27,7 @@ ARGV.concat [ '--readline',
27
27
  '--prompt-mode',
28
28
  'simple']
29
29
 
30
- # 25 entries in the list
31
30
  IRB.conf[:SAVE_HISTORY] = 50
32
-
33
- # Store results in home directory with specified file name
34
31
  IRB.conf[:HISTORY_FILE] = '.irb-history'
35
32
 
36
33
  require 'calabash-cucumber/operations'
@@ -38,7 +35,6 @@ require 'calabash-cucumber/operations'
38
35
  # legacy support - module was deprecated 0.9.169
39
36
  # and replaced with simulator_launcher
40
37
  require 'calabash-cucumber/launch/simulator_helper'
41
-
42
38
  require 'calabash-cucumber/launch/simulator_launcher'
43
39
  SIM=Calabash::Cucumber::SimulatorLauncher.new()
44
40
 
@@ -47,3 +43,22 @@ extend Calabash::Cucumber::Operations
47
43
  def embed(x,y=nil,z=nil)
48
44
  puts "Screenshot at #{x}"
49
45
  end
46
+
47
+ require "calabash-cucumber"
48
+
49
+ def preferences
50
+ Calabash::Cucumber::Preferences.new
51
+ end
52
+
53
+ def disable_usage_tracking
54
+ preferences.usage_tracking = "none"
55
+ puts "Calabash will not collect usage information."
56
+ "none"
57
+ end
58
+
59
+ def enable_usage_tracking(level="system_info")
60
+ preferences.usage_tracking = level
61
+ puts "Calabash will collect statistics using the '#{level}' rule."
62
+ level
63
+ end
64
+
Binary file
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.4
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2015-12-09 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: calabash-common
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -144,20 +144,14 @@ dependencies:
144
144
  name: run_loop
145
145
  requirement: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- version: 1.5.5
150
- - - "<"
147
+ - - "~>"
151
148
  - !ruby/object:Gem::Version
152
149
  version: '2.0'
153
150
  type: :runtime
154
151
  prerelease: false
155
152
  version_requirements: !ruby/object:Gem::Requirement
156
153
  requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: 1.5.5
160
- - - "<"
154
+ - - "~>"
161
155
  - !ruby/object:Gem::Version
162
156
  version: '2.0'
163
157
  - !ruby/object:Gem::Dependency
@@ -230,6 +224,20 @@ dependencies:
230
224
  - - '='
231
225
  - !ruby/object:Gem::Version
232
226
  version: 3.2.0
227
+ - !ruby/object:Gem::Dependency
228
+ name: rspec_junit_formatter
229
+ requirement: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ version: '0'
234
+ type: :development
235
+ prerelease: false
236
+ version_requirements: !ruby/object:Gem::Requirement
237
+ requirements:
238
+ - - ">="
239
+ - !ruby/object:Gem::Version
240
+ version: '0'
233
241
  - !ruby/object:Gem::Dependency
234
242
  name: luffa
235
243
  requirement: !ruby/object:Gem::Requirement
@@ -379,12 +387,12 @@ files:
379
387
  - doc/calabash-ios-help.txt
380
388
  - dylibs/libCalabashDyn.dylib
381
389
  - dylibs/libCalabashDynSim.dylib
382
- - features-skeleton/my_first.feature
383
- - features-skeleton/step_definitions/calabash_steps.rb
384
- - features-skeleton/step_definitions/my_first_steps.rb
390
+ - features-skeleton/sample.feature
391
+ - features-skeleton/steps/sample_steps.rb
385
392
  - features-skeleton/support/01_launch.rb
386
- - features-skeleton/support/02_pre_stop_hooks.rb
393
+ - features-skeleton/support/dry_run.rb
387
394
  - features-skeleton/support/env.rb
395
+ - features-skeleton/support/patches/cucumber.rb
388
396
  - features/step_definitions/calabash_steps.rb
389
397
  - lib/calabash-cucumber.rb
390
398
  - lib/calabash-cucumber/actions/instruments_actions.rb
@@ -397,6 +405,7 @@ files:
397
405
  - lib/calabash-cucumber/date_picker.rb
398
406
  - lib/calabash-cucumber/deprecated.rb
399
407
  - lib/calabash-cucumber/device.rb
408
+ - lib/calabash-cucumber/dot_dir.rb
400
409
  - lib/calabash-cucumber/environment_helpers.rb
401
410
  - lib/calabash-cucumber/failure_helpers.rb
402
411
  - lib/calabash-cucumber/http_helpers.rb
@@ -407,6 +416,7 @@ files:
407
416
  - lib/calabash-cucumber/launch/simulator_helper.rb
408
417
  - lib/calabash-cucumber/launch/simulator_launcher.rb
409
418
  - lib/calabash-cucumber/launcher.rb
419
+ - lib/calabash-cucumber/logging.rb
410
420
  - lib/calabash-cucumber/map.rb
411
421
  - lib/calabash-cucumber/operations.rb
412
422
  - lib/calabash-cucumber/playback_helpers.rb
@@ -513,8 +523,10 @@ files:
513
523
  - lib/calabash-cucumber/resources/wheel_up_ios5_iphone.base64
514
524
  - lib/calabash-cucumber/rotation_helpers.rb
515
525
  - lib/calabash-cucumber/status_bar_helpers.rb
526
+ - lib/calabash-cucumber/store/preferences.rb
516
527
  - lib/calabash-cucumber/tests_helpers.rb
517
528
  - lib/calabash-cucumber/uia.rb
529
+ - lib/calabash-cucumber/usage_tracker.rb
518
530
  - lib/calabash-cucumber/utils/logging.rb
519
531
  - lib/calabash-cucumber/utils/plist_buddy.rb
520
532
  - lib/calabash-cucumber/utils/simulator_accessibility.rb
@@ -543,7 +555,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
543
555
  requirements:
544
556
  - - ">="
545
557
  - !ruby/object:Gem::Version
546
- version: '1.9'
558
+ version: '2.0'
547
559
  required_rubygems_version: !ruby/object:Gem::Requirement
548
560
  requirements:
549
561
  - - ">="