Skip to content

Commit c8ae26d

Browse files
authored
Add some android commands (#517)
* add commands * fix rubocop * add documentations * update some comments
1 parent e0db50e commit c8ae26d

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

android_tests/lib/android/specs/common/command.rb

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def before_first
2020
Selenium::WebDriver::Remote::Bridge.method_defined?(:get_network_connection).must_equal true
2121
Selenium::WebDriver::Remote::Bridge.method_defined?(:get_performance_data_types).must_equal true
2222
Selenium::WebDriver::Remote::Bridge.method_defined?(:get_performance_data).must_equal true
23+
Selenium::WebDriver::Remote::Bridge.method_defined?(:get_system_bars).must_equal true
24+
Selenium::WebDriver::Remote::Bridge.method_defined?(:get_display_density).must_equal true
25+
Selenium::WebDriver::Remote::Bridge.method_defined?(:is_keyboard_shown).must_equal true
2326
end
2427

2528
t 'check all command with arg' do

android_tests/lib/android/specs/common/device.rb

+12
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
Date.parse(device_time)
2424
end
2525

26+
t 'get_system_bars' do
27+
get_system_bars
28+
end
29+
30+
t 'get_display_density' do
31+
(get_display_density > 0).must_equal true
32+
end
33+
34+
t 'system_bars' do
35+
is_keyboard_shown.must_equal false
36+
end
37+
2638
t 'background_app' do
2739
wait { background_app 5 }
2840
end

lib/appium_lib/common/command.rb

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ module Commands
1313
open_notifications: [:post, 'session/:session_id/appium/device/open_notifications'.freeze],
1414
toggle_airplane_mode: [:post, 'session/:session_id/appium/device/toggle_airplane_mode'.freeze],
1515
current_activity: [:get, 'session/:session_id/appium/device/current_activity'.freeze],
16+
get_system_bars: [:get, 'session/:session_id/appium/device/system_bars'.freeze],
17+
get_display_density: [:get, 'session/:session_id/appium/device/display_density'.freeze],
18+
is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'.freeze],
1619
get_network_connection: [:get, 'session/:session_id/network_connection'.freeze],
1720
get_performance_data_types: [:post, 'session/:session_id/appium/performanceData/types'.freeze],
1821

lib/appium_lib/device/device.rb

+25-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,30 @@ module Device
2323

2424
# @!method current_activity
2525

26+
# @!method get_system_bars
27+
# Get system bar's information
28+
# @return [String] System bar
29+
#
30+
# ```ruby
31+
# get_system_bars
32+
# ```
33+
34+
# @!method get_display_density
35+
# Get connected device's density.
36+
# @return [Integer] The size of density
37+
#
38+
# ```ruby
39+
# get_display_density # 320
40+
# ```
41+
42+
# @!method is_keyboard_shown
43+
# Get whether keyboard is displayed or not.
44+
# @return [Bool] Return true if keyboard is shown. Return false if keyboard is hidden.
45+
#
46+
# ```ruby
47+
# is_keyboard_shown # false
48+
# ```
49+
2650
# @!method launch_app
2751
# Start the simulator and application configured with desired capabilities
2852

@@ -538,7 +562,7 @@ def ime_deactivate
538562
# @return [String] The context currently being used.
539563

540564
# @!method available_contexts
541-
# @return [Array<String>] All usable contexts, as an array of strings.
565+
# @return [Array<String>] All usable contexts, as an array of strings.
542566

543567
# Perform a block within the given context, then switch back to the starting context.
544568
# @param context (String) The context to switch to for the duration of the block.

0 commit comments

Comments
 (0)