64
64
"/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml",
65
65
"--desktop_file_hint=/usr/share/applications/ubuntu-clock-app.desktop",
68
def get_toolbar(self):
69
return self.app.select_single("Toolbar")
71
#shamelessly pulled and adapted from the ubuntusdk emulator unmerged code, 6 Aug 13
72
#need to migrate to ubuntusdk emulator
68
73
def get_tabs(self):
69
return self.app.select_single("NewTabBar")
74
return self.app.select_single("TabBar")
76
def switch_to_next_tab(self):
77
"""Open the next tab."""
78
self.pointing_device.click_object(self._get_current_tab_button())
79
self.pointing_device.click_object(self._get_next_tab_button())
81
def _get_current_tab_button(self):
82
tabs = self.get_tabs()
83
#return tabs.tabs.select_many('AbstractButton', selected=True) <--- can't do this
84
#clock has 8 buttons, a duplicate of each tab for some reason.
85
#Sometimes 2 buttons are shown as selected. If this is the case, we want the second one.
86
#Looping through them in this horrible way accomplishes our goal
87
buttons = tabs.select_many('AbstractButton')
88
for button in buttons:
89
if button.selected == True:
90
selectedButton = button
93
def _get_next_tab_button(self):
94
current_index = self._get_current_tab_button().buttonIndex
95
next_index = (current_index + 1) % self._get_number_of_tab_buttons()
96
return self._get_tab_buttons()[next_index]
98
def _get_number_of_tab_buttons(self):
99
return len(self._get_tab_buttons())
101
def _get_tab_buttons(self):
102
tabs = self.get_tabs()
103
return tabs.select_many('AbstractButton')
71
105
def move_to_stopwatch_tab(self):
72
tabs_bar = self.get_tabs()
74
x, y, w, h = tabs_bar.globalRect
77
self.pointing_device.drag(tx, ty, w - 10, ty)
79
stopwatch_tab_button = self.main_window.get_stopwatch_tab_button()
81
self.assertThat(stopwatch_tab_button.opacity, Eventually(GreaterThan(0.35)))
82
self.pointing_device.click_object(stopwatch_tab_button)
106
#stopwatch is 3 tabs over from clock
107
#we really need better tab support to support moving to tab based on objectName
108
self.switch_to_next_tab()
109
self.switch_to_next_tab()
110
self.switch_to_next_tab()
84
112
def move_to_timer_tab(self):
85
tabs_bar = self.get_tabs()
87
x, y, w, h = tabs_bar.globalRect
90
self.pointing_device.drag(tx, ty, w - 9, ty)
92
timer_tab_button = self.main_window.get_timer_tab_button()
94
self.assertThat(timer_tab_button.opacity, Eventually(GreaterThan(0.35)))
95
self.pointing_device.click_object(timer_tab_button)
113
#timer is 2 tabs over from clock
114
#we really need better tab support to support moving to tab based on objectName
115
self.switch_to_next_tab()
116
self.switch_to_next_tab()
99
119
def main_window(self):