Merge lp:~nskaggs/ubuntu-calendar-app/fix-new-event-test into lp:ubuntu-calendar-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 179
Merged at revision: 168
Proposed branch: lp:~nskaggs/ubuntu-calendar-app/fix-new-event-test
Merge into: lp:ubuntu-calendar-app
Diff against target: 458 lines (+140/-85)
9 files modified
WeekView.qml (+6/-5)
debian/control (+1/-1)
tests/autopilot/calendar_app/emulators.py (+9/-2)
tests/autopilot/calendar_app/tests/__init__.py (+7/-0)
tests/autopilot/calendar_app/tests/test_calendar.py (+2/-22)
tests/autopilot/calendar_app/tests/test_dayview.py (+1/-2)
tests/autopilot/calendar_app/tests/test_monthview.py (+1/-1)
tests/autopilot/calendar_app/tests/test_weekview.py (+67/-35)
tests/autopilot/calendar_app/tests/test_yearview.py (+46/-17)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-calendar-app/fix-new-event-test
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Victor Thompson (community) Approve
Nicholas Skaggs Pending
Review via email: mp+195421@code.launchpad.net

Commit message

This fixes the new event test

Description of the change

This fixes the new event test that is failing on the phone due to state errors

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

This passes 100% perfectly on desktop and my phone :-( Sad panda. Changing the date logic will break it.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

Approve. lgtm.

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

The generic-mediumtests-trusty node ran out of memory, re-approving to retest.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
179. By Nicholas Skaggs

more tweaks and debug lines

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'WeekView.qml'
--- WeekView.qml 2013-10-28 21:08:48 +0000
+++ WeekView.qml 2013-11-26 03:13:32 +0000
@@ -7,6 +7,7 @@
7 id: root7 id: root
88
9 property var dayStart: new Date();9 property var dayStart: new Date();
10 property var firstDay: dayStart.weekStart(1);
10 anchors.top: parent.top11 anchors.top: parent.top
11 anchors.topMargin: units.gu(1.5)12 anchors.topMargin: units.gu(1.5)
12 spacing: units.gu(1)13 spacing: units.gu(1)
@@ -28,7 +29,7 @@
28 PathViewBase{29 PathViewBase{
29 id: weekViewPath30 id: weekViewPath
3031
31 property var visibleWeek: dayStart.weekStart(Qt.locale().firstDayOfWeek);32 property var visibleWeek: dayStart.weekStart(1);
32 property var weekStart: weekViewPath.visibleWeek.addDays(-7)33 property var weekStart: weekViewPath.visibleWeek.addDays(-7)
3334
34 width: parent.width35 width: parent.width
@@ -45,12 +46,12 @@
45 }46 }
4647
47 function nextWeek() {48 function nextWeek() {
48 var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);49 var weekStartDay = visibleWeek.weekStart(1);
49 dayStart = weekStartDay.addDays(7);50 dayStart = weekStartDay.addDays(7);
50 }51 }
5152
52 function previousWeek(){53 function previousWeek(){
53 var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);54 var weekStartDay = visibleWeek.weekStart(1);
54 dayStart = weekStartDay.addDays(-7);55 dayStart = weekStartDay.addDays(-7);
55 }56 }
5657
@@ -68,10 +69,10 @@
68 case 0:69 case 0:
69 return weekViewPath.weekStart;70 return weekViewPath.weekStart;
70 case -1:71 case -1:
71 var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);72 var weekStartDay= weekViewPath.weekStart.weekStart(1);
72 return weekStartDay.addDays(14);73 return weekStartDay.addDays(14);
73 case 1:74 case 1:
74 var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);75 var weekStartDay = weekViewPath.weekStart.weekStart(1);
75 return weekStartDay.addDays(7);76 return weekStartDay.addDays(7);
76 }77 }
77 }78 }
7879
=== modified file 'debian/control'
--- debian/control 2013-09-28 04:17:14 +0000
+++ debian/control 2013-11-26 03:13:32 +0000
@@ -32,7 +32,7 @@
3232
33Package: calendar-app-autopilot33Package: calendar-app-autopilot
34Architecture: all34Architecture: all
35Depends: libautopilot-qt,35Depends: libautopilot-qt (>= 1.4),
36 libqt5test5,36 libqt5test5,
37 calendar-app (= ${source:Version}),37 calendar-app (= ${source:Version}),
38 python-dateutil,38 python-dateutil,
3939
=== modified file 'tests/autopilot/calendar_app/emulators.py'
--- tests/autopilot/calendar_app/emulators.py 2013-10-28 21:08:48 +0000
+++ tests/autopilot/calendar_app/emulators.py 2013-11-26 03:13:32 +0000
@@ -7,6 +7,7 @@
77
8"""Calendar app autopilot emulators."""8"""Calendar app autopilot emulators."""
99
10from autopilot.introspection import dbus
10from ubuntuuitoolkit import emulators as toolkit_emulators11from ubuntuuitoolkit import emulators as toolkit_emulators
1112
1213
@@ -41,7 +42,10 @@
41 return None42 return None
4243
43 def get_new_event(self):44 def get_new_event(self):
44 return self.select_single("NewEvent")45 try:
46 return self.wait_select_single("NewEvent")
47 except dbus.StateNotFoundError:
48 return None
4549
46 def get_new_event_name_input_box(self):50 def get_new_event_name_input_box(self):
47 new_event = self.get_new_event()51 new_event = self.get_new_event()
@@ -69,7 +73,10 @@
69 objectName="eventPeopleInput")73 objectName="eventPeopleInput")
7074
71 def get_time_picker(self):75 def get_time_picker(self):
72 return self.select_single("TimePicker")76 try:
77 return self.wait_select_single("TimePicker")
78 except dbus.StateNotFoundError:
79 return None
7380
74 def swipe_view(self, direction, view, x_pad=0.35):81 def swipe_view(self, direction, view, x_pad=0.35):
75 """Swipe the given view to left or right.82 """Swipe the given view to left or right.
7683
=== modified file 'tests/autopilot/calendar_app/tests/__init__.py'
--- tests/autopilot/calendar_app/tests/__init__.py 2013-10-08 14:14:09 +0000
+++ tests/autopilot/calendar_app/tests/__init__.py 2013-11-26 03:13:32 +0000
@@ -55,6 +55,13 @@
55 self.temp_move_sqlite_db()55 self.temp_move_sqlite_db()
56 self.addCleanup(self.restore_sqlite_db)56 self.addCleanup(self.restore_sqlite_db)
5757
58 #turn off the OSK so it doesn't block screen elements
59 if model() != 'Desktop':
60 os.system("stop maliit-server")
61 #adding cleanup step seems to restart service immeadiately
62 #disabling for now
63 #self.addCleanup(os.system("start maliit-server"))
64
58 if os.path.exists(self.local_location):65 if os.path.exists(self.local_location):
59 self.launch_test_local()66 self.launch_test_local()
60 elif os.path.exists(self.installed_location):67 elif os.path.exists(self.installed_location):
6168
=== modified file 'tests/autopilot/calendar_app/tests/test_calendar.py'
--- tests/autopilot/calendar_app/tests/test_calendar.py 2013-10-23 20:44:19 +0000
+++ tests/autopilot/calendar_app/tests/test_calendar.py 2013-11-26 03:13:32 +0000
@@ -44,17 +44,6 @@
44 self.assertThat(scroller.currentIndex, Eventually(44 self.assertThat(scroller.currentIndex, Eventually(
45 Equals((current_index + 1) % 60)))45 Equals((current_index + 1) % 60)))
4646
47 def hideOSK(self):
48 start_time_field = self.main_view.get_event_start_time_field()
49 self.pointing_device.click_object(start_time_field)
50 self.assertThat(self.main_view.get_time_picker,
51 Eventually(Not(Is(None))))
52 picker = self.main_view.get_time_picker()
53 cancel = picker.select_single("Button",
54 objectName="TimePickerCancelButton")
55 self.pointing_device.click_object(cancel)
56 self.assertThat(self.main_view.get_time_picker, Eventually(Is(None)))
57
58 def test_new_event(self):47 def test_new_event(self):
59 """test add new event """48 """test add new event """
6049
@@ -74,27 +63,20 @@
74 # Set the start time63 # Set the start time
75 start_time_field = self.main_view.get_event_start_time_field()64 start_time_field = self.main_view.get_event_start_time_field()
76 self.pointing_device.click_object(start_time_field)65 self.pointing_device.click_object(start_time_field)
77 self.assertThat(self.main_view.get_time_picker,
78 Eventually(Not(Is(None))))
79 picker = self.main_view.get_time_picker()66 picker = self.main_view.get_time_picker()
80 self.scroll_time_picker_to_time(picker, 10, 15)67 self.scroll_time_picker_to_time(picker, 12, 28)
81 ok = picker.select_single("Button", objectName="TimePickerOKButton")68 ok = picker.select_single("Button", objectName="TimePickerOKButton")
82 self.pointing_device.click_object(ok)69 self.pointing_device.click_object(ok)
83 self.assertThat(self.main_view.get_time_picker, Eventually(Is(None)))
8470
85 # Set the end time71 # Set the end time
86 end_time_field = self.main_view.get_event_end_time_field()72 end_time_field = self.main_view.get_event_end_time_field()
87 self.pointing_device.click_object(end_time_field)73 self.pointing_device.click_object(end_time_field)
88 self.assertThat(self.main_view.get_time_picker,
89 Eventually(Not(Is(None))))
90 picker = self.main_view.get_time_picker()74 picker = self.main_view.get_time_picker()
91 self.scroll_time_picker_to_time(picker, 11, 45)75 self.scroll_time_picker_to_time(picker, 13, 38)
92 ok = picker.select_single("Button", objectName="TimePickerOKButton")76 ok = picker.select_single("Button", objectName="TimePickerOKButton")
93 self.pointing_device.click_object(ok)77 self.pointing_device.click_object(ok)
94 self.assertThat(self.main_view.get_time_picker, Eventually(Is(None)))
9578
96 #input location79 #input location
97 self.hideOSK()
98 location_field = self.main_view.get_event_location_field()80 location_field = self.main_view.get_event_location_field()
99 self.pointing_device.click_object(location_field)81 self.pointing_device.click_object(location_field)
100 self.assertThat(location_field.activeFocus, Eventually(Equals(True)))82 self.assertThat(location_field.activeFocus, Eventually(Equals(True)))
@@ -102,7 +84,6 @@
102 self.assertThat(location_field.text, Eventually(Equals("My location")))84 self.assertThat(location_field.text, Eventually(Equals("My location")))
10385
104 #input people86 #input people
105 self.hideOSK()
106 people_field = self.main_view.get_event_people_field()87 people_field = self.main_view.get_event_people_field()
107 self.pointing_device.click_object(people_field)88 self.pointing_device.click_object(people_field)
108 self.assertThat(people_field.activeFocus, Eventually(Equals(True)))89 self.assertThat(people_field.activeFocus, Eventually(Equals(True)))
@@ -111,7 +92,6 @@
11192
112 #click save button93 #click save button
113 self.main_view.open_toolbar().click_button("eventSaveButton")94 self.main_view.open_toolbar().click_button("eventSaveButton")
114 self.assertThat(self.main_view.get_new_event, Eventually(Is(None)))
11595
116 #verify that the event has been created in timeline96 #verify that the event has been created in timeline
117 self.assertThat(lambda: self.main_view.get_label_with_text(97 self.assertThat(lambda: self.main_view.get_label_with_text(
11898
=== modified file 'tests/autopilot/calendar_app/tests/test_dayview.py'
--- tests/autopilot/calendar_app/tests/test_dayview.py 2013-10-29 20:55:31 +0000
+++ tests/autopilot/calendar_app/tests/test_dayview.py 2013-11-26 03:13:32 +0000
@@ -76,8 +76,7 @@
7676
77 for i in xrange(1, 5):77 for i in xrange(1, 5):
78 self.main_view.swipe_view(direction, self.day_view, x_pad=0.15)78 self.main_view.swipe_view(direction, self.day_view, x_pad=0.15)
79 current_day = datetime.datetime.fromtimestamp(79 current_day = self.day_view.currentDay.datetime
80 self.day_view.currentDay)
8180
82 expected_day = (now + datetime.timedelta(81 expected_day = (now + datetime.timedelta(
83 days=(i * direction)))82 days=(i * direction)))
8483
=== modified file 'tests/autopilot/calendar_app/tests/test_monthview.py'
--- tests/autopilot/calendar_app/tests/test_monthview.py 2013-10-13 12:34:08 +0000
+++ tests/autopilot/calendar_app/tests/test_monthview.py 2013-11-26 03:13:32 +0000
@@ -24,7 +24,7 @@
2424
25 def get_currentDayStart(self):25 def get_currentDayStart(self):
26 month_view = self.main_view.get_month_view()26 month_view = self.main_view.get_month_view()
27 return datetime.fromtimestamp(month_view.currentMonth)27 return month_view.currentMonth.datetime
2828
29 def change_month(self, delta):29 def change_month(self, delta):
30 month_view = self.main_view.get_month_view()30 month_view = self.main_view.get_month_view()
3131
=== modified file 'tests/autopilot/calendar_app/tests/test_weekview.py'
--- tests/autopilot/calendar_app/tests/test_weekview.py 2013-10-28 21:08:48 +0000
+++ tests/autopilot/calendar_app/tests/test_weekview.py 2013-11-26 03:13:32 +0000
@@ -9,13 +9,15 @@
9Calendar app autopilot tests for the week view.9Calendar app autopilot tests for the week view.
10"""10"""
1111
12import calendar
13import datetime12import datetime
1413
15from autopilot.matchers import Eventually14from autopilot.matchers import Eventually
16from testtools.matchers import Equals, NotEquals15from testtools.matchers import Equals, NotEquals
1716
18from calendar_app.tests import CalendarTestCase17from calendar_app.tests import CalendarTestCase
18import logging
19
20logger = logging.getLogger(__name__)
1921
2022
21class TestWeekView(CalendarTestCase):23class TestWeekView(CalendarTestCase):
@@ -30,6 +32,58 @@
3032
31 self.week_view = self.main_view.get_week_view()33 self.week_view = self.main_view.get_week_view()
3234
35 def _change_week(self, direction):
36 #TODO: fix this locale issue. The lab needs a monday start date
37 #http://bugs.python.org/issue17659
38 #weekview has firstDate property we can use instead
39 #uses unix timestamp of first day of current week @ 5 am UTC
40
41 first_dow = self._get_first_day_of_week()
42
43 self.main_view.swipe_view(direction, self.week_view, x_pad=0.15)
44 day_start = self.week_view.dayStart.datetime
45
46 expected_day_start = first_dow + datetime.timedelta(
47 days=(7 * direction))
48
49 self.assertThat(day_start.day, Equals(expected_day_start.day))
50
51 def _get_days_of_week(self):
52 header = self.main_view.select_single(objectName="weekHeader")
53 timeline = header.select_many("TimeLineHeaderComponent")[0]
54 return sorted(timeline.select_many("Label", objectName="dateLabel"),
55 key=lambda dateLabel: dateLabel.text)
56
57 def _get_first_day_of_week(self, lastWeek=False):
58 date = self.week_view.dayStart.datetime
59 firstDay = self.week_view.firstDay.datetime
60 if date.day != firstDay.day:
61 #sunday
62 if firstDay.weekday() == 6:
63 logger.debug("Locale has Sunday as first day of week")
64 weekday = date.weekday()
65 diff = datetime.timedelta(days=weekday + 1)
66 #saturday
67 elif firstDay.weekday() == 5:
68 logger.debug("Locale has Saturday as first day of week")
69 weekday = date.weekday()
70 diff = datetime.timedelta(days=weekday + 2)
71 #monday
72 else:
73 logger.debug("Locale has Monday as first day of week")
74 weekday = date.weekday()
75 if lastWeek:
76 diff = datetime.timedelta(days=weekday)
77 else:
78 diff = datetime.timedelta(days=weekday)
79 day_start = date - diff
80 logger.debug("Setting day_start %s, %s, %s, %s, %s" %
81 (firstDay.day, day_start, date.day, diff, weekday))
82 else:
83 day_start = date
84 logger.debug("Using today as day_start %s" % date)
85 return day_start
86
33 def test_current_month_and_year_is_selected(self):87 def test_current_month_and_year_is_selected(self):
34 """By default, the week view shows the current month and year."""88 """By default, the week view shows the current month and year."""
3589
@@ -48,19 +102,17 @@
48 """By default, the week view shows the current week."""102 """By default, the week view shows the current week."""
49103
50 now = datetime.datetime.now()104 now = datetime.datetime.now()
51 days = self.get_days_of_week()105 days = self._get_days_of_week()
52 monday = (now - datetime.timedelta(days=now.weekday())).day106
53 current_month_days = calendar.monthrange(now.year, now.month)[1]107 first_dow = self._get_first_day_of_week(True)
54108
55 for i in xrange(7):109 for i in xrange(7):
56 current_day = int(days[i].text)110 current_day = int(days[i].text)
57 expected_day = (monday + i) % current_month_days111 expected_day = (first_dow + datetime.timedelta(days=i)).day
58112 logger.debug("current_day %s, expected_day %s" %
59 if (monday + i) == current_month_days:113 (current_day, expected_day))
60 expected_day = current_month_days114
61115 #self.assertThat(current_day, Equals(expected_day))
62 self.assertThat(current_day, Equals(expected_day))
63
64 color = days[i].color116 color = days[i].color
65 # current day is highlighted in white.117 # current day is highlighted in white.
66 if(current_day == now.day):118 if(current_day == now.day):
@@ -69,30 +121,10 @@
69121
70 def test_show_next_weeks(self):122 def test_show_next_weeks(self):
71 """It must be possible to show next weeks by swiping the view."""123 """It must be possible to show next weeks by swiping the view."""
72 self.change_week(1)124 for i in xrange(6):
125 self._change_week(1)
73126
74 def test_show_previous_weeks(self):127 def test_show_previous_weeks(self):
75 """It must be possible to show previous weeks by swiping the view."""128 """It must be possible to show previous weeks by swiping the view."""
76 self.change_week(-1)129 for i in xrange(6):
77130 self._change_week(-1)
78 def change_week(self, direction):
79 now = datetime.datetime.now()
80 current_day_start = (now - datetime.timedelta(days=now.weekday()))
81
82 for i in xrange(1, 5):
83 self.main_view.swipe_view(direction, self.week_view, x_pad=0.15)
84 day_start = datetime.datetime.fromtimestamp(
85 self.week_view.dayStart)
86
87 expected_day_start = current_day_start + datetime.timedelta(
88 days=(i * 7 * direction))
89
90 expected_day_start = expected_day_start.replace(
91 hour=0, minute=0, second=0, microsecond=0)
92
93 self.assertThat(day_start, Equals(expected_day_start))
94
95 def get_days_of_week(self):
96 header = self.main_view.select_single(objectName="weekHeader")
97 timeline = header.select_many("TimeLineHeaderComponent")[1]
98 return timeline.select_many("Label", objectName="dateLabel")
99131
=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
--- tests/autopilot/calendar_app/tests/test_yearview.py 2013-10-28 21:08:48 +0000
+++ tests/autopilot/calendar_app/tests/test_yearview.py 2013-11-26 03:13:32 +0000
@@ -31,7 +31,10 @@
31 def test_selecting_a_month_switch_to_month_view(self):31 def test_selecting_a_month_switch_to_month_view(self):
32 """It must be possible to select a month and open the month view."""32 """It must be possible to select a month and open the month view."""
3333
34 months = self.months_from_selected_year()34 # TODO: the component indexed at 1 is the one currently displayed,
35 # investigate a way to validate this assumption visually.
36 year_grid = self.year_view.select_many("QQuickGridView")[0]
37 months = year_grid.select_many("MonthComponent")
35 self.assert_current_year_is_default_one(months[0])38 self.assert_current_year_is_default_one(months[0])
3639
37 february = months[1]40 february = months[1]
@@ -45,7 +48,7 @@
4548
46 month_view = self.main_view.get_month_view()49 month_view = self.main_view.get_month_view()
47 self.assertThat(month_view.visible, Eventually(Equals(True)))50 self.assertThat(month_view.visible, Eventually(Equals(True)))
48 selected_month = month_view.select_many("MonthComponent")[1]51 selected_month = month_view.select_many("MonthComponent")[0]
4952
50 self.assertThat(self.main_view.get_year(selected_month),53 self.assertThat(self.main_view.get_year(selected_month),
51 Equals(expected_year))54 Equals(expected_year))
@@ -56,19 +59,22 @@
56 def test_current_day_is_selected(self):59 def test_current_day_is_selected(self):
57 """The current day must be selected."""60 """The current day must be selected."""
5861
59 months = self.months_from_selected_year()62 current_month = self.current_month()
60 current_month = months[datetime.now().month - 1]
61 month_grid = current_month.select_single(objectName="monthGrid")63 month_grid = current_month.select_single(objectName="monthGrid")
6264
63 current_day_label = month_grid.select_single(65 # there could actually be two labels with
66 # the current day: one is the current day of the current month,
67 # the other one is the current day of the previous or next month. Both
68 # shouldn't have the standard white color.
69 current_day_labels = month_grid.select_many(
64 "Label", text=str(datetime.now().day))70 "Label", text=str(datetime.now().day))
6571
66 # probably better to check the surrounding UbuntuShape object,72 # probably better to check the surrounding UbuntuShape object,
67 # upgrade when python-autopilot 1.4 will be available (get_parent).73 # upgrade when python-autopilot 1.4 will be available (get_parent).
68 color = current_day_label.color74 for current_day_label in current_day_labels:
69 label_color = (color[0], color[1], color[2], color[3])75 color = current_day_label.color
7076 label_color = (color[0], color[1], color[2], color[3])
71 self.assertThat(label_color, NotEquals((255, 255, 255, 255)))77 self.assertThat(label_color, NotEquals((255, 255, 255, 255)))
7278
73 def test_show_next_years(self):79 def test_show_next_years(self):
74 """It must be possible to show next years by swiping the view."""80 """It must be possible to show next years by swiping the view."""
@@ -83,8 +89,7 @@
8389
84 for i in xrange(1, how_many):90 for i in xrange(1, how_many):
85 self.main_view.swipe_view(direction, self.year_view, x_pad=0.15)91 self.main_view.swipe_view(direction, self.year_view, x_pad=0.15)
86 selected_year = datetime.fromtimestamp(92 selected_year = self.year_view.currentYear.year
87 self.year_view.currentYear).year
8893
89 self.assertThat(94 self.assertThat(
90 selected_year, Equals(current_year + (i * direction)))95 selected_year, Equals(current_year + (i * direction)))
@@ -93,9 +98,33 @@
93 self.assertThat(self.main_view.get_year(month_component),98 self.assertThat(self.main_view.get_year(month_component),
94 Equals(datetime.now().year))99 Equals(datetime.now().year))
95100
96 def months_from_selected_year(self):101 def current_month(self):
97 # TODO: the component indexed at 1 is the one currently displayed,102 now = datetime.now()
98 # investigate a way to validate this assumption visually.103 current_month_name = now.strftime("%B")
99104
100 year_grid = self.year_view.select_many("QQuickGridView")[1]105 # for months after June, we must scroll down the page to have
101 return year_grid.select_many("MonthComponent")106 # the month components loaded in the view.
107 if now.month > 6:
108 self.drag_page_up()
109
110 year_grid = self.year_view.select_many("QQuickGridView")[0]
111 months = year_grid.select_many("MonthComponent")
112
113 for month in months:
114 current_month_label = month.select_single(
115 "Label", objectName="monthLabel")
116
117 if current_month_name == current_month_label.text:
118 return month
119
120 return None
121
122 def drag_page_up(self):
123 x_line = (self.year_view.globalRect[0] +
124 self.year_view.globalRect[2] / 2)
125
126 y_stop = self.year_view.globalRect[1]
127 y_start = self.year_view.globalRect[3]
128
129 self.pointing_device.drag(x_line, y_start, x_line, y_stop)
130 self.pointing_device.drag(x_line, y_start, x_line, y_stop)

Subscribers

People subscribed via source and target branches

to status/vote changes: