blob: 20d294d7b955391abbcfedaa0f4fc878502d8905 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
"""Context of Fitbit Companion App."""
from mobly.controllers import android_device
from blueberry.utils.ui_pages import ui_core
from blueberry.utils.ui_pages.fitbit_companion import constants
class Context(ui_core.Context):
"""Context of Fitbit Companion App.
Attributes:
ad: The Android device where the UI pages are derived from.
safe_get: If True, use `safe_get_page` to get the page;
otherwise, use `get_page`.
do_go_home: If False the context object will stay in the
App's current page.
"""
def __init__(self, ad: android_device.AndroidDevice,
safe_get: bool = False,
do_go_home: bool = True) -> None:
super().__init__(ad, [HomePage], safe_get=safe_get,
do_go_home=do_go_home)
def go_home_page(self) -> ui_core.UIPage:
"""Goes to Fitbit companion App's home page.
Returns:
The home page object.
Raises:
errors.ContextError: Fail to reach target page.
"""
return self.go_page(HomePage)
class HomePage(ui_core.UIPage):
"""Fitbit Companion App's home page."""
ACTIVITY = f'{constants.PKG_NAME}/com.fitbit.home.ui.HomeActivity'
PAGE_RID = f'{constants.PKG_NAME_ID}/userAvatar'
def go_account_page(self) -> ui_core.UIPage:
"""Goes to Fitbit companion App's account page.
Returns:
The account page object.
Raises:
errors.UIError: Fail to get target node.
"""
return self.click_node_by_rid(self.PAGE_RID)
|