briar 0.1.3.b7 → 0.1.3.b8

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: 64cfb8af1d1f6f49f08a52b1ad05ddea03652fa6
4
- data.tar.gz: 153e16ff005812af6f6f7c6442ff1b169ad86a2b
3
+ metadata.gz: d41c3feb1feec357d18d6bf4309999c248b8d664
4
+ data.tar.gz: 83235a9761d72557bfe0527f6c10741fd1c0bd9c
5
5
  SHA512:
6
- metadata.gz: eba1da164fd5b0d7e2f58c5a36432ea7a2119bc8f581be538c97aa21339868df381fa47dd9ac45108ec0f7500f8a555d0c1a01bb4b5fea38d47cdb0c05aa7021
7
- data.tar.gz: 181817f3977856a0d2b9cb30171d1a77d42733be2e081275559987bf74ac1988f290ba61fab7de6ac4a218de5985fd59ee0b3f29a6adb42785cf3c4410be8b42
6
+ metadata.gz: 021631be2fb7f87bd3128da2990acecbae0cd4b56535dd9702483772e3fc719f3fb271a37311ba5fa5aab9673cfd62a9f579a53b3e4fb16fb59c838f7fec9800
7
+ data.tar.gz: 62a149922a64cf8e2ac6912cb2ef84b8152eaef9017389e1c3558c055189f613e31746389a2e8c9ef4d584810aa508693e3b677342ced1067e2b4da1f881fe18
data/README.md CHANGED
@@ -33,6 +33,9 @@ require 'briar/cucumber'
33
33
  I18n.enforce_available_locales = false
