Permalink
Browse files

Add tests for DSL#select_menu_item

  • Loading branch information...
1 parent 5931a93 commit d8d975d916196906a122e245c7c3580dcee5ba99 @ferrous26 ferrous26 committed Mar 12, 2012
Showing with 44 additions and 0 deletions.
  1. +44 −0 test/integration/accessibility/test_dsl.rb
@@ -19,6 +19,18 @@ def text_area
@@text_area ||= app.main_window.text_area
end
+ def pref_window
+ app.children.find { |x|
+ x.attributes.include?(:title) && x.title == 'Preferences'
+ }
+ end
+
+ def spelling_window
+ app.children.find { |x|
+ x.attributes.include?(:title) && x.title.match(/^Spelling/)
+ }
+ end
+
def try_typing string, expected = nil
expected = string unless expected
text_area.set :focused, to: true
@@ -69,6 +81,38 @@ def test_typing_ruby_escapes
try_typing "First.\nSecond."
end
+ def test_select_menu_item_string
+ assert_nil pref_window
+ dsl.select_menu_item app, app.title, 'Preferences…'
+ window = dsl.wait_for :window, parent: app, title: 'Preferences'
+ refute_nil window
+ ensure
+ window.close_button.perform :press if window
+ end
+
+ def test_select_menu_item_regexp
+ assert_nil spelling_window
+ dsl.select_menu_item app, /Edit/, /Spelling/, /show spelling/i
+ window = dsl.wait_for :floating_window, parent: app
+ refute_nil window
+ ensure
+ window.close_button.perform :press if window
+ end
+
+ def test_select_menu_item_raises_if_cannot_find_item
+ assert_raises Accessibility::SearchFailure do
+ dsl.select_menu_item app, 'File', 'NonExistantMenuItem'
+ end
+ # @todo verify that menu is closed
+ end
+
+ def test_select_menu_item_provides_proper_debug_info
+ e = assert_raises Accessibility::SearchFailure do
+ dsl.select_menu_item app, 'Format', 'Front'
+ end
+ assert_match /MenuItem/, e.message
+ end
+
def test_wait_for_obeys_timeout_option
# loop sleeps for 0.2, so we have to wait at least that long
start = Time.now

0 comments on commit d8d975d

Please sign in to comment.