~mihirsoni/ubuntu-calendar-app/dateSelectNewEventTest

« back to all changes in this revision

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

  • Committer: Mihir Soni
  • Date: 2014-10-24 12:55:20 UTC
  • Revision ID: mihirsoni.123@gmail.com-20141024125520-4qc4mx0p39z13ysa
Added time picker

Show diffs side-by-side

added added

removed removed

Lines of Context:
574
574
        # self._fill_to_date()
575
575
        if event_information.startDate is not None:
576
576
            self._fill_date(event_information.startDate, 'fromPicker')
 
577
        if event_information.startTime is not None:
 
578
            self._fill_time(event_information.startTime, 'fromPicker')
577
579
        if event_information.endDate is not None:
578
580
            self._fill_date(event_information.endDate, 'toPicker')
 
581
        if event_information.endTime is not None:
 
582
            self._fill_time(event_information.endTime, 'toPicker')
579
583
        if event_information.calendar is not None:
580
584
            self._select_calendar(event_information.calendar)
581
585
        if event_information.name is not None:
600
604
        date_to_pick = datetime.date(date.year, date.month, date.day)
601
605
        picker.pick_date(date_to_pick)
602
606
        self.pointing_device.click_object(dateButton)
 
607
    def _fill_time(self, date, object_name):
 
608
        picker = self.select_single(
 
609
            "NewEventTimePicker",
 
610
            objectName=object_name)
 
611
        timeButton = picker.select_single(
 
612
            NewEventEntryField,
 
613
            objectName="timeInput")
 
614
        self.pointing_device.click_object(timeButton)
 
615
        main_view = self.get_root_instance().select_single(MainView)
 
616
        picker = main_view.wait_select_single("DatePicker")
 
617
        time_to_pick = datetime.time(date.hour,date.minute)
 
618
        picker.pick_time(time_to_pick)
 
619
        self.pointing_device.click_object(timeButton)
603
620
 
604
621
    def _fill_name(self, value):
605
622
        self._ensure_entry_field_visible_and_write('newEventName', value)
609
626
        self._ensure_visible_and_write(name_text_field, value)
610
627
 
611
628
    def _get_new_event_entry_field(self, object_name):
612
 
        return self.select_single(NewEventEntryField, objectName=object_name)
 
629
        picker = self.select_single(
 
630
            "NewEventTimePicker",
 
631
            objectName=object_name)
 
632
        return picker.select_single(
 
633
            NewEventEntryField,
 
634
            objectName="dateInput")
613
635
 
614
636
    def _get_text_box(self, object_name):
615
637
        return self.select_single(
661
683
        for guest in guests:
662
684
            guest_names.append(guest.text)
663
685
        return guest_names
664
 
 
 
686
    def get_start_date(self):
 
687
        return self._get_new_event_entry_field("fromPicker").text
 
688
    def get_end_date(self):
 
689
        return self._get_new_event_entry_field("toPicker").text
665
690
    def get_calendar_name(self):
666
691
        return self._get_calendar().get_current_label().text
667
692
 
677
702
    def _get_form_values(self):
678
703
        # TODO get start date and end date, is all day event, recurrence and
679
704
        # reminders. --elopio - 2014-06-26
 
705
        startDate = self.get_start_date()
 
706
        endDate = self.get_end_date()
680
707
        calendar = self.get_calendar_name()
681
708
        name = self.get_event_name()
682
709
        description = self.get_description_text()
683
710
        location = self.get_location_name()
684
711
        guests = self._get_guests()
685
 
        return data.Event(calendar, name, description, location, guests)
 
712
        return data.Event(startDate, endDate, calendar, name, description, location, guests)
686
713
 
687
714
    @autopilot.logging.log_action(logger.info)
688
715
    def _save(self):
732
759
 
733
760
    def get_event_information(self):
734
761
        """Return the information of the event."""
 
762
        startDate = self.get_date()
 
763
        endDate = self.get_date()
735
764
        calendar = self._get_calendar()
736
765
        name = self._get_name()
737
766
        description = self._get_description()
738
767
        location = self._get_location()
739
768
        guests = self._get_guests()
740
 
        return data.Event(calendar, name, description, location, guests)
 
769
        return data.Event(startDate, endDate, calendar, name, description, location, guests)
 
770
 
 
771
    def get_date(self):
 
772
        return self._get_label_text("dateLabel")
741
773
 
742
774
    def _get_calendar(self):
743
775
        return self._get_label_text('calendarName').split(" ")[0]