Merge lp:~pkunal-parmar/ubuntu-calendar-app/nextYearFix into lp:ubuntu-calendar-app

Proposed by Kunal Parmar
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 194
Merged at revision: 195
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/nextYearFix
Merge into: lp:ubuntu-calendar-app
Diff against target: 195 lines (+32/-23)
7 files modified
MonthView.qml (+4/-2)
PathViewBase.qml (+5/-4)
TimeLineHeader.qml (+1/-1)
WeekView.qml (+2/-2)
YearView.qml (+4/-8)
tests/autopilot/calendar_app/tests/test_weekview.py (+2/-1)
tests/autopilot/calendar_app/tests/test_yearview.py (+14/-5)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/nextYearFix
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+197624@code.launchpad.net

Commit message

Fix for "Buffered next year is wrong" from observation reported by jacekn on
https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1222846

"If I do it slowly and move it just enough to see the year it is initially showing previous year. Then when I scroll a bit more then is short lock up and year is update to what it should be."

Description of the change

Fix for "Buffered next year is wrong" from observation reported by jacekn on
https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1222846

"If I do it slowly and move it just enough to see the year it is initially showing previous year. Then when I scroll a bit more then is short lock up and year is update to what it should be."

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: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

This fixes the issue raised by Jacek. However this code could be made much easier to read. How about:

    property var year: getDateFromYear(getYear())
    function getYear() {
        switch( root.indexType(index)) {
        case 0:
            return currentYear.getFullYear() - 1
        case -1:
            return currentYear.getFullYear() + 1
        case 1:
            return currentYear.getFullYear()
        }
    }

And while we’re at it, I don’t understand how come case 0 is not for current year, -1 for previous and +1 for next, as function indexType(…) documents it. This is confusing, can you shed a light on this?

review: Needs Fixing
174. By Kunal Parmar

merge from trunk

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
175. By Kunal Parmar

PathView changed

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

> And while we’re at it, I don’t understand how come case 0 is not for current
> year, -1 for previous and +1 for next, as function indexType(…) documents it.
> This is confusing, can you shed a light on this?

This was the case due to how Path was created in PathView, now I changed path in pathview and it works as expected.

0 = visible item
-1 = previous item
1 = next item

Please review again

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

yearview horizontal scrolling fix

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

Autopilot for YearView fixed

178. By Kunal Parmar

weekview autopilot test fix

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

delay year update rollback

180. By Kunal Parmar

merge from trunk

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
Olivier Tilloy (osomon) wrote :

82 + //To make horizontal movement smooth, not using bindig for year
83 + /*Component.onCompleted: {
84 + year = getYear();
85 + }
86 +
87 + Connections{
88 + target:root
89 + onMovementEnded: {
90 + //update only when movement ends, to avoid calculation while animation
91 + year = getYear();
92 + }
93 + }*/
94 +

Is this commented out code a leftover? Can it be removed?

Revision history for this message
Olivier Tilloy (osomon) wrote :

71 QtObject{
72 id: intern
73 - property var startYear: getDateFromYear(currentYear.getFullYear()-1);
74 + property var startYear: currentYear;
75 }

It looks like this 'intern' object has become useless, can’t we remove it and replace all instances of intern.startYear with currentYear?

Revision history for this message
Olivier Tilloy (osomon) wrote :

121 months = year_grid.select_many("MonthComponent")
122 self.assert_current_year_is_default_one(months[0])
123
124 - february = months[1]
125 + february = months[0]

No way February is the first month of the year.
select_many(…) doesn’t guarantee the order of the returned elements, which is why it seems January doesn’t come first, so hardcoding the index of the month is unreliable and this test is flaky.
What you need to do is to sort the list of months using their properties before accessing them by index. Something like that:

  months.sort(key=lambda month: month.monthDate)

With that, you can revert the index change, you will be guaranteed that february == months[1]

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

> 82 + //To make horizontal movement smooth, not using bindig for
> year
> 83 + /*Component.onCompleted: {
> 84 + year = getYear();
> 85 + }
> 86 +
> 87 + Connections{
> 88 + target:root
> 89 + onMovementEnded: {
> 90 + //update only when movement ends, to avoid
> calculation while animation
> 91 + year = getYear();
> 92 + }
> 93 + }*/
> 94 +
>
> Is this commented out code a leftover? Can it be removed?

Hi, I will remove it for now,
But it's possible, can you checkout this code and see how it works ?
This code I wrote to avoid lag while changing year by swiping left right. on my device it seems to work good, I commented out code as it was failing test case.

But if you find code it good then I can try to fix testcase instead and keep this code.

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

> 71 QtObject{
> 72 id: intern
> 73 - property var startYear:
> getDateFromYear(currentYear.getFullYear()-1);
> 74 + property var startYear: currentYear;
> 75 }
>
> It looks like this 'intern' object has become useless, can’t we remove it and
> replace all instances of intern.startYear with currentYear?

removed

181. By Kunal Parmar

Commented out code removed

182. By Kunal Parmar

Intern object in yearview removed

183. By Kunal Parmar

test case fix

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
Kunal Parmar (pkunal-parmar) wrote :

> 121 months = year_grid.select_many("MonthComponent")
> 122 self.assert_current_year_is_default_one(months[0])
> 123
> 124 - february = months[1]
> 125 + february = months[0]
>
> No way February is the first month of the year.
> select_many(…) doesn’t guarantee the order of the returned elements, which is
> why it seems January doesn’t come first, so hardcoding the index of the month
> is unreliable and this test is flaky.
> What you need to do is to sort the list of months using their properties
> before accessing them by index. Something like that:
>
> months.sort(key=lambda month: month.monthDate)
>

Done, can you review again
> With that, you can revert the index change, you will be guaranteed that
> february == months[1]

Revision history for this message
Olivier Tilloy (osomon) wrote :

> > 82 + //To make horizontal movement smooth, not using bindig for
> > year
> > 83 + /*Component.onCompleted: {
> > 84 + year = getYear();
> > 85 + }
> > 86 +
> > 87 + Connections{
> > 88 + target:root
> > 89 + onMovementEnded: {
> > 90 + //update only when movement ends, to avoid
> > calculation while animation
> > 91 + year = getYear();
> > 92 + }
> > 93 + }*/
> > 94 +
> >
> > Is this commented out code a leftover? Can it be removed?
>
> Hi, I will remove it for now,
> But it's possible, can you checkout this code and see how it works ?
> This code I wrote to avoid lag while changing year by swiping left right. on
> my device it seems to work good, I commented out code as it was failing test
> case.
>
> But if you find code it good then I can try to fix testcase instead and keep
> this code.

Let’s do this in a separate branch/MR, please. I’ll gladly test it then.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Because of bug #1268574 and bug #1268640, I fail to run the autopilot tests both locally and on my device (Galaxy Nexus). Therefore I cannot verify that this code doesn’t introduce regressions, even though it seems to fix the issue it claims it fixes.

Revision history for this message
Olivier Tilloy (osomon) wrote :

119 months = year_grid.select_many("MonthComponent")
120 self.assert_current_year_is_default_one(months[0])
121
122 + months.sort(key=lambda month: month.monthDate)

This works, but for corectness the sort should be done before asserting anything on the months:

    months = year_grid.select_many("MonthComponent")
    months.sort(key=lambda month: month.monthDate)
    self.assert_current_year_is_default_one(months[0])

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

105 + timeline = header.select_many("TimeLineHeaderComponent")[1]
118 + year_grid = self.year_view.select_many("QQuickGridView")[1]
131 + selected_month = month_view.select_many("MonthComponent")[1]
140 + year_grid = self.year_view.select_many("QQuickGridView")[1]

