Repository navigation
Add battery info #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add battery info #85
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
394dafe
add battery info
KazuCocoa f412189
fix rubocop
KazuCocoa 0d02d02
add android
KazuCocoa e37f9c0
fix rubocop
KazuCocoa 1532775
add docstring
KazuCocoa 4736dd4
add changelog
KazuCocoa 150d030
add func test
KazuCocoa 526ce91
Merge branch 'master' into add_battery_info
KazuCocoa 69ac2c0
move touch actions in common touch action directoly
KazuCocoa ac6bf16
appends a limit for ios
KazuCocoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| module Appium | ||
| module Core | ||
| module Android | ||
| module Uiautomator2 | ||
| module Device | ||
| extend Forwardable | ||
|
|
||
| # @since 1.6.0 | ||
| # @!method battery_info | ||
| # | ||
| # Get battery information. | ||
| # | ||
| # @return [Hash] Return battery level and battery state. | ||
| # Battery level in range [0.0, 1.0], where 1.0 means 100% charge. -1 is returned | ||
| # if the actual value cannot be retrieved from the system. | ||
| # Battery state. The following symbols are possible | ||
| # `:unknown, :charging, :discharging, :not_charging, :full` | ||
| # | ||
| # @example | ||
| # | ||
| # @driver.battery_info #=> { state: :charging, level: 0.7 } | ||
| # | ||
|
|
||
| #### | ||
| ## class << self | ||
| #### | ||
|
|
||
| class << self | ||
| def extended(_mod) | ||
| ::Appium::Core::Device.add_endpoint_method(:battery_info) do | ||
| def battery_info | ||
| response = execute_script 'mobile: batteryInfo', {} | ||
|
|
||
| state = case response['state'] | ||
| when 2, 3, 4, 5 | ||
| ::Appium::Core::Device::BatteryStatus::ANDROID[response['state']] | ||
| else | ||
| Appium::Logger.warn("The state is unknown or undefined: #{response['state']}") | ||
| ::Appium::Core::Device::BatteryStatus::ANDROID[1] # :unknown | ||
| end | ||
| { state: state, level: response['level'] } | ||
| end | ||
| end | ||
| end | ||
| end # class << self | ||
| end # module Device | ||
| end # module Uiautomator2 | ||
| end # module Android | ||
| end # module Core | ||
| end # module Appium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| # loaded in common/driver.rb | ||
| require_relative 'android/search_context' | ||
| require_relative 'android/device' | ||
|
|
||
| require_relative 'android/uiautomator2/bridge' | ||
| require_relative 'android/uiautomator2/device' |
File renamed without changes.
36 changes: 18 additions & 18 deletions
36
lib/appium_lib_core/device/touch_actions.rb → ...core/common/touch_action/touch_actions.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| module Appium | ||
| module Core | ||
| module Device | ||
| module BatteryStatus | ||
| ANDROID = [ | ||
| :undefined, # 0, dummy | ||
| :unknown, # 1 | ||
| :charging, # 2 | ||
| :discharging, # 3 | ||
| :not_charging, # 4 | ||
| :full # 5 | ||
| ].freeze | ||
|
|
||
| IOS = [ | ||
| :unknown, # 0 | ||
| :unplugged, # 1 | ||
| :charging, # 2 | ||
| :full # 3 | ||
| ].freeze | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the
valuehasstatus, then Ruby client raise parse response error.I guess the implementation is https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#responses 's one.