34
34
  ```
35
35
 
36
+ To integrate briar and your calabash-ios console see: https://github.com/jmoody/briar/wiki/Integrating-Briar-Into-Your-Calabash-Console
37
+
38
+
36
39
  ## Xamarin Test Cloud
37
40
 
38
41
  There is currently an issue with using briar predefined steps on the XTC:
data/briar.gemspec CHANGED
@@ -25,10 +25,12 @@ Gem::Specification.new do |gem|
25
25
  gem.platform = Gem::Platform::RUBY
26
26
  gem.required_ruby_version = '>= 1.8.7'
27
27
 
28
- gem.add_runtime_dependency 'rbx-require-relative', "~> 0.0.9"
28
+ gem.add_runtime_dependency 'rbx-require-relative', '~> 0.0.9'
29
29
  gem.add_runtime_dependency 'calabash-cucumber', '>= 0.9.164'
30
30
  gem.add_runtime_dependency 'rake', '~>10.1'
31
- gem.add_runtime_dependency 'syntax', '~>1.2'
31
+ # downgrading to 1.0.0 from 1.2.0
32
+ # https://trello.com/c/YKREVfCX/630-lesspainfulformatter-should-depend-on-syntax-1-2-0
33
+ gem.add_runtime_dependency 'syntax', '~>1.0.0'
32
34
 
33
35
  gem.files = `git ls-files`.split("\n") - ['.gitignore']
34
36
  gem.executables = 'briar'
data/lib/briar.rb CHANGED
@@ -75,3 +75,6 @@ require 'briar/scroll_view'
75
75
  require 'briar/table'
76
76
  require 'briar/text_field'
77
77
  require 'briar/text_view'
78
+
79
+ require 'briar/page/briar_page_helpers'
80
+ require 'briar/page/briar_page'
@@ -1,3 +1,4 @@
1
+ #noinspection RubyResolve
1
2
  require 'calabash-cucumber'
2
3
 
3
4
  module Briar
@@ -49,6 +50,7 @@ module Briar
49
50
  }
50
51
  end
51
52
 
53
+ # todo refactor should_see_view_with_center to wait for view
52
54
  def should_see_view_with_center(view_id, center_ht)
53
55
  res = query("view marked:'#{view_id}'").first
54
56
  if res.nil?
@@ -69,13 +71,18 @@ module Briar
69
71
  end
70
72
  end
71
73
 
72
- def touch_view_named(view_id)
74
+ def touch_view(view_id)
73
75
  wait_for_view view_id
74
76
  touch("view marked:'#{view_id}'")
75
77
  end
76
78
 
79
+ def touch_view_named(view_id)
80
+ _deprecated('0.1.3', "use 'touch_view' instead", :warn)
81
+ touch_view(view_id)
82
+ end
83
+
77
84
  def touch_and_wait_for_view(view_id, view_to_wait_for, timeout=BRIAR_WAIT_TIMEOUT)
78
- touch_view_named(view_id)
85
+ touch_view(view_id)
79
86
  wait_for_view(view_to_wait_for, timeout)
80
87
  end
81
88
 
@@ -152,7 +159,7 @@ module Briar
152
159
  end
153
160
 
154
161
  def touch_and_wait_to_disappear(view_id, timeout=BRIAR_WAIT_TIMEOUT)
155
- touch_view_named(view_id)
162
+ touch_view(view_id)
156
163
  wait_for_view_to_disappear view_id, timeout
157
164
  end
158
165
 
@@ -68,8 +68,17 @@ module Briar
68
68
  :timeout_message => msg) do
69
69
  button_exists? button_id
70
70
  end
71
- should_see_button_with_title(button_id, title)
71
+ res = query("button descendant view {text LIKE '#{title}'")
72
+ if res.empty?
73
+ screenshot_and_raise "expected button '#{button_id}' to have title '#{title}'"
74
+ end
75
+ end
76
+
77
+ def touch_button_with_title(button_id, title, timeout=BRIAR_WAIT_TIMEOUT)
78
+ wait_for_button_with_title button_id, title, timeout
79
+ touch("button marked:'#{button_id}'")
72
80
  end
81
+
73
82
  end
74
83
  end
75
84
  end
@@ -27,30 +27,43 @@ World(Briar::ScrollView)
27
27
  World(Briar::Table)
28
28
  World(Briar::TextField)
29
29
  World(Briar::TextView)
30
+ World(Briar::Page::Helpers)
30
31
 
32
+ # briar predefined steps are not found during the XTC validation phase
33
+ #
34
+ # they are, however, correctly exposed because if you copy them to the
35
+ # step_definitions directory as part of the XTC submission, you will see
36
+ # Cucumber:Ambiguous errors
37
+ #
38
+ # so the strategy to is avoid loading the step definitions when running on the
39
+ # XTC and copying them to the features/step_definitions directory during the
40
+ # XTC job submission.
41
+ #
42
+ # see the xamarin-build.sh script
43
+ unless ENV['XAMARIN_TEST_CLOUD'] == '1'
44
+ require_relative '../../features/step_definitions/alerts_and_sheets/action_sheet_steps'
45
+ require_relative '../../features/step_definitions/alerts_and_sheets/alert_view_steps'
31
46
 
32
- require_relative '../../features/step_definitions/alerts_and_sheets/action_sheet_steps'
33
- require_relative '../../features/step_definitions/alerts_and_sheets/alert_view_steps'
47
+ require_relative '../../features/step_definitions/bars/tabbar_steps'
48
+ require_relative '../../features/step_definitions/bars/navbar_steps'
49
+ require_relative '../../features/step_definitions/bars/toolbar_steps'
34
50
 
35
- require_relative '../../features/step_definitions/bars/tabbar_steps'
36
- require_relative '../../features/step_definitions/bars/navbar_steps'
37
- require_relative '../../features/step_definitions/bars/toolbar_steps'
51
+ require_relative '../../features/step_definitions/control/button_steps'
52
+ require_relative '../../features/step_definitions/control/segmented_control_steps'
53
+ require_relative '../../features/step_definitions/control/slider_steps'
38
54
 
39
- require_relative '../../features/step_definitions/control/button_steps'
40
- require_relative '../../features/step_definitions/control/segmented_control_steps'
41
- require_relative '../../features/step_definitions/control/slider_steps'
42
55
 
56
+ require_relative '../../features/step_definitions/picker/picker_steps'
57
+ require_relative '../../features/step_definitions/picker/date_picker_steps'
43
58
 
44
- require_relative '../../features/step_definitions/picker/picker_steps'
45
- require_relative '../../features/step_definitions/picker/date_picker_steps'
46
59
 
60
+ require_relative '../../features/step_definitions/email_steps'
61
+ require_relative '../../features/step_definitions/image_view_steps'
62
+ require_relative '../../features/step_definitions/keyboard_steps'
63
+ require_relative '../../features/step_definitions/label_steps'
64
+ require_relative '../../features/step_definitions/scroll_view_steps'
47
65
 
48
- require_relative '../../features/step_definitions/email_steps'
49
- require_relative '../../features/step_definitions/image_view_steps'
50
- require_relative '../../features/step_definitions/keyboard_steps'
51
- require_relative '../../features/step_definitions/label_steps'
52
- require_relative '../../features/step_definitions/scroll_view_steps'
53
-
54
- require_relative '../../features/step_definitions/table_steps'
55
- require_relative '../../features/step_definitions/text_field_steps'
56
- require_relative '../../features/step_definitions/text_view_steps'
66
+ require_relative '../../features/step_definitions/table_steps'
67
+ require_relative '../../features/step_definitions/text_field_steps'
68
+ require_relative '../../features/step_definitions/text_view_steps'
69
+ end
data/lib/briar/email.rb CHANGED
@@ -162,7 +162,7 @@ module Briar
162
162
  :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
163
163
  :post_timeout => BRIAR_WAIT_STEP_PAUSE,
164
164
  :timeout_message => msg) do
165
- uia_element_exists?(:view, {:marked => 'Delete Draft'})
165
+ uia_element_exists?(:view, {:marked => 'Delete Draft'})
166
166
  end
167
167
 
168
168
  uia_tap_mark('Delete Draft')
@@ -180,11 +180,9 @@ module Briar
180
180
  screenshot_and_raise 'UIA needs to be available'
181
181
  end
182
182
 
183
- res = uia_query(:view, {:marked => 'To:'}).first
184
- rect = res['rect']
185
- point = {:x => rect['x'] + (2 * rect['width']),
186
- :y => rect['y']}
187
- uia_touch_with_options(point)
183
+ # with predicate
184
+ # uia_tap(:textField, {[:label, :beginswith] => "'To:'"})
185
+ uia_tap(:textField, marked:'toField')
188
186
  uia_wait_for_keyboard if opts[:wait_for_keyboard]
189
187
  end
190
188
 
@@ -0,0 +1,199 @@
1
+ require 'rubygems'
2
+ require 'irb/completion'
3
+ require 'irb/ext/save-history'
4
+ require 'awesome_print'
5
+ AwesomePrint.irb!
6
+
7
+ require 'require_relative'
8
+
9
+ #noinspection RubyUnusedLocalVariable
10
+ def World(*world_modules, &proc)
11
+ world_modules.each { |mod|
12
+ include mod
13
+ puts "loaded '#{mod}'"
14
+ }
15
+ end
16
+
17
+
18
+ ARGV.concat [ '--readline',
19
+ '--prompt-mode',
20
+ 'simple']
21
+
22
+ # 25 entries in the list
23
+ IRB.conf[:SAVE_HISTORY] = 50
24
+
25
+ # Store results in home directory with specified file name
26
+ IRB.conf[:HISTORY_FILE] = '.irb-history'
27
+
28
+ require 'calabash-cucumber'
29
+ require 'calabash-cucumber/operations'
30
+ require 'calabash-cucumber/launch/simulator_helper'
31
+ require 'calabash-cucumber/launcher'
32
+
33
+ SIM=Calabash::Cucumber::SimulatorHelper
34
+
35
+ extend Calabash::Cucumber::Operations
36
+
37
+ def embed(x,y=nil,z=nil)
38
+ puts "Screenshot at #{x}"
39
+ end
40
+
41
+ puts 'loaded calabash'
42
+
43
+ include Briar::Bars
44
+ include Briar::Alerts_and_Sheets
45
+ include Briar::Control::Button
46
+ include Briar::Control::Segmented_Control
47
+ include Briar::Control::Slider
48
+ include Briar::Picker
49
+ include Briar::Picker_Shared
50
+ include Briar::Picker::DateCore
51
+ include Briar::Picker::DateManipulation
52
+ include Briar::Picker::DateSteps
53
+ include Briar::Core
54
+ include Briar::UIA
55
+ include Briar::UIA::IPadEmulation
56
+ include Briar::Table
57
+ include Briar::ImageView
58
+ include Briar::Label
59
+ include Briar::Keyboard
60
+ include Briar::UIAKeyboard
61
+ include Briar::UIAKeyboard::Numeric
62
+ include Briar::UIAKeyboard::Language
63
+ include Briar::Email
64
+ include Briar::TextField
65
+ include Briar::TextView
66
+ include Briar::Page::Helpers
67
+
68
+
69
+ @ai=:accessibilityIdentifier
70
+ @al=:accessibilityLabel
71
+
72
+ def print_marks(marks, max_width)
73
+ counter = -1
74
+ marks.sort.each { |elm|
75
+ printf("%4s %#{max_width + 2}s => %s\n", "[#{counter = counter + 1}]", elm[0], elm[1])
76
+ }
77
+ end
78
+
79
+ def accessibility_marks(kind, opts={})
80
+ opts = {:print => true, :return => false}.merge(opts)
81
+
82
+ kinds = [:id, :label]
83
+ raise "'#{kind}' is not one of '#{kinds}'" unless kinds.include?(kind)
84
+
85
+ res = Array.new
86
+ max_width = 0
87
+ query('*').each { |view|
88
+ aid = view[kind.to_s]
89
+ unless aid.nil? or aid.eql?('')
90
+ cls = view['class']
91
+ len = cls.length
92
+ max_width = len if len > max_width
93
+ res << [cls, aid]
94
+ end
95
+ }
96
+ print_marks(res, max_width) if opts[:print]
97
+ opts[:return] ? res : nil
98
+ end
99
+
100
+ def text_marks(opts={})
101
+ opts = {:print => true, :return => false}.merge(opts)
102
+
103
+ indexes = Array.new
104
+ idx = 0
105
+ all_texts = query('*', :text)
106
+ all_texts.each { |view|
107
+ indexes << idx unless view.eql?('*****') or view.eql?('')
108
+ idx = idx + 1
109
+ }
110
+
111
+ res = Array.new
112
+
113
+ all_views = query('*')
114
+ max_width = 0
115
+ indexes.each { |index|
116
+ view = all_views[index]
117
+ cls = view['class']
118
+ text = all_texts[index]
119
+ len = cls.length
120
+ max_width = len if len > max_width
121
+ res << [cls, text]
122
+ }
123
+
124
+ print_marks(res, max_width) if opts[:print]
125
+ opts[:return] ? res : nil
126
+ end
127
+
128
+
129
+ def ids
130
+ accessibility_marks(:id)
131
+ end
132
+
133
+ def labels
134
+ accessibility_marks(:label)
135
+ end
136
+
137
+ def text
138
+ text_marks
139
+ end
140
+
141
+ def marks
142
+ opts = {:print => false, :return => true }
143
+ res = accessibility_marks(:id, opts).each { |elm|elm << :ai }
144
+ res.concat(accessibility_marks(:label, opts).each { |elm| elm << :al })
145
+ res.concat(text_marks(opts).each { |elm| elm << :text })
146
+ max_width = 0
147
+ res.each { |elm|
148
+ len = elm[0].length
149
+ max_width = len if len > max_width
150
+ }
151
+
152
+ counter = -1
153
+ res.sort.each { |elm|
154
+ printf("%4s %-4s => %#{max_width}s => %s\n",
155
+ "[#{counter = counter + 1}]",
156
+ elm[2], elm[0], elm[1])
157
+ }
158
+ nil
159
+ end
160
+
161
+ def nbl
162
+ query('navigationButton', :accessibilityLabel)
163
+ end
164
+
165
+ def row_ids
166
+ query('tableViewCell', @ai).compact.sort.each {|x| puts "* #{x}" }
167
+ end
168
+
169
+ def puts_calabash_environment
170
+
171
+ puts ''
172
+ puts "loaded #{Dir.pwd}/.irbrc"
173
+ puts ''
174
+ puts " DEVICE_ENDPOINT => '#{ENV['DEVICE_ENDPOINT']}'"
175
+ puts " DEVICE_TARGET => '#{ENV['DEVICE_TARGET']}'"
176
+ puts " DEVICE => '#{ENV['DEVICE']}'"
177
+ puts " BUNDLE_ID => '#{ENV['BUNDLE_ID']}'"
178
+ puts " PLAYBACK_DIR => '#{ENV['PLAYBACK_DIR']}'"
179
+ puts " SCREENSHOT_PATH => '#{ENV['SCREENSHOT_PATH']}'"
180
+ puts " SDK_VERSION => '#{ENV['SDK_VERSION']}'"
181
+ puts "CALABASH_FULL_CONSOLE_OUTPUT => '#{ENV['CALABASH_FULL_CONSOLE_OUTPUT']}'"
182
+ puts " DEBUG => '#{ENV['DEBUG']}'"
183
+ puts ''
184
+ puts '*** useful functions defined in .irbrc ***'
185
+ puts '> ids => all accessibilityIdentifiers'
186
+ puts '> labels => all accessibilityLabels'
187
+ puts '> text => all text'
188
+ puts '> row_ids => all tableViewCell accessibilityIdentifiers'
189
+ puts ''
190
+ end
191
+
192
+ def briar_message_of_the_day
193
+ motd=["Let's get this done!", 'Ready to rumble.', 'Enjoy.', 'Remember to breathe.',
194
+ 'Take a deep breath.', "Isn't it time for a break?", 'Can I get you a coffee?',
195
+ 'What is a calabash anyway?', 'Smile! You are on camera!', 'Let op! Wild Rooster!',
196
+ "Don't touch that button!", "I'm gonna take this to 11.", 'Console. Engaged.',
197
+ 'Your wish is my command.', 'This console session was created just for you.']
198
+ puts "#{motd.sample}"
199
+ end
@@ -0,0 +1,55 @@
1
+ require 'calabash-cucumber/ibase'
2
+
3
+ # extends Calabash::IBase
4
+ class BriarPage < Calabash::IBase
5
+
6
+ def initialize(world, transition_duration=BRIAR_WAIT_STEP_PAUSE)
7
+ super(world, transition_duration)
8
+ end
9
+
10
+ # returns a query string that can be used by +trait+ method to create a
11
+ # query string based on the mark
12
+ #
13
+ # accepts the following options:
14
+ # +:ui_class+ - defaults to <tt>'view'</tt>
15
+ # +:is_custom_class+ - defaults to +false+
16
+ #
17
+ # raises an exception if +:is_custom+ is +true+ and +:ui_class+ is
18
+ # <tt>'view'</tt> - set the +:ui_class+ to your custom class name
19
+ def qstr_for_trait(mark, opts={})
20
+ default_opts = {:ui_class => 'view',
21
+ :is_custom => false}
22
+ opts = default_opts.merge(opts)
23
+
24
+ ui_class = opts[:ui_class]
25
+ is_custom = opts[:is_custom]
26
+
27
+ if is_custom and ui_class.eql?('view')
28
+ raise "if is_custom is 'true' than ui_class should not be '#{view}'"
29
+ end
30
+
31
+ if opts[:is_custom]
32
+ view = "view:'#{opts[:is_custom]}'"
33
+ else
34
+ view = ui_class
35
+ end
36
+
37
+ "#{view} marked:'#{mark}'"
38
+ end
39
+
40
+ # returns the mark for this page
41
+ #
42
+ # raises an exception if subclass does not implement
43
+ def mark
44
+ raise "subclasses must implement the 'mark' method"
45
+ end
46
+
47
+ def trait
48
+ qstr_for_trait(mark)
49
+ end
50
+
51
+ def page_visible?
52
+ view_exists?(mark)
53
+ end
54
+
55
+ end
@@ -0,0 +1,35 @@
1
+ module Briar
2
+ module Page
3
+ module Helpers
4
+
5
+ # returns +true+ if +current_page+ is an instance of +page_class+
6
+ #
7
+ # the +current_page+ argument defaults to the +@cp+ World variable
8
+ def cp_is?(page_class, current_page=@cp)
9
+ current_page.is_a?(page_class)
10
+ end
11
+
12
+ # raises a exception if the +current_page+ is not an instance of
13
+ # +page_class+
14
+ #
15
+ # the +current_page+ argument defaults to the +@cp+ World variable
16
+ def expect_current_page(page_class, current_page=@cp)
17
+ unless cp_is? page_class, current_page
18
+ screenshot_and_raise "expected current page to be '#{page_class}' but found '#{current_page}'"
19
+ end
20
+ end
21
+
22
+ # raises an exception if the +current_page+ is not an instance of any of
23
+ # +page_classes+
24
+ #
25
+ # the +current_page+ argument defaults to the +@cp+ World variable
26
+ def expect_current_page_is_one_of(page_classes, current_page=@cp)
27
+ res = page_classes.any? { |page_class| cp_is?(page_class, current_page) }
28
+ unless res
29
+ screenshot_and_raise "expected current page to be on of these '#{page_classes}' pages but found '#{current_page}'"
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -74,14 +74,6 @@ module Briar
74
74
  end
75
75
  end
76
76
 
77
-
78
- def is_iphone_app_emulated_on_ipad?(cache=Cache.new)
79
- return false unless ipad?
80
- idx = window_index_of_ipad_1x_2x_button({:raise_if_not_found => false,
81
- :cache => cache})
82
- idx != -1
83
- end
84
-
85
77
  def window_index_of_ipad_1x_2x_button(opts={})
86
78
 
87
79
  default_opts = {:language_code => :en,
@@ -143,8 +135,8 @@ module Briar
143
135
  end
144
136
 
145
137
  cache = Cache.new
146
- #noinspection RubyParenthesesAfterMethodCallInspection
147
- return unless is_iphone_app_emulated_on_ipad?(cache)
138
+
139
+ return unless iphone_app_emulated_on_ipad?
148
140
 
149
141
  default_opts = {:language_code => :en,
150
142
  :ensure_uia_and_ipad => false,
data/lib/briar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Briar
2
- VERSION = '0.1.3.b7'
2
+ VERSION = '0.1.3.b8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: briar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.b7
4
+ version: 0.1.3.b8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Moody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-15 00:00:00.000000000 Z
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbx-require-relative
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '1.2'
61
+ version: 1.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '1.2'
68
+ version: 1.0.0
69
69
  description: extends calabash-ios steps
70
70
  email:
71
71
  - joshuajmoody@gmail.com
@@ -117,11 +117,14 @@ files:
117
117
  - lib/briar/cucumber.rb
118
118
  - lib/briar/email.rb
119
119
  - lib/briar/image_view.rb
120
+ - lib/briar/irbrc.rb
120
121
  - lib/briar/keyboard/keyboard.rb
121
122
  - lib/briar/keyboard/uia_keyboard.rb
122
123
  - lib/briar/keyboard/uia_keyboard_language.rb
123
124
  - lib/briar/keyboard/uia_numeric_keyboard.rb
124
125
  - lib/briar/label.rb
126
+ - lib/briar/page/briar_page.rb
127
+ - lib/briar/page/briar_page_helpers.rb
125
128
  - lib/briar/picker/date_picker.rb
126
129
  - lib/briar/picker/date_picker_core.rb
127
130
  - lib/briar/picker/date_picker_manipulation.rb
@@ -159,6 +162,6 @@ rubyforge_project:
159
162
  rubygems_version: 2.2.1
160
163
  signing_key:
161
164
  specification_version: 4
162
- summary: briar-0.1.3.b7
165
+ summary: briar-0.1.3.b8
163
166
  test_files:
164
167
  - spec/spec_helper.rb