42 + // FIXME: Currently autopilot can only get visual items, but once it is
43 + // updated to support non-visual items, a QtObject may be used.
Please add a link to http://pad.lv/1273956 so we know what you are referring to. Also, I find it useful to sign the FIXME comments, with something like --timp - 2014-03-19
637 + current_tab = tabs.get_current_tab()
638 + number_of_switches = 0
639 + while not tabs.selectedTabIndex == index:
640 + logger.debug(
641 + 'Current tab index: {0}.'.format(tabs.selectedTabIndex))
642 + if number_of_switches >= number_of_tabs - 1:
643 + # This prevents a loop. But if this error is ever raised, it's
644 + # likely there's a bug on the emulator or on the QML Tab.
645 + raise ToolkitEmulatorException(
646 + 'The tab with index {0} was not selected.'.format(index))
647 + current_tab = self.switch_to_next_tab()
648 + number_of_switches += 1
649 + return current_tab
You should move this into a method. You can call it something like _switch_to_deprecated_tab_by_index
42 + // FIXME: Currently autopilot can only get visual items, but once it is
43 + // updated to support non-visual items, a QtObject may be used.
Please add a link to http:// pad.lv/ 1273956 so we know what you are referring to. Also, I find it useful to sign the FIXME comments, with something like --timp - 2014-03-19
637 + current_tab = tabs.get_ current_ tab() bIndex == index: tabs.selectedTa bIndex) ) Exception( '.format( index)) to_next_ tab()
638 + number_of_switches = 0
639 + while not tabs.selectedTa
640 + logger.debug(
641 + 'Current tab index: {0}.'.format(
642 + if number_of_switches >= number_of_tabs - 1:
643 + # This prevents a loop. But if this error is ever raised, it's
644 + # likely there's a bug on the emulator or on the QML Tab.
645 + raise ToolkitEmulator
646 + 'The tab with index {0} was not selected.
647 + current_tab = self.switch_
648 + number_of_switches += 1
649 + return current_tab
You should move this into a method. You can call it something like _switch_ to_deprecated_ tab_by_ index
651 + if (index != tabs.selectedTa bIndex) : header( ).switch_ to_tab_ by_index( index) current_ tab()
652 + self.get_
653 + current_tab = tabs.get_
654 + return current_tab
This is not a big deal, but it would also make it clearer putting those statements on _switch_ to_tab_ in_drawer_ by_index
668 + return false
Typo. It's False.
677 + try: single( TabBar) undError: Exception( _NO_TABS_ ERROR) switch_ to_next_ tab() animating( ).wait_ for(False)
678 + tab_bar = self.select_
679 + except dbus.StateNotFo
680 + raise ToolkitEmulator
681 + tab_bar.
682 + self._get_
Same thing here ^
684 + try: single( 'AbstractButton ', objectName= 'tabsButton' ) undError: Exception( _NO_TABS_ ERROR) device. click_object( tabs_drawer_ button) properties = self.select_ single( 'QQuickItem' , objectName= 'tabsModelPrope rties') properties. selectedIndex + 1) % tabs_model_ properties. count root_instance( ).select_ single( 'Standard' , 'tabButton' +str(next_ tab_index) ) undError: Exception( "Tab button {0} not found." .format( next_tab_ index)) device. click_object( tab_button)
685 + tabs_drawer_button = self.select_
686 + except dbus.StateNotFo
687 + raise ToolkitEmulator
688 + self.pointing_
689 +
690 + tabs_model_
691 + next_tab_index = (tabs_model_
692 +
693 + try:
694 + tab_button = self.get_
695 + objectName=
696 + except dbus.StateNotFo
697 + raise ToolkitEmulator
698 +
699 + self.pointing_
and here ^. Please wrap them in something like _switch_ to_next_ deprecated_ tab, and _switch_ to_next_ tab_in_ drawer
4 + try: single( 'AbstractButton ', objectName= 'tabsButton' ) undError: Exception( _NO_TABS_ ERROR)
685 + tabs_drawer_button = self.select_
686 + except dbus.StateNotFo
687 + raise ToolkitEmulator
You can also move this ^
724 + try: root_instance( ).select_ single( 'Standard' , 'tabButton' +str(index) ) undError: Exception( "Tab button {0} not found." .format( index))
725 + tab_button = self.get_
726 + objectName=
727 + except dbus.StateNotFo
728 + raise ToolkitEmulator
and this ^ into a private methods, as you have the same statements twice.
755 +class DeprecatedTabsT estCase( TabsTestCase) :
I would prefer to do it with scenarios. Take a look at http:// paste.ubuntu. com/7121301/
I haven't tried it, but something like that should work.
702 + def switch_ to_tab_ by_index( self, index):
You are missing a test for this new method.
And some of your lines are too long. They will fail pep8.