52
51
class Page(UbuntuUIToolkitCustomProxyObjectBase):
53
52
"""Autopilot helper for Pages."""
54
def __init__(self, *args):
55
super(Page, self).__init__(*args)
53
def __init__(self, *args, **kwargs):
54
super(Page, self).__init__(*args, **kwargs)
56
# Use only objectName due to bug 1350532 as it is MainView12
57
self.main_view = self.get_root_instance().select_single(
61
return self.main_view.get_header().click_back_button()
58
64
class PageWithBottomEdge(Page):
59
"""Autopilot helper for PageWithBottomEdge."""
60
def __init__(self, *args):
61
super(PageWithBottomEdge, self).__init__(*args)
66
An emulator class that makes it easy to interact with the bottom edge
69
def __init__(self, *args, **kwargs):
70
super(PageWithBottomEdge, self).__init__(*args, **kwargs)
63
72
def reveal_bottom_edge_page(self):
64
73
"""Bring the bottom edge page to the screen"""
66
74
self.bottomEdgePageLoaded.wait_for(True)
73
81
start_y = (action_item.globalRect.y +
74
82
(action_item.height * 0.5))
75
83
stop_y = start_y - (self.height * 0.7)
77
84
self.pointing_device.drag(start_x, start_y,
78
85
start_x, stop_y, rate=2)
79
86
self.isReady.wait_for(True)
85
92
class AddLocationPage(Page):
86
93
"""Autopilot helper for AddLocationPage."""
87
def __init__(self, *args):
88
super(AddLocationPage, self).__init__(*args)
94
def __init__(self, *args, **kwargs):
95
super(AddLocationPage, self).__init__(*args, **kwargs)
98
def click_location(self, index):
99
return self.select_single("UCListItem",
100
objectName="addLocation" + str(index))
102
def click_search_action(self):
103
self.main_view.get_header().click_action_button("search")
105
def get_search_field(self):
106
header = self.main_view.get_header()
108
return header.select_single("TextField", objectName="searchField")
110
def search(self, value):
111
self.click_search_action()
113
search_field = self.get_search_field()
114
search_field.write(value)
116
# Wait for model to finish loading
117
self.searching.wait_for(False)
91
120
class HomePage(PageWithBottomEdge):
92
121
"""Autopilot helper for HomePage."""
93
def __init__(self, *args):
94
super(HomePage, self).__init__(*args)
122
def __init__(self, *args, **kwargs):
123
super(HomePage, self).__init__(*args, **kwargs)
96
125
def get_location_count(self):
97
126
return self.wait_select_single(
103
132
def __init__(self, *args, **kwargs):
104
133
super(LocationsPage, self).__init__(*args, **kwargs)
135
def click_add_location_action(self):
136
self.main_view.get_header().click_action_button("addLocation")
138
def get_location(self, index):
139
return self.select_single(WeatherListItem,
140
objectName="location" + str(index))
107
143
class MainView(MainView):
108
144
"""Autopilot custom proxy object for the MainView."""
111
147
def __init__(self, *args):
112
148
super(MainView, self).__init__(*args)
113
149
self.visible.wait_for(True)
152
class WeatherListItem(UbuntuUIToolkitCustomProxyObjectBase):
154
return self.select_single("Label", objectName="name").text