As I pointed out earlier, select_many(…) doesn’t guarantee the return order, so this might break at any point in time. If you want to get a specific component, either use specific properties like the objectName or a property that identifies it unambiguously, or sort the list returned by select_many(…) using an unambiguous key.

review: Needs Fixing
184. By Kunal Parmar

YearView autopilot text fix

185. By Kunal Parmar

Other testcase fixed

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

error resolved

187. By Kunal Parmar

pyflakes error resolved

188. By Kunal Parmar

pyflakes resolved

189. By Kunal Parmar

merge from trunk

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)
190. By Kunal Parmar

WeekView test case fix

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

trobleshooting test

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

test fail fixed

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
Kunal Parmar (pkunal-parmar) wrote :

> 105 + timeline = header.select_many("TimeLineHeaderComponent")[1]
> 118 + year_grid = self.year_view.select_many("QQuickGridView")[1]
> 131 + selected_month = month_view.select_many("MonthComponent")[1]
> 140 + year_grid = self.year_view.select_many("QQuickGridView")[1]
>
> As I pointed out earlier, select_many(…) doesn’t guarantee the return order,
> so this might break at any point in time. If you want to get a specific
> component, either use specific properties like the objectName or a property
> that identifies it unambiguously, or sort the list returned by select_many(…)
> using an unambiguous key.

I fixed hard coded index issue, kindly have another look

Revision history for this message
Olivier Tilloy (osomon) wrote :

130 + compArray = header.select_many("TimeLineHeaderComponent")
131 + timeline = None
132 +
133 + for tilelineComponent in compArray:
134 + if tilelineComponent.isCurrentItem:
135 + timeline = tilelineComponent
136 + break

Autopilot allows to do this in a much simpler way:

    timeline = header.select_single("TimeLineHeaderComponent", isCurrentItem=True)

The same applies to get_current_year() and to selected_month.

review: Needs Fixing
193. By Kunal Parmar

Merge from trunk

194. By Kunal Parmar

review comment

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
Olivier Tilloy (osomon) wrote :

