Merge lp:~om26er/ubuntu-calendar-app/robust_test into lp:~pkunal-parmar/ubuntu-calendar-app/newtabs_dayview

Proposed by Omer Akram
Status: Merged
Approved by: Kunal Parmar
Approved revision: 98
Merged at revision: 100
Proposed branch: lp:~om26er/ubuntu-calendar-app/robust_test
Merge into: lp:~pkunal-parmar/ubuntu-calendar-app/newtabs_dayview
Diff against target: 64 lines (+8/-3)
3 files modified
DayView.qml (+1/-0)
tests/autopilot/calendar_app/emulators/main_view.py (+1/-1)
tests/autopilot/calendar_app/tests/test_calendar.py (+6/-2)
To merge this branch: bzr merge lp:~om26er/ubuntu-calendar-app/robust_test
Reviewer Review Type Date Requested Status
Kunal Parmar Approve
Review via email: mp+181839@code.launchpad.net

Commit message

fixes the failing test for the calendar app

Description of the change

fastens the tests, does not fix it. I have tried hard but cannot fix it the test. The calendar app needs to expose the properties of the newly created event so that we could test.

To post a comment you must log in.
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

looks good,

Can you check, what's wrong with following

Here, timeline_base.eventCount is always returning 0, where in QML is gets updates after sometime.
Is there way to overcome this ?

    def event_count_for_dayview(self):
        #retuns event count for dayview
        day_view = self.main_view.get_day_view()
        self.assertThat(lambda: day_view, Eventually(Not(Is(None))))

        path_base = day_view.select_single("PathViewBase",
                                           objectName="DayViewPathBase")
        current_index = path_base.currentIndex
        com_name = "DayComponent-" + str(current_index)
        #print("Comp Name:" , com_name)
        day_component = path_base.select_single("DayComponent",
                                                objectName=com_name)
        self.assertThat(lambda: day_component, Eventually(Not(Is(None))))

        timeline_base = day_component.select_single("TimeLineBase",
                                                    objectName="timeLineBase")
        self.assertThat(lambda: timeline_base, Eventually(Not(Is(None))))

        print("Event count:", timeline_base.eventCount)
        return (timeline_base.eventCount)

review: Approve
Revision history for this message
Omer Akram (om26er) wrote :

fixed the test now, It seems I just needed a fresh day to start with :) You need to manually merge this branch into your branch.

99. By Omer Akram

fix the failing test

Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

ok, thanks, I was waiting that it will merge by itself.

Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

Anyway, Just for information.

Can you tell me how to resolve above problem with getting eventCount ?

print("Event count:", timeline_base.eventCount)

Revision history for this message
Omer Akram (om26er) wrote :

Can you show the complete source code where you have created event_count_for_dayview() since I believe you must have added other changes to the app as well for this method to work, like objectNames for a few things.

Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

I removed the source code which I was refering, as you fix the original problem. I will create another branch to reproduce this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DayView.qml'
2--- DayView.qml 2013-08-24 03:41:04 +0000
3+++ DayView.qml 2013-08-24 12:04:26 +0000
4@@ -85,6 +85,7 @@
5
6 delegate: DayComponent {
7 id: timeLineView
8+ objectName: "day"
9
10 objectName: "DayComponent-"+index
11
12
13=== modified file 'tests/autopilot/calendar_app/emulators/main_view.py'
14--- tests/autopilot/calendar_app/emulators/main_view.py 2013-08-24 03:41:04 +0000
15+++ tests/autopilot/calendar_app/emulators/main_view.py 2013-08-24 12:04:26 +0000
16@@ -26,7 +26,7 @@
17 return self.select_single("DayView")
18
19 def get_title_label(self, title):
20- return self.select_single("Label", text=title)
21+ return self.select_many("Label", text=title)[0]
22
23 def get_new_event(self):
24 return self.select_single("NewEvent")
25
26=== modified file 'tests/autopilot/calendar_app/tests/test_calendar.py'
27--- tests/autopilot/calendar_app/tests/test_calendar.py 2013-08-24 03:41:04 +0000
28+++ tests/autopilot/calendar_app/tests/test_calendar.py 2013-08-24 12:04:26 +0000
29@@ -14,6 +14,7 @@
30 from testtools.matchers import Equals, Not, Is
31
32 import time
33+import datetime
34
35 from calendar_app.tests import CalendarTestCase
36
37@@ -62,6 +63,9 @@
38
39 def test_new_event(self):
40 """test add new event """
41+ now = datetime.datetime.now()
42+ hour = now.hour
43+ minute = now.minute
44
45 count_before_insert = self.event_count_for_dayview()
46
47@@ -84,7 +88,7 @@
48 self.assertThat(self.main_view.get_time_picker,
49 Eventually(Not(Is(None))))
50 picker = self.main_view.get_time_picker()
51- self.scroll_time_picker_to_time(picker, 10, 15)
52+ self.scroll_time_picker_to_time(picker, hour, minute+2)
53 ok = picker.select_single("Button", objectName="TimePickerOKButton")
54 self.pointing_device.click_object(ok)
55 self.assertThat(self.main_view.get_time_picker, Eventually(Is(None)))
56@@ -95,7 +99,7 @@
57 self.assertThat(self.main_view.get_time_picker,
58 Eventually(Not(Is(None))))
59 picker = self.main_view.get_time_picker()
60- self.scroll_time_picker_to_time(picker, 11, 45)
61+ self.scroll_time_picker_to_time(picker, hour+1, minute+2)
62 ok = picker.select_single("Button", objectName="TimePickerOKButton")
63 self.pointing_device.click_object(ok)
64 self.assertThat(self.main_view.get_time_picker, Eventually(Is(None)))

Subscribers

People subscribed via source and target branches

to all changes: