blob: b2e14d80dda35644984ad1c551b4756fdcaf5bfb (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
"""Account pages associated with Fitbit Companion App testing."""
from typing import List
from blueberry.utils.ui_pages import ui_core
from blueberry.utils.ui_pages import ui_node
from blueberry.utils.ui_pages.fitbit_companion import constants
class AccountPage(ui_core.UIPage):
"""Fitbit Companion App's account page."""
ACTIVITY = f'{constants.PKG_NAME}/com.fitbit.settings.ui.AccountActivity'
PAGE_RID = f'{constants.PKG_NAME_ID}/account_recycler'
NODE_UER_AVATOR_RID = f'{constants.PKG_NAME_ID}/userAvatar'
NODE_BACK_CONTENT_DESC = 'Navigate up'
NODE_ADD_DEV_RID = f'{constants.PKG_NAME_ID}/add_device_img'
NODE_DEVICE_RID = f'{constants.PKG_NAME_ID}/device_name'
def add_device(self) -> ui_core.UIPage:
"""Goes to page to add new device.
Returns:
The transformed page.
Raises:
errors.UIError: Fail to get the target node.
"""
return self.click_node_by_rid(self.NODE_ADD_DEV_RID)
def back(self) -> ui_core.UIPage:
"""Goes back to Fitbit Companion App's home page.
Returns:
The transformed page.
Raises:
errors.UIError: Fail to get target node.
"""
return self.click_node_by_content_desc(self.NODE_BACK_CONTENT_DESC)
def get_paired_devices(self) -> List[ui_node.UINode]:
"""Gets all paired devices.
Returns:
The list of node representing the paired device.
"""
return self.get_all_nodes_by_rid(self.NODE_DEVICE_RID)
class PairedDeviceDetailPage(ui_core.UIPage):
"""Fitbit Companion App's page of paired device."""
PAGE_RID = f'{constants.PKG_NAME_ID}/unpair'
def unpair(self) -> ui_core.UIPage:
"""Unpairs device.
Returns:
The transformed page.
Raises:
errors.UIError: Fail to find the target node.
"""
# TODO(user): We need to consider the situation while device
# sync now which cause unpair to fail.
return self.click_node_by_rid(self.PAGE_RID)
class UnpairConfirmPage(ui_core.UIPage):
"""Fitbit Companion App's page to confirm the action of unpairing."""
PAGE_TEXT = 'UNPAIR'
def confirm(self) -> ui_core.UIPage:
"""Confirms the action of unpairing.
Returns:
The transformed page.
"""
self.click_node_by_text(self.PAGE_TEXT)
self.ctx.expect_page(AccountPage)
return self.ctx.page
|