Skip to content

Commit 3c783ae

Browse files
feat: Add unit tests and fix review comments
1 parent 7694af1 commit 3c783ae

21 files changed

+692
-107
lines changed

appium/common/helper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import base64
1516
from typing import Any, Dict
1617

1718
from appium import version as appium_version
@@ -33,3 +34,8 @@ def library_version() -> str:
3334
"""Return a version of this python library"""
3435

3536
return appium_version.version
37+
38+
def encode_file_to_base64(file_path: str) -> str:
39+
"""Return base64 encoded string for given file"""
40+
with open(file_path, 'rb') as file:
41+
return base64.b64encode(file.read()).decode('utf-8')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .base import FlutterOptions
1+
from .base import FlutterOptions

appium/options/flutter_integration/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
from typing import Dict
19+
1920
from appium.options.common.automation_name_option import AUTOMATION_NAME
2021
from appium.options.common.base import AppiumOptions
2122
from appium.options.flutter_integration.flutter_element_wait_timeout_option import FlutterElementWaitTimeOutOption
@@ -29,12 +30,11 @@ class FlutterOptions(
2930
FlutterElementWaitTimeOutOption,
3031
FlutterEnableMockCameraOption,
3132
FlutterServerLaunchTimeOutOption,
32-
FlutterSystemPortOption
33+
FlutterSystemPortOption,
3334
):
34-
35+
3536
@property
3637
def default_capabilities(self) -> Dict:
3738
return {
3839
AUTOMATION_NAME: 'FlutterIntegration',
3940
}
40-

appium/options/flutter_integration/flutter_element_wait_timeout_option.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717

1818
from datetime import timedelta
1919
from typing import Optional, Union
20-
from appium.options.common.supports_capabilities import SupportsCapabilities
2120

21+
from appium.options.common.supports_capabilities import SupportsCapabilities
2222

23-
FLUTTER_ELEMENT_WAIT_TIMEOUT= 'flutterElementWaitTimeout'
23+
FLUTTER_ELEMENT_WAIT_TIMEOUT = 'flutterElementWaitTimeout'
2424

2525

2626
class FlutterElementWaitTimeOutOption(SupportsCapabilities):
27-
27+
2828
@property
2929
def flutter_element_wait_timeout(self) -> Optional[timedelta]:
3030
"""
3131
Maximum timeout to wait for element for Flutter integration test
32-
32+
3333
Returns:
3434
Optional[timedelta]: The timeout value as a `timedelta` object if set, or `None` if the timeout is not defined.
3535
"""
@@ -46,6 +46,6 @@ def flutter_element_wait_timeout(self, value: Union[timedelta, int]) -> None:
4646
If provided as a `timedelta`, it will be converted to milliseconds.
4747
"""
4848
self.set_capability(
49-
FLUTTER_ELEMENT_WAIT_TIMEOUT,
49+
FLUTTER_ELEMENT_WAIT_TIMEOUT,
5050
int(value.total_seconds() * 1000) if isinstance(value, timedelta) else value
51-
)
51+
)

appium/options/flutter_integration/flutter_enable_mock_camera_option.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@
1616
# under the License.
1717

1818
from typing import Optional
19-
from appium.options.common.supports_capabilities import SupportsCapabilities
2019

20+
from appium.options.common.supports_capabilities import SupportsCapabilities
2121

2222
FLUTTER_ENABLE_MOCK_CAMERA = 'flutterEnableMockCamera'
2323

2424

2525
class FlutterEnableMockCameraOption(SupportsCapabilities):
26-
26+
2727
@property
2828
def flutter_enable_mock_camera(self) -> bool:
2929
"""
3030
Get state of the mock camera for Flutter integration test
31-
31+
3232
Returns:
3333
bool: A boolean indicating whether the mock camera is enabled (True) or disabled (False).
3434
"""
3535
return self.get_capability(FLUTTER_ENABLE_MOCK_CAMERA)
3636

3737
@flutter_enable_mock_camera.setter
3838
def flutter_enable_mock_camera(self, value: bool) -> None:
39-
"""
39+
"""
4040
Setter method enable or disable the mock camera for Flutter integration test
4141
Default state is `False`
4242
4343
Args:
4444
value (bool): A boolean value indicating whether to enable (True) or disable (False) the mock camera.
4545
"""
46-
self.set_capability(FLUTTER_ENABLE_MOCK_CAMERA, value)
46+
self.set_capability(FLUTTER_ENABLE_MOCK_CAMERA, value)

appium/options/flutter_integration/flutter_server_launch_timeout_option.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
from datetime import timedelta
1919
from typing import Optional, Union
20-
from appium.options.common.supports_capabilities import SupportsCapabilities
2120

21+
from appium.options.common.supports_capabilities import SupportsCapabilities
2222

23-
FLUTTER_SERVER_LAUNCH_TIMEOUT= 'flutterServerLaunchTimeout'
23+
FLUTTER_SERVER_LAUNCH_TIMEOUT = 'flutterServerLaunchTimeout'
2424

2525

2626
class FlutterServerLaunchTimeOutOption(SupportsCapabilities):
27-
27+
2828
@property
2929
def flutter_server_launch_timeout(self) -> Optional[timedelta]:
3030
"""
@@ -43,10 +43,10 @@ def flutter_server_launch_timeout(self, value: Union[timedelta, int]) -> None:
4343
Default timeout is 5000ms
4444
4545
Args:
46-
value (Union[timedelta, int]): The timeout value, either as a `timedelta` object or an integer in milliseconds.
46+
value (Union[timedelta, int]): The timeout value, either as a `timedelta` object or an integer in milliseconds.
4747
If provided as a `timedelta`, it will be converted to milliseconds.
4848
"""
4949
self.set_capability(
50-
FLUTTER_SERVER_LAUNCH_TIMEOUT,
50+
FLUTTER_SERVER_LAUNCH_TIMEOUT,
5151
int(value.total_seconds() * 1000) if isinstance(value, timedelta) else value
52-
)
52+
)

appium/options/flutter_integration/flutter_system_port_option.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
# under the License.
1717

1818
from typing import Optional
19-
from appium.options.common.supports_capabilities import SupportsCapabilities
2019

20+
from appium.options.common.supports_capabilities import SupportsCapabilities
2121

2222
FLUTTER_SYSTEM_PORT = 'flutterSystemPort'
2323

2424

2525
class FlutterSystemPortOption(SupportsCapabilities):
26-
26+
2727
@property
2828
def flutter_system_port(self) -> Optional[int]:
2929
"""
3030
Get flutter system port for Flutter integration tests.
31-
31+
3232
Returns:
3333
int: returns the port number
3434
"""
@@ -43,4 +43,4 @@ def flutter_system_port(self, value: int) -> None:
4343
Args:
4444
value (int): The port number to be used for the Flutter server.
4545
"""
46-
self.set_capability(FLUTTER_SYSTEM_PORT, value)
46+
self.set_capability(FLUTTER_SYSTEM_PORT, value)

appium/webdriver/common/appiumby.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class AppiumBy(By):
2525
ACCESSIBILITY_ID = 'accessibility id'
2626
IMAGE = '-image'
2727
CUSTOM = '-custom'
28+
29+
# For Flutter integration usage https://github.com/AppiumTestDistribution/appium-flutter-integration-driver/tree/main
2830
FLUTTER_INTEGRATION_SEMANTICS_LABEL = '-flutter semantics label'
2931
FLUTTER_INTEGRATION_TYPE = '-flutter type'
3032
FLUTTER_INTEGRATION_KEY = '-flutter key'

0 commit comments

Comments
 (0)