Skip to content

Commit

Permalink
Add some android commands (#517)
Browse files Browse the repository at this point in the history
* add commands

* fix rubocop

* add documentations

* update some comments
  • Loading branch information
KazuCocoa authored Mar 25, 2017
1 parent e0db50e commit c8ae26d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions android_tests/lib/android/specs/common/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions android_tests/lib/android/specs/common/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/appium_lib/common/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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],

Expand Down
26 changes: 25 additions & 1 deletion lib/appium_lib/device/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

# @!method available_contexts
# @return [Array<String>] All usable contexts, as an array of strings.
# @return [Array<String>] 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.
Expand Down

0 comments on commit c8ae26d

Please sign in to comment.