From c8ae26d6c9c400c5f40c3d1b620a3a5ba09c5932 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sat, 25 Mar 2017 16:38:36 +0900 Subject: [PATCH] Add some android commands (#517) * add commands * fix rubocop * add documentations * update some comments --- .../lib/android/specs/common/command.rb | 3 +++ .../lib/android/specs/common/device.rb | 12 +++++++++ lib/appium_lib/common/command.rb | 3 +++ lib/appium_lib/device/device.rb | 26 ++++++++++++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/android_tests/lib/android/specs/common/command.rb b/android_tests/lib/android/specs/common/command.rb index 0b423ded..382a4c04 100644 --- a/android_tests/lib/android/specs/common/command.rb +++ b/android_tests/lib/android/specs/common/command.rb @@ -20,6 +20,9 @@ def before_first Selenium::WebDriver::Remote::Bridge.method_defined?(:get_network_connection).must_equal true Selenium::WebDriver::Remote::Bridge.method_defined?(:get_performance_data_types).must_equal true Selenium::WebDriver::Remote::Bridge.method_defined?(:get_performance_data).must_equal true + Selenium::WebDriver::Remote::Bridge.method_defined?(:get_system_bars).must_equal true + Selenium::WebDriver::Remote::Bridge.method_defined?(:get_display_density).must_equal true + Selenium::WebDriver::Remote::Bridge.method_defined?(:is_keyboard_shown).must_equal true end t 'check all command with arg' do diff --git a/android_tests/lib/android/specs/common/device.rb b/android_tests/lib/android/specs/common/device.rb index bcc6ddac..814aa523 100644 --- a/android_tests/lib/android/specs/common/device.rb +++ b/android_tests/lib/android/specs/common/device.rb @@ -23,6 +23,18 @@ Date.parse(device_time) end + t 'get_system_bars' do + get_system_bars + end + + t 'get_display_density' do + (get_display_density > 0).must_equal true + end + + t 'system_bars' do + is_keyboard_shown.must_equal false + end + t 'background_app' do wait { background_app 5 } end diff --git a/lib/appium_lib/common/command.rb b/lib/appium_lib/common/command.rb index 0bd45469..20694eba 100644 --- a/lib/appium_lib/common/command.rb +++ b/lib/appium_lib/common/command.rb @@ -13,6 +13,9 @@ module Commands open_notifications: [:post, 'session/:session_id/appium/device/open_notifications'.freeze], toggle_airplane_mode: [:post, 'session/:session_id/appium/device/toggle_airplane_mode'.freeze], current_activity: [:get, 'session/:session_id/appium/device/current_activity'.freeze], + get_system_bars: [:get, 'session/:session_id/appium/device/system_bars'.freeze], + get_display_density: [:get, 'session/:session_id/appium/device/display_density'.freeze], + is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'.freeze], get_network_connection: [:get, 'session/:session_id/network_connection'.freeze], get_performance_data_types: [:post, 'session/:session_id/appium/performanceData/types'.freeze], diff --git a/lib/appium_lib/device/device.rb b/lib/appium_lib/device/device.rb index d3c76966..66861044 100644 --- a/lib/appium_lib/device/device.rb +++ b/lib/appium_lib/device/device.rb @@ -23,6 +23,30 @@ module Device # @!method current_activity + # @!method get_system_bars + # Get system bar's information + # @return [String] System bar + # + # ```ruby + # get_system_bars + # ``` + + # @!method get_display_density + # Get connected device's density. + # @return [Integer] The size of density + # + # ```ruby + # get_display_density # 320 + # ``` + + # @!method is_keyboard_shown + # Get whether keyboard is displayed or not. + # @return [Bool] Return true if keyboard is shown. Return false if keyboard is hidden. + # + # ```ruby + # is_keyboard_shown # false + # ``` + # @!method launch_app # Start the simulator and application configured with desired capabilities @@ -538,7 +562,7 @@ def ime_deactivate # @return [String] The context currently being used. # @!method available_contexts - # @return [Array] All usable contexts, as an array of strings. + # @return [Array] All usable contexts, as an array of strings. # Perform a block within the given context, then switch back to the starting context. # @param context (String) The context to switch to for the duration of the block.