Code review comment for lp:~carla-sella/ubuntu-clock-app/add-alarm-test

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

803 + def _select_single_alarm_day(self, index):
804 + """ function for selecting the day passed to the function.
805 +
806 + :param index: the day to be selected
807 +
808 + """
809 + dayCheckbox = self.wait_select_single(
810 + 'CheckBox', objectName='daySwitch{}'.format(index))
811 + if not dayCheckbox.checked:
812 + self.pointing_device.click_object(dayCheckbox)
813 +
814 + @autopilot_logging.log_action(logger.info)
815 + def unselect_selected_days(self):
816 + """ function for unselecting already selected days. """
817 + for index in range(self._get_num_of_days()):
818 + if self.wait_select_single(
819 + 'CheckBox', objectName='daySwitch{}'.format(index))\
820 + .checked:
821 + self.pointing_device.click_object(self.wait_select_single(
822 + 'CheckBox', objectName='daySwitch{}'.format(index)))
823 + break

In these 2 functions, you are using the IF loop to check if the switch is checked or not. Why not use the Ubuntu SDK helpers for this? http://developer.ubuntu.com/api/devel/ubuntu-14.10/python/autopilot-emulator/ubuntuuitoolkit.html#ubuntuuitoolkit.emulators.CheckBox has two functions check() and uncheck() which will automatically check and do the respective actions.

This would make it as simple as,

dayCheckbox.check()

or

dayCheckbox.uncheck()

review: Needs Fixing

« Back to merge proposal