[test] Make iOS UI helper search from the key window instead.

Fixes http://hipbyte.myjetbrains.com/youtrack/issue/RM-382.
This commit is contained in:
Eloy Durán
2014-01-16 12:06:31 +01:00
committed by Watson
parent ba64b5644b
commit 16c19e5a20
2 changed files with 24 additions and 9 deletions

View File

@@ -288,12 +288,12 @@ module Bacon
def view(label)
return label if label.is_a?(UIView)
window.viewByName(label) ||
UIApplication.sharedApplication.keyWindow.viewByName(label) ||
raise(Bacon::Error.new(:error, "Unable to find a view with label `#{label}'"))
end
def views(view_class)
views = window.viewsByClass(view_class)
views = UIApplication.sharedApplication.keyWindow.viewsByClass(view_class)
if views.empty?
raise(Bacon::Error.new(:error, "Unable to find any view of class `#{view_class.name}'"))
end
@@ -520,12 +520,6 @@ module Bacon
[from, to]
end
def _view(accessibilityLabel, error_message = nil)
return accessibilityLabel if accessibilityLabel.is_a?(UIView)
window.viewByName(accessibilityLabel) ||
raise(Bacon::Error.new(:error, error_message || "Unable to find a view with label `#{accessibilityLabel}'"))
end
# This class wraps a block that will be executed on a GCD queue, but will
# halt the main thread's call stack (while still handling the main thread's
# runloop) until the block has completely finished its work.