android_tests/lib/android/specs/common/device.rb in appium_lib-3.0.3 vs android_tests/lib/android/specs/common/device.rb in appium_lib-4.0.0
- old
+ new
@@ -1,5 +1,6 @@
+# rake android[common/device]
describe 'common/device' do
# Not yet implemented
t 'shake' do
# todo: write test
end
@@ -30,63 +31,57 @@
t 'current_activity' do
wait { current_activity.must_equal '.ApiDemos' }
end
- t 'available_contexts' do
- wait { available_contexts.must_equal ['NATIVE_APP'] }
- end
-
- t 'current_context' do
- wait { current_context.must_equal 'NATIVE_APP' }
- end
-
- t 'set_context' do
- wait { scroll_to('Views').click }
- wait { scroll_to('WebView').click }
- wait { set_context 'WEBVIEW' }
- wait { current_context.must_equal 'WEBVIEW_1' }
-
- wait { set_context 'NATIVE_APP' }
- wait { current_context.must_equal 'NATIVE_APP' }
-
- 2.times { back; sleep 1 }
- end
-
- t 'within_context' do
- $driver.within_context 'NATIVE_APP' do
- wait { current_context.must_equal 'NATIVE_APP' }
- end
- end
-
- t 'switch_to_default_context' do
- wait do
- switch_to_default_context
- current_context.must_equal 'NATIVE_APP'
- end
- end
-
t 'app_strings' do
wait_true { app_strings.has_key? 'activity_save_restore' }
end
def must_return_element element
element.class.must_equal Selenium::WebDriver::Element
end
- t 'complex_find' do
- wait { find('Views').click }
- wait { must_return_element complex_find(mode: 'scroll', selectors: [[[3, 'tabs']]]) }
- wait { must_return_element complex_find(mode: 'all', selectors: [[[3, 'i']]]).first }
- wait { must_return_element complex_find(selectors: [[[3, 'tabs']]]) }
- back
+ t 'press_keycode' do
+ # http://developer.android.com/reference/android/view/KeyEvent.html
+ press_keycode 176
end
- t 'key_event' do
- key_event 176
+ t 'long_press_keycode' do
+ # http://developer.android.com/reference/android/view/KeyEvent.html
+ long_press_keycode 176
end
+ t 'open_notifications' do
+ # test & comments from https://github.com/appium/appium/blob/master/test/functional/android/apidemos/notifications-specs.js#L19
+ # get to the notification page
+ wait { scroll_to('App').click }
+ wait { scroll_to('Notification').click }
+ wait { scroll_to('Status Bar').click }
+ # create a notification
+ wait { button(':-|').click }
+ open_notifications
+ # shouldn't see the elements behind shade
+ wait_true { !exists { find(':-|') } }
+ # should see the notification
+ wait_true { text_exact 'Mood ring' }
+ # return to app
+ back
+ # should be able to see elements from app
+ wait_true { button(':-|') }
+
+ # go back, waiting for each page to load.
+ # if we go back using 3.times { back }
+ # then android will flake out and discard some back events
+ back
+ wait { text('Status Bar') }
+ back
+ wait { text('Notification') }
+ back
+ wait { text('App') }
+ end
+
t 'action_chain' do
wait do
e = find_element(:name, 'Accessibility')
Appium::TouchAction.new.press(:element => e, x: 0.5, y: 0.5).release(:element => e).perform
end
@@ -118,7 +113,12 @@
wait do
push_file path, file
read_file = pull_file path
read_file.must_equal file
end
+ end
+
+ t 'pull_folder' do
+ data = pull_folder '/data/local/tmp'
+ data.length.must_be :>, 100
end
end
\ No newline at end of file