Looks good now, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MonthView.qml'
--- MonthView.qml 2014-01-09 23:15:57 +0000
+++ MonthView.qml 2014-02-10 13:56:10 +0000
@@ -14,7 +14,7 @@
14 PathViewBase{14 PathViewBase{
15 id: monthViewPath15 id: monthViewPath
1616
17 property var startMonth: addMonth(currentMonth,-1);17 property var startMonth: currentMonth;
1818
19 anchors.top:parent.top19 anchors.top:parent.top
2020
@@ -44,6 +44,8 @@
44 }44 }
4545
46 delegate: MonthComponent{46 delegate: MonthComponent{
47 property bool isCurrentItem: index === monthViewPath.currentIndex
48
47 width: parent.width - units.gu(5)49 width: parent.width - units.gu(5)
48 height: parent.height - units.gu(5)50 height: parent.height - units.gu(5)
4951
@@ -54,7 +56,7 @@
54 case 0:56 case 0:
55 return monthViewPath.startMonth;57 return monthViewPath.startMonth;
56 case -1:58 case -1:
57 return monthViewPath.addMonth(monthViewPath.startMonth,2);59 return monthViewPath.addMonth(monthViewPath.startMonth,-1);
58 case 1:60 case 1:
59 return monthViewPath.addMonth(monthViewPath.startMonth,1);61 return monthViewPath.addMonth(monthViewPath.startMonth,1);
60 }62 }
6163
=== modified file 'PathViewBase.qml'
--- PathViewBase.qml 2013-09-16 14:04:01 +0000
+++ PathViewBase.qml 2014-02-10 13:56:10 +0000
@@ -9,11 +9,12 @@
9 signal nextItemHighlighted();9 signal nextItemHighlighted();
10 signal previousItemHighlighted();10 signal previousItemHighlighted();
1111
12 preferredHighlightBegin: 0.5
13 preferredHighlightEnd: 0.5
14
12 path: Path {15 path: Path {
13 startX: -(root.width/2); startY: root.height/216 startX: -(root.width); startY: root.height/2
14 PathLine { relativeX: root.width; relativeY: 0 }17 PathLine { x: (root.width)*2 ; relativeY: 0; }
15 PathLine { relativeX: root.width; relativeY: 0 }
16 PathLine { relativeX: root.width; relativeY: 0 }
17 }18 }
1819
19 // 0= current index, -1= previous index, 1 next index20 // 0= current index, -1= previous index, 1 next index
2021
=== modified file 'TimeLineHeader.qml'
--- TimeLineHeader.qml 2013-09-28 09:37:52 +0000
+++ TimeLineHeader.qml 2014-02-10 13:56:10 +0000
@@ -64,7 +64,7 @@
64 case 0:64 case 0:
65 return date;65 return date;
66 case -1:66 case -1:
67 return date.addDays(14);67 return date.addDays(-7);
68 case 1:68 case 1:
69 return date.addDays(7);69 return date.addDays(7);
70 }70 }
7171
=== modified file 'WeekView.qml'
--- WeekView.qml 2014-01-28 01:51:29 +0000
+++ WeekView.qml 2014-02-10 13:56:10 +0000
@@ -31,7 +31,7 @@
31 id: weekViewPath31 id: weekViewPath
3232
33 property var visibleWeek: dayStart.weekStart(Qt.locale().firstDayOfWeek);33 property var visibleWeek: dayStart.weekStart(Qt.locale().firstDayOfWeek);
34 property var weekStart: weekViewPath.visibleWeek.addDays(-7)34 property var weekStart: weekViewPath.visibleWeek
3535
36 width: parent.width36 width: parent.width
37 height: root.height - weekViewPath.y37 height: root.height - weekViewPath.y
@@ -71,7 +71,7 @@
71 return weekViewPath.weekStart;71 return weekViewPath.weekStart;
72 case -1:72 case -1:
73 var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);73 var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
74 return weekStartDay.addDays(14);74 return weekStartDay.addDays(-7);
75 case 1:75 case 1:
76 var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);76 var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
77 return weekStartDay.addDays(7);77 return weekStartDay.addDays(7);
7878
=== modified file 'YearView.qml'
--- YearView.qml 2014-01-09 23:15:57 +0000
+++ YearView.qml 2014-02-10 13:56:10 +0000
@@ -25,25 +25,21 @@
25 return new Date(year,0,1,0,0,0,0);25 return new Date(year,0,1,0,0,0,0);
26 }26 }
2727
28 QtObject{
29 id: intern
30 property var startYear: getDateFromYear(currentYear.getFullYear()-1);
31 }
32
33 delegate: GridView{28 delegate: GridView{
34 id: yearView29 id: yearView
35 clip: true30 clip: true
3631
32 property bool isCurrentItem: index == root.currentIndex
37 property var year: getYear();33 property var year: getYear();
3834
39 function getYear() {35 function getYear() {
40 switch( root.indexType(index)) {36 switch( root.indexType(index)) {
41 case 0:37 case 0:
42 return intern.startYear;38 return currentYear;
43 case -1:39 case -1:
44 return getDateFromYear(intern.startYear.getFullYear() - 1);40 return getDateFromYear(currentYear.getFullYear() - 1);
45 case 1:41 case 1:
46 return getDateFromYear(intern.startYear.getFullYear() + 1);42 return getDateFromYear(currentYear.getFullYear() + 1);
47 }43 }
48 }44 }
4945
5046
=== modified file 'tests/autopilot/calendar_app/tests/test_weekview.py'
--- tests/autopilot/calendar_app/tests/test_weekview.py 2014-01-09 23:30:55 +0000
+++ tests/autopilot/calendar_app/tests/test_weekview.py 2014-02-10 13:56:10 +0000
@@ -70,7 +70,8 @@
7070
71 def _get_date_label_headers(self):71 def _get_date_label_headers(self):
72 header = self.main_view.select_single(objectName="weekHeader")72 header = self.main_view.select_single(objectName="weekHeader")
73 timeline = header.select_many("TimeLineHeaderComponent")[0]73 timeline = header.select_single("TimeLineHeaderComponent",
74 isCurrentItem=True)
74 dateLabels = timeline.select_many("Label", objectName="dateLabel")75 dateLabels = timeline.select_many("Label", objectName="dateLabel")
75 return dateLabels76 return dateLabels
7677
7778
=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
--- tests/autopilot/calendar_app/tests/test_yearview.py 2014-01-09 23:28:15 +0000
+++ tests/autopilot/calendar_app/tests/test_yearview.py 2014-02-10 13:56:10 +0000
@@ -10,7 +10,6 @@
10"""10"""
1111
12from datetime import datetime12from datetime import datetime
13
14from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
15from testtools.matchers import Equals, NotEquals14from testtools.matchers import Equals, NotEquals
1615
@@ -28,13 +27,19 @@
2827
29 self.year_view = self.main_view.get_year_view()28 self.year_view = self.main_view.get_year_view()
3029
30 def get_current_year(self):
31 return self.year_view.select_single("QQuickGridView",
32 isCurrentItem=True)
33
31 def test_selecting_a_month_switch_to_month_view(self):34 def test_selecting_a_month_switch_to_month_view(self):
32 """It must be possible to select a month and open the month view."""35 """It must be possible to select a month and open the month view."""
3336
34 # TODO: the component indexed at 1 is the one currently displayed,37 # TODO: the component indexed at 1 is the one currently displayed,
35 # investigate a way to validate this assumption visually.38 # investigate a way to validate this assumption visually.
36 year_grid = self.year_view.select_many("QQuickGridView")[0]39 year_grid = self.get_current_year()
40 self.assertThat(year_grid, NotEquals(None))
37 months = year_grid.select_many("MonthComponent")41 months = year_grid.select_many("MonthComponent")
42 months.sort(key=lambda month: month.monthDate)
38 self.assert_current_year_is_default_one(months[0])43 self.assert_current_year_is_default_one(months[0])
3944
40 february = months[1]45 february = months[1]
@@ -48,7 +53,11 @@
4853
49 month_view = self.main_view.get_month_view()54 month_view = self.main_view.get_month_view()
50 self.assertThat(month_view.visible, Eventually(Equals(True)))55 self.assertThat(month_view.visible, Eventually(Equals(True)))
51 selected_month = month_view.select_many("MonthComponent")[0]56
57 selected_month = month_view.select_single("MonthComponent",
58 isCurrentItem=True)
59
60 self.assertThat(selected_month, NotEquals(None))
5261
53 self.assertThat(self.main_view.get_year(selected_month),62 self.assertThat(self.main_view.get_year(selected_month),
54 Equals(expected_year))63 Equals(expected_year))
@@ -108,13 +117,13 @@
108 if now.month > 6:117 if now.month > 6:
109 self.drag_page_up()118 self.drag_page_up()
110119
111 year_grid = self.year_view.select_many("QQuickGridView")[0]120 year_grid = self.get_current_year()
121 self.assertThat(year_grid, NotEquals(None))
112 months = year_grid.select_many("MonthComponent")122 months = year_grid.select_many("MonthComponent")
113123
114 for month in months:124 for month in months:
115 current_month_label = month.select_single(125 current_month_label = month.select_single(
116 "Label", objectName="monthLabel")126 "Label", objectName="monthLabel")
117
118 if current_month_name == current_month_label.text:127 if current_month_name == current_month_label.text:
119 return month128 return month
120129

Subscribers

People subscribed via source and target branches

to status/vote changes: