calabash-cucumber 0.19.0 → 0.19.1

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: f8d1ae811a8e9ce1b128587fde8169a360a814f4
4
- data.tar.gz: 5362957ea9cbf06f092a4d6274c438e9e6d2f920
3
+ metadata.gz: 025464e725f8c4d6ff249aaf250a6685896a75f6
4
+ data.tar.gz: 37858349091f137c9888024cd77cbb856c60c41d
5
5
  SHA512:
6
- metadata.gz: a96c9b3f4680184761ca7c35e2b80e557bb539dbd30f408031e93ba1d1fa5e0897658296a3f49c0da2e4dc649c3a5fd57b5adf5afed622b8a445ccc6eaabc75b
7
- data.tar.gz: 08fd8ceedc0c2961abd1d8ccf24809eba00fbe1c0be7f1bae925b08052e64e31e80480554b9c7ff560f88ec4e8d0fe0ff9ed9feef2271590522ad46c8415aa87
6
+ metadata.gz: c635ff3050323a9233fedc5a000eb7ba3ece0d93fa7708d6365c89a38b55757794bf9fa311e276e5406cac166b87cf7930adeab1d9a5c1d02618356415972cda
7
+ data.tar.gz: 62dd3aa71a22c78c10ec5377a53277af29701cfa291941ce03db779505f6f9eaeb316b7d1d8aac16d20b95cddc8a10b6a7ece2b865c1309091f5176ddb4ee903
Binary file
@@ -279,7 +279,9 @@ Please report this issue.
279
279
  str_id = data["id"] ? "[id:#{RunLoop::Color.blue(data["id"])}] " : ""
280
280
  str_label = data["label"] ? "[label:#{RunLoop::Color.green(data["label"])}] " : ""
281
281
  str_text = data["value"] ? "[text:#{RunLoop::Color.magenta(data["value"])}] " : ""
282
- output("#{str_type}#{str_id}#{str_label}#{str_text}", indentation)
282
+ str_node_type = data["nodeType"] ? "[nodeType:#{RunLoop::Color.red(data["nodeType"])}] " : ""
283
+
284
+ output("#{str_type}#{str_id}#{str_label}#{str_text}#{str_node_type}", indentation)
283
285
  output("\n", indentation)
284
286
  end
285
287
  end
@@ -102,7 +102,8 @@ module Calabash
102
102
  # :sample => 1,
103
103
  # :height => 1334,
104
104
  # :width => 750,
105
- # :scale" => 2
105
+ # :scale" => 2,
106
+ # :native_scale => 2
106
107
  # }
107
108
  #
108
109
  #
@@ -51,7 +51,12 @@ module Calabash
51
51
  def screenshot_embed(options={:prefix => nil, :name => nil, :label => nil})
52
52
  path = screenshot(options)
53
53
  filename = options[:label] || File.basename(path)
54
- embed(path, 'image/png', filename)
54
+ if self.respond_to?(:embed)
55
+ embed(path, 'image/png', filename)
56
+ else
57
+ RunLoop.log_info2("Embed is not available in this context. Will not embed.")
58
+ end
59
+ true
55
60
  end
56
61
 
57
62
  # Generates a screenshot of the app UI by calling screenshot_embed and raises an error.
@@ -82,7 +87,6 @@ module Calabash
82
87
  def fail(msg='Error. Check log for details.', options={:prefix => nil, :name => nil, :label => nil})
83
88
  screenshot_and_raise(msg, options)
84
89
  end
85
-
86
90
  end
87
91
  end
88
- end
92
+ end
@@ -66,7 +66,7 @@ module Calabash
66
66
 
67
67
  begin
68
68
  success, body = self.ping_app
69
- RunLoop.log_debug("Connected to Calaash Server on try: #{try + 1} of #{max_retry_count}")
69
+ RunLoop.log_debug("Connected to Calabash Server on try: #{try + 1} of #{max_retry_count}")
70
70
  return success, body if success
71
71
  rescue => e
72
72
  last_error = e
@@ -229,17 +229,8 @@ module Calabash
229
229
  return if opts[:skip]
230
230
 
231
231
  screenshot = opts[:screenshot]
232
- unless keyboard_visible?
233
- msg = 'no visible keyboard'
234
- if screenshot
235
- screenshot_and_raise msg
236
- else
237
- raise msg
238
- end
239
- end
240
-
241
- if split_keyboard_visible? and uia_not_available?
242
- msg = 'cannot type on a split keyboard without launching with Instruments'
232
+ if !keyboard_visible?
233
+ msg = "No visible keyboard."
243
234
  if screenshot
244
235
  screenshot_and_raise msg
245
236
  else
@@ -291,46 +282,32 @@ module Calabash
291
282
  _ensure_can_enter_text({:screenshot => should_screenshot,
292
283
  :skip => (not should_screenshot)})
293
284
 
294
- if uia_available?
295
- if chr.length == 1
296
- uia_type_string_raw chr
297
- else
298
- code = UIA_SUPPORTED_CHARS[chr]
299
-
300
- unless code
301
- raise "typing character '#{chr}' is not yet supported when running with Instruments"
302
- end
285
+ if chr.length == 1
286
+ uia_type_string_raw chr
287
+ else
288
+ code = UIA_SUPPORTED_CHARS[chr]
303
289
 
304
- # on iOS 6, the Delete char code is _not_ \b
305
- # on iOS 7, the Delete char code is \b on non-numeric keyboards
306
- # on numeric keyboards, it is actually a button on the
307
- # keyboard and not a key
308
- if code.eql?(UIA_SUPPORTED_CHARS['Delete'])
309
- js_tap_delete = "(function() {"\
310
- "var deleteElement = uia.keyboard().elements().firstWithName('Delete');"\
311
- "deleteElement = deleteElement.isValid() ? deleteElement : uia.keyboard().elements().firstWithName('delete');"\
312
- "deleteElement.tap();"\
313
- "})();"
314
- uia(js_tap_delete)
315
- else
316
- uia_type_string_raw(code)
317
- end
290
+ unless code
291
+ raise "typing character '#{chr}' is not yet supported when running with Instruments"
318
292
  end
319
- # noinspection RubyStringKeysInHashInspection
320
- res = {'results' => []}
321
- else
322
- res = http({:method => :post, :path => 'keyboard'},
323
- {:key => chr, :events => load_playback_data('touch_done')})
324
- res = JSON.parse(res)
325
- if res['outcome'] != 'SUCCESS'
326
- msg = "Keyboard enter failed failed because: #{res['reason']}\n#{res['details']}"
327
- if should_screenshot
328
- screenshot_and_raise msg
329
- else
330
- raise msg
331
- end
293
+
294
+ # on iOS 6, the Delete char code is _not_ \b
295
+ # on iOS 7, the Delete char code is \b on non-numeric keyboards
296
+ # on numeric keyboards, it is actually a button on the
297
+ # keyboard and not a key
298
+ if code.eql?(UIA_SUPPORTED_CHARS['Delete'])
299
+ js_tap_delete = "(function() {"\
300
+ "var deleteElement = uia.keyboard().elements().firstWithName('Delete');"\
301
+ "deleteElement = deleteElement.isValid() ? deleteElement : uia.keyboard().elements().firstWithName('delete');"\
302
+ "deleteElement.tap();"\
303
+ "})();"
304
+ uia(js_tap_delete)
305
+ else
306
+ uia_type_string_raw(code)
332
307
  end
333
308
  end
309
+ # noinspection RubyStringKeysInHashInspection
310
+ res = {'results' => []}
334
311
 
335
312
  if ENV['POST_ENTER_KEYBOARD']
336
313
  w = ENV['POST_ENTER_KEYBOARD'].to_f
@@ -349,19 +326,9 @@ module Calabash
349
326
  # @raise [RuntimeError] if the text cannot be typed.
350
327
  def keyboard_enter_text(text)
351
328
  _ensure_can_enter_text
352
- if uia_available?
353
- text_before = _text_from_first_responder()
354
- text_before = text_before.gsub("\n","\\n") if text_before
355
- uia_type_string(text, text_before)
356
- else
357
- text.each_char do |ch|
358
- begin
359
- keyboard_enter_char(ch, {:should_screenshot => false})
360
- rescue
361
- _search_keyplanes_and_enter_char(ch)
362
- end
363
- end
364
- end
329
+ text_before = _text_from_first_responder()
330
+ text_before = text_before.gsub("\n","\\n") if text_before
331
+ uia_type_string(text, text_before)
365
332
  end
366
333
 
367
334
  # @!visibility private
@@ -406,14 +373,9 @@ module Calabash
406
373
  # @param [String] text the text to enter
407
374
  def fast_enter_text(text)
408
375
  _ensure_can_enter_text
409
- if uia_available?
410
- uia_set_responder_value(text)
411
- else
412
- keyboard_enter_text(text)
413
- end
376
+ uia_set_responder_value(text)
414
377
  end
415
378
 
416
-
417
379
  # Touches the keyboard action key.
418
380
  #
419
381
  # The action key depends on the keyboard. Some examples include:
@@ -528,13 +490,8 @@ module Calabash
528
490
  #
529
491
  # @raise [RuntimeError] if the device is not an iPad
530
492
  def dismiss_ipad_keyboard
531
- screenshot_and_raise 'cannot dismiss keyboard on iphone' if device_family_iphone?
532
-
533
- if uia_available?
534
- send_uia_command({:command => "#{_query_uia_hide_keyboard_button}.tap()"})
535
- else
536
- touch(_query_for_keyboard_mode_key)
537
- end
493
+ screenshot_and_raise "Cannot dismiss keyboard on iPhone" if device_family_iphone?
494
+ send_uia_command({:command => "#{_query_uia_hide_keyboard_button}.tap()"})
538
495
 
539
496
  opts = {:timeout_message => 'keyboard did not disappear'}
540
497
  wait_for(opts) do
@@ -553,78 +510,12 @@ module Calabash
553
510
  # @raise [RuntimeError] when the device is not an iPad
554
511
  # @raise [RuntimeError] the app was not launched with instruments
555
512
  def _point_for_ipad_keyboard_mode_key
556
- raise 'the keyboard mode does not exist on the on the iphone' if device_family_iphone?
557
- raise 'cannot detect keyboard mode key without launching with instruments' unless uia_available?
513
+ raise "The keyboard mode does not exist on the on the iphone" if device_family_iphone?
558
514
  res = send_uia_command({:command => "#{_query_uia_hide_keyboard_button}.rect()"})
559
515
  origin = res['value']['origin']
560
516
  {:x => origin['x'], :y => origin['y']}
561
517
  end
562
518
 
563
- # @!visibility private
564
- # Returns a query string for touching one of the options that appears when
565
- # the iPad mode key is touched and held.
566
- #
567
- # The mode key is also know as the 'Hide keyboard' key.
568
- #
569
- # @note
570
- # This is only available when running outside of instruments.
571
- #
572
- # @param [Symbol] top_or_bottom can be one of `{:top | :bottom}`
573
- # @param [Symbol] mode `{:docked | :undocked | :skipped}`
574
- #
575
- # @raise [RuntimeError] the device is not an iPad
576
- # @raise [RuntimeError] the app was not launched with instruments
577
- # @raise [RuntimeError] the method is passed invalid arguments
578
- def _query_for_touch_for_keyboard_mode_option(top_or_bottom, mode)
579
- raise 'the keyboard mode does not exist on the iphone' if device_family_iphone?
580
-
581
- if uia_available?
582
- raise "UIA is available, use '_point_for_keyboard_mode_key' instead"
583
- end
584
-
585
- valid = [:top, :bottom]
586
- unless valid.include? top_or_bottom
587
- raise "expected '#{top_or_bottom}' to be one of '#{valid}'"
588
- end
589
-
590
- valid = [:split, :undocked, :docked]
591
- unless valid.include? mode
592
- raise "expected '#{mode}' to be one of '#{valid}'"
593
- end
594
-
595
- hash = {:split => {:top => 'Merge',
596
- :bottom => 'Dock and Merge'},
597
- :undocked => {:top => 'Dock',
598
- :bottom => 'Split'},
599
- :docked => {:top => 'Undock',
600
- :bottom => 'Split'}}
601
- mark = hash[mode][top_or_bottom]
602
- "label marked:'#{mark}'"
603
- end
604
-
605
- # @!visibility private
606
- # Returns a query for touching the iPad keyboard mode key.
607
- #
608
- # The mode key is also know as the 'Hide keyboard' key.
609
- #
610
- # @note
611
- # This is only available when running outside of instruments. Use
612
- # ` _point_for_ipad_keyboard_mode_key` when the app is _not_ launched
613
- # with instruments.
614
- #
615
- # raises an error when
616
- # * the device is not an iPad
617
- # * the app was launched with Instruments i.e. there is a <tt>run_loop</tt>
618
- def _query_for_keyboard_mode_key
619
- raise 'cannot detect keyboard mode key on iphone' if device_family_iphone?
620
- if uia_available?
621
- raise "UIA is available, use '_point_for_keyboard_mode_key' instead"
622
- end
623
- qstr = "view:'UIKBKeyView'"
624
- idx = query(qstr).count - 1
625
- "#{qstr} index:#{idx}"
626
- end
627
-
628
519
  # @!visibility private
629
520
  # Touches the bottom option on the popup dialog that is presented when the
630
521
  # the iPad keyboard `mode` key is touched and held.
@@ -633,19 +524,12 @@ module Calabash
633
524
  #
634
525
  # The `mode` key allows the user to undock, dock, or split the keyboard.
635
526
  def _touch_bottom_keyboard_mode_row
636
- mode = ipad_keyboard_mode
637
- if uia_available?
638
- start_pt = _point_for_ipad_keyboard_mode_key
639
- # there are 10 pt btw the key and the popup and the row is 50 pt
640
- y_offset = 10 + 25
641
- end_pt = {:x => (start_pt[:x] - 40), :y => (start_pt[:y] - y_offset)}
642
- uia_pan_offset(start_pt, end_pt, {})
643
- else
644
- pan(_query_for_keyboard_mode_key, nil, {:duration => 1.0})
645
- touch(_query_for_touch_for_keyboard_mode_option(:bottom, mode))
646
- sleep(0.5)
647
- end
648
- 2.times { sleep(0.5) }
527
+ start_pt = _point_for_ipad_keyboard_mode_key
528
+ # there are 10 pt btw the key and the popup and the row is 50 pt
529
+ y_offset = 10 + 25
530
+ end_pt = {:x => (start_pt[:x] - 40), :y => (start_pt[:y] - y_offset)}
531
+ uia_pan_offset(start_pt, end_pt, {})
532
+ sleep(1.0)
649
533
  end
650
534
 
651
535
  # Touches the top option on the popup dialog that is presented when the
@@ -655,23 +539,15 @@ module Calabash
655
539
  #
656
540
  # The `mode` key allows the user to undock, dock, or split the keyboard.
657
541
  def _touch_top_keyboard_mode_row
658
- mode = ipad_keyboard_mode
659
- if uia_available?
660
- start_pt = _point_for_ipad_keyboard_mode_key
661
- # there are 10 pt btw the key and the popup and each row is 50 pt
662
- # NB: no amount of offsetting seems to allow touching the top row
663
- # when the keyboard is split
664
-
665
- x_offset = 40
666
- y_offset = 10 + 50 + 25
667
- end_pt = {:x => (start_pt[:x] - x_offset), :y => (start_pt[:y] - y_offset)}
668
- uia_pan_offset(start_pt, end_pt, {:duration => 1.0})
669
- else
670
- pan(_query_for_keyboard_mode_key, nil, {})
671
- touch(_query_for_touch_for_keyboard_mode_option(:top, mode))
672
- sleep(0.5)
673
- end
674
- 2.times { sleep(0.5) }
542
+ start_pt = _point_for_ipad_keyboard_mode_key
543
+ # there are 10 pt btw the key and the popup and each row is 50 pt
544
+ # NB: no amount of offsetting seems to allow touching the top row
545
+ # when the keyboard is split
546
+
547
+ x_offset = 40
548
+ y_offset = 10 + 50 + 25
549
+ end_pt = {:x => (start_pt[:x] - x_offset), :y => (start_pt[:y] - y_offset)}
550
+ uia_pan_offset(start_pt, end_pt, {:duration => 1.0})
675
551
  end
676
552
 
677
553
  # Ensures that the iPad keyboard is docked.
@@ -847,9 +723,6 @@ module Calabash
847
723
  #
848
724
  # @raise [RuntimeError] if the app was not launched with instruments
849
725
  def uia_keyboard_visible?
850
- unless uia_available?
851
- screenshot_and_raise 'only available if there is a run_loop i.e. the app was launched with Instruments'
852
- end
853
726
  res = uia_query_windows(:keyboard)
854
727
  not res.eql?(':nil')
855
728
  end
@@ -865,9 +738,6 @@ module Calabash
865
738
  #
866
739
  # @raise [RuntimeError] if the app was not launched with instruments
867
740
  def uia_wait_for_keyboard(opts={})
868
- unless uia_available?
869
- screenshot_and_raise 'only available if there is a run_loop i.e. the app was launched with Instruments'
870
- end
871
741
  default_opts = {:timeout => 10,
872
742
  :retry_frequency => 0.1,
873
743
  :post_timeout => 0.5}
@@ -82,7 +82,7 @@ module Calabash
82
82
  else
83
83
  msg << "Not attached to instruments."
84
84
  msg << "Start your app with `start_test_server_in_background`"
85
- msg << "If you app is already running, try `console_attach`"
85
+ msg << "If your app is already running, try `console_attach`"
86
86
  end
87
87
  msg.join("\n")
88
88
  end
@@ -82,20 +82,23 @@ module Calabash
82
82
  :arguments => method_args
83
83
  }
84
84
 
85
- res = Map.new.http({:method => :post, :path => 'map'},
86
- {:query => query, :operation => operation_map})
87
- res = JSON.parse(res)
88
- if res['outcome'] != 'SUCCESS'
85
+ route = {:method => :post, :path => "map"}
86
+ parameters = {:query => query,
87
+ :operation => operation_map}
88
+ body = self.map_factory.http(route, parameters)
89
+
90
+ hash = JSON.parse(body)
91
+ if hash["outcome"] != "SUCCESS"
89
92
  message = %Q[
90
93
  map #{query}, #{method_name} failed for:
91
94
 
92
- reason: #{res["reason"]}
93
- details: #{res["details"]}
95
+ reason: #{hash["reason"]}
96
+ details: #{hash["details"]}
94
97
  ]
95
- Map.new.screenshot_and_raise(message)
98
+ self.map_factory.screenshot_and_raise(message)
96
99
  end
97
100
 
98
- res
101
+ hash
99
102
  end
100
103
 
101
104
  # Asserts the result of a calabash `map` call and raises an error with
@@ -139,6 +142,12 @@ details: #{res["details"]}
139
142
  Map.new.screenshot_and_raise msg
140
143
  end
141
144
  end
145
+
146
+ private
147
+
148
+ def self.map_factory
149
+ Map.new
150
+ end
142
151
  end
143
152
  end
144
153
  end
@@ -12,11 +12,20 @@ module Calabash
12
12
  # @param {String} command the JavaScript snippet to execute
13
13
  # @return {Object} the result returned by the UIA process
14
14
  def uia(command, options={})
15
+ raise ArgumentError, "Please supply :command" unless command
16
+
15
17
  # UIA only makes sense if there is a run loop
16
18
  launcher = Calabash::Cucumber::Launcher.launcher_if_used
17
19
  run_loop = launcher && launcher.active? && launcher.run_loop
18
- raise ArgumentError, 'the current launcher must be active and be attached to a run_loop' unless run_loop
19
- raise ArgumentError, 'please supply :command' unless command
20
+
21
+ # Automatically attach in the calabash console
22
+ if !run_loop && defined?(IRB)
23
+ RunLoop.log_debug("Attaching to current instruments process...")
24
+ launcher = Calabash::Cucumber::Launcher.new
25
+ Calabash::Cucumber::Launcher.attach
26
+ run_loop = launcher.run_loop
27
+ RunLoop.log_debug("Attached!")
28
+ end
20
29
 
21
30
  strategy = run_loop[:uia_strategy]
22
31
  case strategy
@@ -3,10 +3,10 @@ module Calabash
3
3
 
4
4
  # @!visibility public
5
5
  # The Calabash iOS gem version.
6
- VERSION = "0.19.0"
6
+ VERSION = "0.19.1"
7
7
 
8
8
  # @!visibility public
9
9
  # The minimum required version of the Calabash embedded server.
10
- MIN_SERVER_VERSION = "0.19.0"
10
+ MIN_SERVER_VERSION = "0.19.1"
11
11
  end
12
12
  end
@@ -34,8 +34,9 @@ IRB.conf[:HISTORY_FILE] = ".irb-history"
34
34
 
35
35
  begin
36
36
  require "pry"
37
- Pry.config.history.should_save = false
38
- Pry.config.history.should_load = false
37
+ Pry.config.history.should_save = true
38
+ Pry.config.history.should_load = true
39
+ Pry.config.history.file = ".pry-history"
39
40
  require "pry-nav"
40
41
  rescue LoadError => _
41
42
 
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2016-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -132,7 +132,7 @@ dependencies:
132
132
  requirements:
133
133
  - - ">="
134
134
  - !ruby/object:Gem::Version
135
- version: 2.1.1
135
+ version: 2.1.2
136
136
  - - "<"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3.0'
@@ -142,7 +142,7 @@ dependencies:
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 2.1.1
145
+ version: 2.1.2
146
146
  - - "<"
147
147
  - !ruby/object:Gem::Version
148
148
  version: '3.0'
@@ -314,6 +314,20 @@ dependencies:
314
314
  - - ">="
315
315
  - !ruby/object:Gem::Version
316
316
  version: '0'
317
+ - !ruby/object:Gem::Dependency
318
+ name: listen
319
+ requirement: !ruby/object:Gem::Requirement
320
+ requirements:
321
+ - - '='
322
+ - !ruby/object:Gem::Version
323
+ version: 3.0.6
324
+ type: :development
325
+ prerelease: false
326
+ version_requirements: !ruby/object:Gem::Requirement
327
+ requirements:
328
+ - - '='
329
+ - !ruby/object:Gem::Version
330
+ version: 3.0.6
317
331
  - !ruby/object:Gem::Dependency
318
332
  name: growl
319
333
  requirement: !ruby/object:Gem::Requirement
@@ -449,7 +463,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
449
463
  version: '0'
450
464
  requirements: []
451
465
  rubyforge_project:
452
- rubygems_version: 2.5.2
466
+ rubygems_version: 2.5.1
453
467
  signing_key:
454
468
  specification_version: 4
455
469
  summary: Client for calabash-ios-server for automated functional testing on iOS