forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mobile - Network Connection implementation for Java and Python.
Browser Connection is no more adding simple Android Driver wrapper for RWD (I tire of typing out webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.ANDROID) ) :)
- Loading branch information
Showing
42 changed files
with
418 additions
and
425 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
36 changes: 0 additions & 36 deletions
36
java/client/src/org/openqa/selenium/html5/BrowserConnection.java
This file was deleted.
Oops, something went wrong.
127 changes: 127 additions & 0 deletions
127
java/client/src/org/openqa/selenium/mobile/NetworkConnection.java
This file contains 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,127 @@ | ||
/* | ||
Copyright 2014 Software Freedom Conservancy | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package org.openqa.selenium.mobile; | ||
|
||
|
||
/** | ||
* Control a device's network connection | ||
* <p> | ||
* Example usage: | ||
* | ||
* <pre> | ||
* NetworkConnection mobileDriver = (NetworkConnection) driver; | ||
* if (mobileDriver.getNetworkConnection() != ConnectionType.AIRPLANE_MODE) { | ||
* // enabling Airplane mode | ||
* mobileDriver.setNetworkConnection(ConnectionType.AIRPLANE_MODE); | ||
* } | ||
* </pre> | ||
*/ | ||
public interface NetworkConnection { | ||
|
||
/** | ||
* ConnectionType is a bitmask to represent a device's network connection | ||
* Data | WIFI | Airplane | ||
* 0 0 1 == 1 | ||
* 1 1 0 == 6 | ||
* 1 0 0 == 4 | ||
* 0 1 0 == 2 | ||
* 0 0 0 == 0 | ||
* | ||
* Giving "Data" the first bit positions in order to give room for the future of enabling | ||
* specific types of data (Edge / 2G, 3G, 4G, LTE, etc) if the device allows it. | ||
*/ | ||
public class ConnectionType { | ||
public static final ConnectionType WIFI = new ConnectionType(2); | ||
public static final ConnectionType DATA = new ConnectionType(4); | ||
public static final ConnectionType AIRPLANE_MODE = new ConnectionType(1); | ||
public static final ConnectionType ALL = new ConnectionType(6); | ||
public static final ConnectionType NONE = new ConnectionType(0); | ||
|
||
/* | ||
Future for Network Data types. With a new constructor accepting this enum. | ||
public enum DataType { | ||
_2G, _3G, _4G, LTE | ||
} | ||
*/ | ||
|
||
private int mask = 0; | ||
|
||
public ConnectionType(Boolean wifi, Boolean data, Boolean airplaneMode) { | ||
if (wifi) { | ||
mask += WIFI.mask; | ||
} | ||
if (data) { | ||
mask += DATA.mask; | ||
} | ||
if (airplaneMode) { | ||
mask += AIRPLANE_MODE.mask; | ||
} | ||
} | ||
|
||
public ConnectionType(int mask) { | ||
// must be a positive number | ||
this.mask = Math.max(mask, 0); | ||
} | ||
|
||
public Boolean isAirplaneMode() { | ||
return mask % 2 == 1; | ||
} | ||
|
||
public Boolean isWifiEnabled() { | ||
// shift right 1 bit, check last bit | ||
return (mask / 2) % 2 == 1; | ||
} | ||
|
||
public Boolean isDataEnabled() { | ||
// shift right 2 bits, check if any bits set | ||
return (mask / 4) > 0; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object type) { | ||
return type instanceof ConnectionType && this.mask == ((ConnectionType)type).mask; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Integer.toString(mask); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Query the driver for the Airplane Mode setting state | ||
* | ||
* @return ConnectionType indicating if the device is in Airplane Mode | ||
* @see org.openqa.selenium.mobile.NetworkConnection.ConnectionType | ||
*/ | ||
public ConnectionType getNetworkConnection(); | ||
|
||
/** | ||
* Set the Connection type | ||
* Not all connection type combinations are valid for an individual type of device | ||
* and the remote endpoint will make a best effort to set the type as requested | ||
* | ||
* @param type ConnectionType of what the network connection should be | ||
* | ||
* @return @ConnectionType of what the device's network connection is | ||
* @see org.openqa.selenium.mobile.NetworkConnection.ConnectionType | ||
*/ | ||
public ConnectionType setNetworkConnection(ConnectionType type); | ||
|
||
} |
This file contains 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 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 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 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
2 changes: 1 addition & 1 deletion
2
java/client/src/org/openqa/selenium/remote/RemoteWebDriver.java
This file contains 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 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
30 changes: 0 additions & 30 deletions
30
java/client/src/org/openqa/selenium/remote/html5/RemoteBrowserConnection.java
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.