Skip to content

Commit bfbab1d

Browse files
feat: fix review comments and applied black and isort formating
1 parent 7694af1 commit bfbab1d

File tree

13 files changed

+93
-93
lines changed

13 files changed

+93
-93
lines changed
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/extensions/flutter_integration/flutter_commands.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,30 @@
1515
import base64
1616
import os
1717
from typing import Any, Dict, Optional, Tuple, Union
18+
1819
from appium.webdriver.extensions.flutter_integration.scroll_directions import ScrollDirection
1920
from appium.webdriver.flutter_finder import FlutterFinder
2021
from appium.webdriver.webdriver import WebDriver
2122
from appium.webdriver.webelement import WebElement
2223

2324

2425
class FlutterCommand:
25-
26+
2627
def __init__(self, driver: WebDriver) -> None:
2728
self.driver = driver
28-
29-
# wait commands
30-
29+
30+
# wait commands
31+
3132
def wait_for_visible(self, locator: Union[WebElement, FlutterFinder], time_out: Optional[float] = None) -> None:
3233
"""
3334
Waits for a element to become visible.
3435
3536
Args:
3637
locator (Union[WebElement, FlutterFinder]): The element to wait for; can be a WebElement or a FlutterFinder.
3738
time_out (Optional[float]): Maximum wait time in seconds. Defaults to a predefined timeout if not specified.
38-
39-
Returns:
40-
None:
39+
40+
Returns:
41+
None:
4142
"""
4243
opts: Dict[str, Union[WebElement, Dict[str, str], float]] = {}
4344
if isinstance(locator, WebElement):
@@ -49,17 +50,16 @@ def wait_for_visible(self, locator: Union[WebElement, FlutterFinder], time_out:
4950

5051
self.execute_flutter_command('waitForVisible', opts)
5152

52-
5353
def wait_for_invisible(self, locator: Union[WebElement, FlutterFinder], time_out: Optional[float] = None) -> None:
5454
"""
5555
Waits for a element to become invisible.
5656
5757
Args:
5858
locator (Union[WebElement, FlutterFinder]): The element to wait for; can be a WebElement or a FlutterFinder.
5959
time_out (Optional[float]): Maximum wait time in seconds. Defaults to a predefined timeout if not specified.
60-
60+
6161
Returns:
62-
None:
62+
None:
6363
"""
6464
opts: Dict[str, Union[WebElement, Dict[str, str], float]] = {}
6565
if isinstance(locator, WebElement):
@@ -68,95 +68,95 @@ def wait_for_invisible(self, locator: Union[WebElement, FlutterFinder], time_out
6868
opts['locator'] = locator.to_dict()
6969
if time_out is not None:
7070
opts['timeout'] = time_out
71-
71+
7272
self.execute_flutter_command('waitForAbsent', opts)
7373

7474
# flutter action commands
75-
75+
7676
def perform_double_click(self, element: WebElement, offset: Optional[Tuple[int, int]] = None) -> None:
7777
"""
7878
Performs a double-click on the given element, with an optional offset.
7979
8080
Args:
8181
element (WebElement): The element to double-click on. This parameter is required.
8282
offset (Optional[Tuple[int, int]]): The x and y offsets from the element to click at. If not specified, the click is performed at the element's center.
83-
83+
8484
Returns:
8585
None:
8686
"""
87-
opts: Dict[str, Union[WebElement, Dict[str, int]]] = {'origin': element}
87+
opts: Dict[str, Union[WebElement, Dict[str, int]]] = {"origin": element}
8888
if offset is not None:
8989
opts['offset'] = {'x': offset[0], 'y': offset[1]}
9090
self.execute_flutter_command('doubleClick', opts)
91-
91+
9292
def perform_long_press(self, element: WebElement, offset: Optional[Tuple[int, int]] = None) -> None:
9393
"""
9494
Performs a long press on the given element, with an optional offset.
9595
9696
Args:
9797
element (WebElement): The element to perform the long press on. This parameter is required.
9898
offset (Optional[Tuple[int, int]]): The x and y offsets from the element to perform the long press at. If not specified, the long press is performed at the element's center.
99-
99+
100100
Returns:
101101
None:
102102
"""
103-
opts: Dict[str, Union[WebElement, Dict[str, int]]]= {'origin': element}
103+
opts: Dict[str, Union[WebElement, Dict[str, int]]] = {'origin': element}
104104
if offset is not None:
105105
opts['offset'] = {'x': offset[0], 'y': offset[1]}
106106
self.execute_flutter_command('longPress', opts)
107-
107+
108108
def perform_drag_and_drop(self, source: WebElement, target: WebElement) -> None:
109109
"""
110110
Performs a drag-and-drop operation from a source element to a target element.
111111
112112
Args:
113113
source (WebElement): The element to drag from.
114114
target (WebElement): The element to drop onto.
115-
115+
116116
Returns:
117117
None:
118118
"""
119119
self.execute_flutter_command('dragAndDrop', {'source': source, 'target': target})
120-
120+
121121
def scroll_till_visible(self, scroll_to: FlutterFinder, scroll_direction: ScrollDirection = ScrollDirection.DOWN, **opts: Any) -> WebElement:
122122
"""
123123
Scrolls until the specified element becomes visible.
124124
125125
Args:
126126
scroll_to (FlutterFinder): The Flutter element to scroll to.
127127
scroll_direction (ScrollDirection): The direction to scroll up or down. Defaults to `ScrollDirection.DOWN`.
128-
128+
129129
KeywordArgs:
130-
scrollView (str): The view of the scroll.
131-
delta (int): delta for the scroll
132-
maxScrolls (int): Max times to scroll
133-
settleBetweenScrollsTimeout (int): settle timeout
134-
dragDuration (int): time gap between each scroll
135-
130+
scrollView (str): The view of the scroll. Default value is 'Scrollable'
131+
delta (int): delta for the scroll. Default value is 64
132+
maxScrolls (int): Max times to scroll. Default value is 15
133+
settleBetweenScrollsTimeout (int): settle timeout in milliseconds. Default value is 5000ms
134+
dragDuration (int): time gap between each scroll in milliseconds. Default value is 100ms
135+
136136
Returns:
137137
Webelement: scrolled element
138138
"""
139139
opts['finder'] = scroll_to.to_dict()
140-
opts['scrollDirection'] = scroll_direction.as_string()
140+
opts['scrollDirection'] = scroll_direction.value
141141
return self.execute_flutter_command('scrollTillVisible', opts)
142-
142+
143143
def inject_mock_image(self, value: str) -> str:
144144
"""
145145
Injects a mock image to the device. The input can be a file path or a base64-encoded string.
146146
147147
Args:
148148
value (str): The file path of the image or a base64-encoded string.
149-
149+
150150
Returns:
151151
str: Image ID of the injected image.
152152
"""
153-
if os.path.isfile(value):
153+
if os.path.isfile(value):
154154
with open(value, 'rb') as image_file:
155155
base64_encoded_image = base64.b64encode(image_file.read()).decode('utf-8')
156156
else:
157157
base64_encoded_image = value
158158
return self.execute_flutter_command('injectImage', {'base64Image': base64_encoded_image})
159-
159+
160160
def activate_injected_image(self, image_id: str) -> None:
161161
"""
162162
Activates an injected image with image ID.
@@ -168,18 +168,18 @@ def activate_injected_image(self, image_id: str) -> None:
168168
None:
169169
"""
170170
self.execute_flutter_command('activateInjectedImage', {'imageId': image_id})
171-
171+
172172
def execute_flutter_command(self, scriptName: str, params: dict) -> Any:
173173
"""
174174
Executes a Flutter command by sending a script and parameters to the flutter integration driver.
175175
176176
Args:
177-
scriptName (str): The name of the Flutter command to execute.
177+
scriptName (str): The name of the Flutter command to execute.
178178
This will be prefixed with 'flutter:' when passed to the driver.
179179
params (dict): A dictionary of parameters to be passed along with the Flutter command.
180180
181181
Returns:
182-
Any: The result of the command execution. The return value depends on the
182+
Any: The result of the command execution. The return value depends on the
183183
specific Flutter command being executed.
184184
"""
185-
return self.driver.execute_script(f'flutter: {scriptName}', params)
185+
return self.driver.execute_script(f'flutter: {scriptName}', params)
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from enum import Enum
22

3+
34
class ScrollDirection(Enum):
45
UP = 'up'
56
DOWN = 'down'
6-
7-
def as_string(self) -> str:
8-
return str(self.value)

0 commit comments

Comments
 (0)