~nik90/ubuntu-clock-app/dynamic-stopwatch-loader

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_clock_app/tests/__init__.py

  • Committer: Nekhelesh Ramananthan
  • Date: 2013-08-08 07:40:44 UTC
  • mfrom: (157.1.6 ubuntu-clock-app)
  • Revision ID: krnekhelesh@hotmail.com-20130808074044-9127kld8nqpwi6iw
mergeĀ fromĀ master

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
            "/usr/share/ubuntu-clock-app/ubuntu-clock-app.qml",
65
65
            "--desktop_file_hint=/usr/share/applications/ubuntu-clock-app.desktop",
66
66
            app_type='qt')
67
 
            
 
67
 
 
68
    def get_toolbar(self):
 
69
        return self.app.select_single("Toolbar")
 
70
 
 
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")
70
 
        
 
74
        return self.app.select_single("TabBar")
 
75
 
 
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())
 
80
 
 
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
 
91
        return selectedButton
 
92
 
 
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]
 
97
 
 
98
    def _get_number_of_tab_buttons(self):
 
99
        return len(self._get_tab_buttons())
 
100
 
 
101
    def _get_tab_buttons(self):
 
102
        tabs = self.get_tabs()
 
103
        return tabs.select_many('AbstractButton')
 
104
 
71
105
    def move_to_stopwatch_tab(self):
72
 
        tabs_bar = self.get_tabs()
73
 
 
74
 
        x, y, w, h = tabs_bar.globalRect
75
 
        tx = x + w / 10
76
 
        ty = y + h / 2
77
 
        self.pointing_device.drag(tx, ty, w - 10, ty)
78
 
 
79
 
        stopwatch_tab_button = self.main_window.get_stopwatch_tab_button()
80
 
 
81
 
        self.assertThat(stopwatch_tab_button.opacity, Eventually(GreaterThan(0.35)))
82
 
        self.pointing_device.click_object(stopwatch_tab_button)    
83
 
    
 
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()
 
111
 
84
112
    def move_to_timer_tab(self):
85
 
        tabs_bar = self.get_tabs()
86
 
 
87
 
        x, y, w, h = tabs_bar.globalRect
88
 
        tx = x + w / 10
89
 
        ty = y + h / 2
90
 
        self.pointing_device.drag(tx, ty, w - 9, ty)
91
 
 
92
 
        timer_tab_button = self.main_window.get_timer_tab_button()
93
 
 
94
 
        self.assertThat(timer_tab_button.opacity, Eventually(GreaterThan(0.35)))
95
 
        self.pointing_device.click_object(timer_tab_button)  
96
 
 
 
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()
97
117
 
98
118
    @property
99
119
    def main_window(self):