-  
 -   Notifications  
You must be signed in to change notification settings  - Fork 768
 
Add handlers for gsm, network, power and sms command #834
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  
 Changes from 3 commits
 Commits 
  Show all changes 
  5 commits   Select commit Hold shift + click to select a range 
 dc8e3eb  Add handlers for gsm, network, power and sms command 
  SrinivasanTarget 0fdc028  fixed review comments 
  SrinivasanTarget 2166063  make codacy happy 
  SrinivasanTarget 52bb05e  update as per review comments 
  SrinivasanTarget 9e76107  Fixed review comments 
  SrinivasanTarget 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   
            5 changes: 5 additions & 0 deletions  5   src/main/java/io/appium/java_client/android/GsmCallActions.java          
     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,5 @@ | ||
| package io.appium.java_client.android; | ||
|   |  ||
| public enum GsmCallActions { | ||
| CALL, ACCEPT, CANCEL, HOLD | ||
| } | 
       5 changes: 5 additions & 0 deletions  5   src/main/java/io/appium/java_client/android/GsmSignalStrength.java          
     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,5 @@ | ||
| package io.appium.java_client.android; | ||
|   |  ||
| public enum GsmSignalStrength { | ||
| NONE_OR_UNKNOWN, POOR, MODERATE, GOOD, GREAT | ||
| } | 
       5 changes: 5 additions & 0 deletions  5   src/main/java/io/appium/java_client/android/GsmVoiceState.java          
     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,5 @@ | ||
| package io.appium.java_client.android; | ||
|   |  ||
| public enum GsmVoiceState { | ||
| ON, OFF, DENIED, SEARCHING, ROAMING, HOME, UNREGISTERED | ||
| } | 
       5 changes: 5 additions & 0 deletions  5   src/main/java/io/appium/java_client/android/NetworkSpeed.java          
     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,5 @@ | ||
| package io.appium.java_client.android; | ||
|   |  ||
| public enum NetworkSpeed { | ||
| GSM, SCSD, GPRS, EDGE, UMTS, HSDPA, LTE, EVDO, FULL | ||
| } | 
       5 changes: 5 additions & 0 deletions  5   src/main/java/io/appium/java_client/android/PowerACState.java          
     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,5 @@ | ||
| package io.appium.java_client.android; | ||
|   |  ||
| public enum PowerACState { | ||
| ON, OFF | ||
| } | 
       81 changes: 81 additions & 0 deletions  81   src/main/java/io/appium/java_client/android/SupportsSpecialEmulatorCommands.java          
     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,81 @@ | ||
| package io.appium.java_client.android; | ||
|   |  ||
| import static io.appium.java_client.android.AndroidMobileCommandHelper.gsmCallCommand; | ||
| import static io.appium.java_client.android.AndroidMobileCommandHelper.gsmSignalStrengthCommand; | ||
| import static io.appium.java_client.android.AndroidMobileCommandHelper.gsmVoiceCommand; | ||
| import static io.appium.java_client.android.AndroidMobileCommandHelper.networkSpeedCommand; | ||
| import static io.appium.java_client.android.AndroidMobileCommandHelper.powerACCommand; | ||
| import static io.appium.java_client.android.AndroidMobileCommandHelper.powerCapacityCommand; | ||
| import static io.appium.java_client.android.AndroidMobileCommandHelper.sendSMSCommand; | ||
|   |  ||
| import io.appium.java_client.CommandExecutionHelper; | ||
| import io.appium.java_client.ExecutesMethod; | ||
|   |  ||
| public interface SupportsSpecialEmulatorCommands extends ExecutesMethod { | ||
|   |  ||
| /** | ||
| * Emulate send SMS event on the connected emulator. | ||
| * | ||
| * @param phoneNumber The phone number of message sender. | ||
| * @param message The message content. | ||
| */ | ||
| default void sendSMS(String phoneNumber, String message) { | ||
| CommandExecutionHelper.execute(this, sendSMSCommand(phoneNumber, message)); | ||
| } | ||
|   |  ||
| /** | ||
| * Emulate GSM call event on the connected emulator. | ||
| * | ||
| * @param phoneNumber The phone number of the caller. | ||
| * @param gsmCallActions One of available {@link GsmCallActions} values. | ||
| */ | ||
| default void setGsmCall(String phoneNumber, GsmCallActions gsmCallActions) { | ||
| CommandExecutionHelper.execute(this, gsmCallCommand(phoneNumber, gsmCallActions)); | ||
| } | ||
|   |  ||
| /** | ||
| * Emulate GSM signal strength change event on the connected emulator. | ||
| * | ||
| * @param gsmSignalStrength One of available {@link GsmSignalStrength} values. | ||
| */ | ||
| default void setGsmSignalStrength(GsmSignalStrength gsmSignalStrength) { | ||
| CommandExecutionHelper.execute( this, gsmSignalStrengthCommand(gsmSignalStrength)); | ||
    |  ||
| } | ||
|   |  ||
| /** | ||
| * Emulate GSM voice event on the connected emulator. | ||
| * | ||
| * @param gsmVoiceState One of available {@link GsmVoiceState} values. | ||
| */ | ||
| default void setGsmVoice(GsmVoiceState gsmVoiceState) { | ||
| CommandExecutionHelper.execute(this, gsmVoiceCommand(gsmVoiceState)); | ||
| } | ||
|   |  ||
| /** | ||
| * Emulate network speed change event on the connected emulator. | ||
| * | ||
| * @param networkSpeed One of available {@link NetworkSpeed} values. | ||
| */ | ||
| default void setNetworkSpeed(NetworkSpeed networkSpeed) { | ||
| CommandExecutionHelper.execute(this, networkSpeedCommand(networkSpeed)); | ||
| } | ||
|   |  ||
| /** | ||
| * Emulate power capacity change on the connected emulator. | ||
| * | ||
| * @param percent Percentage value in range [0, 100]. | ||
| */ | ||
| default void setPowerCapacity(int percent) { | ||
| CommandExecutionHelper.execute(this, powerCapacityCommand(percent)); | ||
| } | ||
|   |  ||
| /** | ||
| * Emulate power state change on the connected emulator. | ||
| * | ||
| * @param powerACState One of available {@link PowerACState} values. | ||
| */ | ||
| default void setPowerAC(PowerACState powerACState) { | ||
| CommandExecutionHelper.execute(this, powerACCommand(powerACState)); | ||
| } | ||
|   |  ||
| } | ||
   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 | 
|---|---|---|
|      |  @@ -37,6 +37,56 @@ | |
|   |  ||
| public class AndroidDriverTest extends BaseAndroidTest { | ||
|   |  ||
| @Test public void sendSMSTest() { | ||
| try { | ||
| driver.sendSMS("11111111", "call"); | ||
| } catch (Exception e) { | ||
| assertFalse( "method works only in emulators", true); | ||
    |  ||
| } | ||
| } | ||
|   |  ||
| @Test public void gsmCallTest() { | ||
| try { | ||
| driver.setGsmCall("11111111", GsmCallActions.CALL); | ||
| driver.setGsmCall("11111111", GsmCallActions.ACCEPT); | ||
| } catch (Exception e) { | ||
| assertFalse( "method works only in emulators", true); | ||
| } | ||
| } | ||
|   |  ||
| @Test public void gsmSignalStrengthTest() { | ||
| try { | ||
| driver.setGsmSignalStrength(GsmSignalStrength.GREAT); | ||
| } catch (Exception e) { | ||
| assertFalse( "method works only in emulators", true); | ||
| } | ||
| } | ||
|   |  ||
| @Test public void gsmVoiceTest() { | ||
| try { | ||
| driver.setGsmVoice(GsmVoiceState.OFF); | ||
| } catch (Exception e) { | ||
| assertFalse( "method works only in emulators", true); | ||
| } | ||
| } | ||
|   |  ||
| @Test public void networkSpeedTest() { | ||
| try { | ||
| driver.setNetworkSpeed(NetworkSpeed.EDGE); | ||
| } catch (Exception e) { | ||
| assertFalse( "method works only in emulators", true); | ||
| } | ||
| } | ||
|   |  ||
| @Test public void powerTest() { | ||
| try { | ||
| driver.setPowerCapacity(100); | ||
| driver.setPowerAC(PowerACState.OFF); | ||
| } catch (Exception e) { | ||
| assertFalse( "method works only in emulators", true); | ||
| } | ||
| } | ||
|   |  ||
| @Test public void getDeviceTimeTest() { | ||
| String time = driver.getDeviceTime(); | ||
| assertTrue(time.length() == 28); | ||
|      |  ||
 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.
makeGsmCallwould be a better name