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

Proposed by Kunal Parmar
Status: Merged
Approved by: Francis Ginther
Approved revision: 74
Merged at revision: 77
Proposed branch: lp:~pkunal-parmar/ubuntu-calendar-app/today
Merge into: lp:ubuntu-calendar-app
Diff against target: 183 lines (+138/-0)
5 files modified
MonthView.qml (+6/-0)
calendar.qml (+7/-0)
debian/control (+1/-0)
tests/autopilot/calendar_app/emulators/main_window.py (+3/-0)
tests/autopilot/calendar_app/tests/test_monthview.py (+121/-0)
To merge this branch: bzr merge lp:~pkunal-parmar/ubuntu-calendar-app/today
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Olivier Tilloy (community) Approve
Kunal Parmar Needs Resubmitting
Michael Zanetti (community) Needs Fixing
Review via email: mp+169436@code.launchpad.net

Commit message

Jump to today, feature implemented

Description of the change

Jump to today, feature implemented

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 doesn’t work if I’m looking at the same month next year (e.g. swipe left 12 times to browse to June 2014, and then click the Today button).

As a side note, this is typically the functionality that would greatly benefit from an associated autopilot test, do you think you could add one (that would cover the normal use cases as well as the "corner" cases like the one I’ve described above). If you need help writing autopilot tests, do not hesitate to ask Omer Akram (om26er on IRC) or myself. Cheers!

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

> This doesn’t work if I’m looking at the same month next year (e.g. swipe left
> 12 times to browse to June 2014, and then click the Today button).
>
> As a side note, this is typically the functionality that would greatly benefit
> from an associated autopilot test, do you think you could add one (that would
> cover the normal use cases as well as the "corner" cases like the one I’ve
> described above). If you need help writing autopilot tests, do not hesitate to
> ask Omer Akram (om26er on IRC) or myself. Cheers!

Ahh, I never tested that test case, thought from code it was quite evident that it will not work for same month.

I fixed this, but I am yet to implement test case for it. Yes, I agree that test case will help greatly.

I checked code and looks like, current month view implementation does not allow user to browse more then 24 month in one direction. I guess we will need to make changes to allow browse as much as user wanted, and we will need test case that time.

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (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
Kunal Parmar (pkunal-parmar) wrote :

> > This doesn’t work if I’m looking at the same month next year (e.g. swipe
> left
> > 12 times to browse to June 2014, and then click the Today button).
> >
> > As a side note, this is typically the functionality that would greatly
> benefit
> > from an associated autopilot test, do you think you could add one (that
> would
> > cover the normal use cases as well as the "corner" cases like the one I’ve
> > described above). If you need help writing autopilot tests, do not hesitate
> to
> > ask Omer Akram (om26er on IRC) or myself. Cheers!
>
> Ahh, I never tested that test case, thought from code it was quite evident
> that it will not work for same month.
>
> I fixed this, but I am yet to implement test case for it. Yes, I agree that
> test case will help greatly.
>
> I checked code and looks like, current month view implementation does not
> allow user to browse more then 24 month in one direction. I guess we will need
> to make changes to allow browse as much as user wanted, and we will need test
> case that time.

There is some bug with AutoPilot system, which prevent testcase from getting any object property from QML.
like
readonly property var currentDayStart: intern.currentDayStart

Error I got is
AttributeError: Class 'MonthView' has no attribute 'currentDayStart'.

I talked with balloons and om26er and they will be trying to resolve the bug, but untill that is resolved, I am not able to create any meaning full test for this feature.

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
Nicholas Skaggs (nskaggs) wrote :
Revision history for this message
Michael Zanetti (mzanetti) wrote :

80 + start_x = month_view.x + month_view.width * 0.85
81 + stop_x = month_view.x + month_view.width * 0.15

This fails on screens with different resolutions because the mouse tries to move to a half pixel which it can't and gets stuck trying. Needs to be truncated/rounded to be an integer.

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> There is some bug with AutoPilot system, which prevent testcase from getting
> any object property from QML.
> like
> readonly property var currentDayStart: intern.currentDayStart
>
> Error I got is
> AttributeError: Class 'MonthView' has no attribute 'currentDayStart'.
>
> I talked with balloons and om26er and they will be trying to resolve the bug,
> but untill that is resolved, I am not able to create any meaning full test for
> this feature.

Well, its not really a bug. More like a limitation because we are mixing C++ and python through a D-Bus interface and there is no straigt forward conversion between a QDateTime, through an integer and then to a python datetime. I'm exploring into solution for this though, maybe we can prefix it somehow internally to make python-autopilot recognize it as a datetime and automaticaly convert it.

Anyways, to still write some tests in the meantime you can use things like this:

QtObject {
  id: intern
  property monthStart: monthView.monthStart.valueOf()
}

That would give you a monthStart property containing an integer (unix timestamp) which you can convert back to a datetime object in python.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Please try this autopilot-qt branch. That should allow you to introspect your Date properties:

lp:~mzanetti/autopilot-qt/add-date-time-introspection

In the autopilot test, you will get Date as an integer (seconds since 1970-01-01T00:00:00). You can convert them back to a datetime object in python by using for example

time.ctime(self.main_window.get_month_view().monthStart)

Please let me know how it works.

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

I tried your branch and seems now currentDayStart is indeed being exposed.

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

> Please try this autopilot-qt branch. That should allow you to introspect your
> Date properties:
>
> lp:~mzanetti/autopilot-qt/add-date-time-introspection
>
> In the autopilot test, you will get Date as an integer (seconds since
> 1970-01-01T00:00:00). You can convert them back to a datetime object in python
> by using for example
>
> time.ctime(self.main_window.get_month_view().monthStart)
>
> Please let me know how it works.

Hi, Thanks for support, I will check and update test case accordingly.

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

> > Please try this autopilot-qt branch. That should allow you to introspect
> your
> > Date properties:
> >
> > lp:~mzanetti/autopilot-qt/add-date-time-introspection
> >
> > In the autopilot test, you will get Date as an integer (seconds since
> > 1970-01-01T00:00:00). You can convert them back to a datetime object in
> python
> > by using for example
> >
> > time.ctime(self.main_window.get_month_view().monthStart)
> >
> > Please let me know how it works.
>
> Hi, Thanks for support, I will check and update test case accordingly.

Hi, I checked the autopilot fix, and it works great. Thanks :)

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 :

The functionality seems to work nicely now, good job!
However the autopilot tests are failing with the following error:

    AttributeError: Class 'MonthView' has no attribute 'currentDayStart'.

This is the issue discussed above, but we cannot merge as is before the fix lands in autopilot-qt.
In order to get the functionality merged ASAP, one thing you could do is skip temporarily the tests, and re-enable them once the fix lands in autopilot-qt. You can skip a specific test method by decorating it like this:

    @unittest.skip("message to explain why we are skipping this test")
    def test_monthview_today_next_month(self):
        …

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

Some general remarks on the newly added autopilot tests:

 - it would be good to split them into a separate python file, so that each file contains a set of related tests (autopilot takes care of discovering all the tests even if they are spread over several files)

 - in changeMonth(…), I’d rather make direction an integer (with value=-1 for previous month, and 1 for next month), or rename the boolean to 'goToNextMonth' or something like that, that will make the code easier to understand
   as a bonus, if you use an integer, you won’t need conditional code to compute start_x and stop_x, just use the value as a multiplier

 - in changeMonth(…), "y_line = month_view.y + 300" this won’t work on all devices, you should probably do something like that:
        y_line = int(month_view.y + month_view.height / 2)

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> The functionality seems to work nicely now, good job!
> However the autopilot tests are failing with the following error:
>
> AttributeError: Class 'MonthView' has no attribute 'currentDayStart'.
>
> This is the issue discussed above, but we cannot merge as is before the fix
> lands in autopilot-qt.
> In order to get the functionality merged ASAP, one thing you could do is skip
> temporarily the tests, and re-enable them once the fix lands in autopilot-qt.
> You can skip a specific test method by decorating it like this:
>
> @unittest.skip("message to explain why we are skipping this test")
> def test_monthview_today_next_month(self):
> …

The fixed autopilot version should appear in saucy repositories tomorrow.

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

> The fixed autopilot version should appear in saucy repositories tomorrow.

Oh, that’s great news! In that case, Kunal please forget about my suggestion to skip the tests. However please consider my second comment to improve the implementation of the tests.

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

> > The fixed autopilot version should appear in saucy repositories tomorrow.
>
> Oh, that’s great news! In that case, Kunal please forget about my suggestion
> to skip the tests. However please consider my second comment to improve the
> implementation of the tests.

Sure, Thanks

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

> Some general remarks on the newly added autopilot tests:
>
> - it would be good to split them into a separate python file, so that each
> file contains a set of related tests (autopilot takes care of discovering all
> the tests even if they are spread over several files)
>
> - in changeMonth(…), I’d rather make direction an integer (with value=-1 for
> previous month, and 1 for next month), or rename the boolean to
> 'goToNextMonth' or something like that, that will make the code easier to
> understand
> as a bonus, if you use an integer, you won’t need conditional code to
> compute start_x and stop_x, just use the value as a multiplier
>
> - in changeMonth(…), "y_line = month_view.y + 300" this won’t work on all
> devices, you should probably do something like that:
> y_line = int(month_view.y + month_view.height / 2)

addressed above comment

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

> - in changeMonth(…), I’d rather make direction an integer (with value=-1 for
> previous month, and 1 for next month), or rename the boolean to
> 'goToNextMonth' or something like that, that will make the code easier to
> understand
> as a bonus, if you use an integer, you won’t need conditional code to
> compute start_x and stop_x, just use the value as a multiplier

You added a comment "direction 1 for next month, -1 for previous month", but then the parameter remains a boolean (and was renamed goToNextMonth). This is confusing, could you please clarify?

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

In changeMonth, why does the value of count defaults to -1? Wouldn’t it be easier to default to 0? You wouldn’t need any special handling of the value, as range(0, 0) generates an empty list.

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

Python nitpick: no need for range(0, count): range(count) is enough.

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

In changeMonth, the multipliers used for the swipe gesture are not symmetrical (should be 0.15 and 0.85, or 0.25 and 0.75), is that on purpose?

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

> In changeMonth, the multipliers used for the swipe gesture are not symmetrical
> (should be 0.15 and 0.85, or 0.25 and 0.75), is that on purpose?

I see consistent value in both IF ELSE, can you explain what you are suggesting?

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

> > In changeMonth, the multipliers used for the swipe gesture are not
> symmetrical
> > (should be 0.15 and 0.85, or 0.25 and 0.75), is that on purpose?
>
> I see consistent value in both IF ELSE, can you explain what you are
> suggesting?

Yes, the values are consistent, but they are not symmetrical. The center of the view being at (month_view.x + month_view.width * 0.5), it feels incorrect that the start position and the stop position of the swipe gesture are not symmetrical relative to the center:

    >>> abs(0.5 - 0.85)
    0.35
    >>> abs(0.5 - 0.25)
    0.25

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

You could simplify the code further by completely getting rid of the 'goToNextMonth' parameter, using the sign of 'count' as a multiplier (to get the sign of count, just use cmp(count, 0)).

That’s only a suggestion though, feel free to ignore.

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

> > > In changeMonth, the multipliers used for the swipe gesture are not
> > symmetrical
> > > (should be 0.15 and 0.85, or 0.25 and 0.75), is that on purpose?
> >
> > I see consistent value in both IF ELSE, can you explain what you are
> > suggesting?
>
> Yes, the values are consistent, but they are not symmetrical. The center of
> the view being at (month_view.x + month_view.width * 0.5), it feels incorrect
> that the start position and the stop position of the swipe gesture are not
> symmetrical relative to the center:
>
> >>> abs(0.5 - 0.85)
> 0.35
> >>> abs(0.5 - 0.25)
> 0.25

ok, I understand it now. Changed the values now and made it symmetrical.

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

> You could simplify the code further by completely getting rid of the
> 'goToNextMonth' parameter, using the sign of 'count' as a multiplier (to get
> the sign of count, just use cmp(count, 0)).
>
> That’s only a suggestion though, feel free to ignore.

This i will try some other time

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

Due to the latest changes in trunk, there are now conflicts when merging this branch. Can you please resolve them (by merging trunk back into your branch)?

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

> Due to the latest changes in trunk, there are now conflicts when merging this
> branch. Can you please resolve them (by merging trunk back into your branch)?
Yes, I also realized that I need to get latest code from trunk. I will update code and notify you

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

Hi Olivier,

I resolved the merge conflict and also made some other related changes.

But "UNSTABLE: http://91.189.93.70:8080/job/generic-mediumtests/95" jenkins is still complaining, with AttributeError: Class 'MonthView' has no attribute 'currentDayStart' error.

Do i need to do anything for this ?

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

In changeMonth(…), instead of adding self.ubuntusdk.get_qml_view().x and self.ubuntusdk.get_qml_view().y to all the coordinates, you should do something like that:

    x, y, w, h = self.main_window.get_month_view().globalRect
    y_line = int(y + h / 2)
    …
    start_x = int(x + w * 0.85)
    …

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

43 +// TODO: Following function is causing regression in monthview
44 +// It is affecting month view's layout and default date is select
45 +// Temporarily reverting changes
46 +//Date.prototype.midnight = function() {
47 +// var date = new Date(this)
48 +// date.setHours(0,0,0,0);
49 +// return date
50 +//}

You can’t just revert the function to its previous implementation, as it was buggy.
What regression exactly is it causing? Can’t it be addressed properly?

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

> Hi Olivier,
>
> I resolved the merge conflict and also made some other related changes.
>
> But "UNSTABLE: http://91.189.93.70:8080/job/generic-mediumtests/95" jenkins
> is still complaining, with AttributeError: Class 'MonthView' has no attribute
> 'currentDayStart' error.
>
> Do i need to do anything for this ?

I’m guessing that the latest version of autopilot-qt is not installed on the builder. Not much you can do about it, try pinging mzanetti on IRC.

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

> 43 +// TODO: Following function is causing regression in monthview
> 44 +// It is affecting month view's layout and default date is select
> 45 +// Temporarily reverting changes
> 46 +//Date.prototype.midnight = function() {
> 47 +// var date = new Date(this)
> 48 +// date.setHours(0,0,0,0);
> 49 +// return date
> 50 +//}
>
> You can’t just revert the function to its previous implementation, as it was
> buggy.
> What regression exactly is it causing? Can’t it be addressed properly?

That will need some time.

but the commented out code is affecting monthview's algorithm to calculate num of days and first day of month and like wise.

So in this case, person who made fixed should have make necessary changes in MonthView as well or should have left code as it is.

Following is snaps of problem
http://ubuntuone.com/7O0UlY3RAT4wvSxOctDpq4
http://ubuntuone.com/3CWSpaxJ15IynbOIACPJ6V
http://ubuntuone.com/5DVRYl8nhT8xuWc6n3nrXw

This is affecting my test case as well, as I am not able to check if month is changed or not after swiping.
As now sometimes after changing month start date is coming as 31 instead of 1.

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

> > Hi Olivier,
> >
> > I resolved the merge conflict and also made some other related changes.
> >
> > But "UNSTABLE: http://91.189.93.70:8080/job/generic-mediumtests/95" jenkins
> > is still complaining, with AttributeError: Class 'MonthView' has no
> attribute
> > 'currentDayStart' error.
> >
> > Do i need to do anything for this ?
>
> I’m guessing that the latest version of autopilot-qt is not installed on the
> builder. Not much you can do about it, try pinging mzanetti on IRC.

I’ve had a look at the logs of the CI run (http://91.189.93.70:8080/job/generic-mediumtests/96/console), and it appears the job is running on raring, and autopilot-qt must be pre-installed on the builder because it doesn’t appear anywhere in the logs. Which would explain why it’s not picking up the latest version that your branch requires.

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

> > 43 +// TODO: Following function is causing regression in monthview
> > 44 +// It is affecting month view's layout and default date is select
> > 45 +// Temporarily reverting changes
> > 46 +//Date.prototype.midnight = function() {
> > 47 +// var date = new Date(this)
> > 48 +// date.setHours(0,0,0,0);
> > 49 +// return date
> > 50 +//}
> >
> > You can’t just revert the function to its previous implementation, as it was
> > buggy.
> > What regression exactly is it causing? Can’t it be addressed properly?
>
> That will need some time.
>
> but the commented out code is affecting monthview's algorithm to calculate num
> of days and first day of month and like wise.
>
> So in this case, person who made fixed should have make necessary changes in
> MonthView as well or should have left code as it is.
>
> Following is snaps of problem
> http://ubuntuone.com/7O0UlY3RAT4wvSxOctDpq4
> http://ubuntuone.com/3CWSpaxJ15IynbOIACPJ6V
> http://ubuntuone.com/5DVRYl8nhT8xuWc6n3nrXw

Ah, got it, I’m now seeing the issue. In fact it exists in the latest trunk, so it should be fixed there, not worked around in your branch. I filed bug #1202366 to track the issue, I’m gonna look into it right away.

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

> > > 43 +// TODO: Following function is causing regression in monthview
> > > 44 +// It is affecting month view's layout and default date is select
> > > 45 +// Temporarily reverting changes
> > > 46 +//Date.prototype.midnight = function() {
> > > 47 +// var date = new Date(this)
> > > 48 +// date.setHours(0,0,0,0);
> > > 49 +// return date
> > > 50 +//}
> > >
> > > You can’t just revert the function to its previous implementation, as it
> was
> > > buggy.
> > > What regression exactly is it causing? Can’t it be addressed properly?
> >
> > That will need some time.
> >
> > but the commented out code is affecting monthview's algorithm to calculate
> num
> > of days and first day of month and like wise.
> >
> > So in this case, person who made fixed should have make necessary changes in
> > MonthView as well or should have left code as it is.
> >
> > Following is snaps of problem
> > http://ubuntuone.com/7O0UlY3RAT4wvSxOctDpq4
> > http://ubuntuone.com/3CWSpaxJ15IynbOIACPJ6V
> > http://ubuntuone.com/5DVRYl8nhT8xuWc6n3nrXw
>
> Ah, got it, I’m now seeing the issue. In fact it exists in the latest trunk,
> so it should be fixed there, not worked around in your branch. I filed bug
> #1202366 to track the issue, I’m gonna look into it right away.

Fixed by https://code.launchpad.net/~osomon/ubuntu-calendar-app/all-dates-local/+merge/175398.
Please review, so that we can merge it prior to your branch (and once it’s done, revert your changes to the midnight() function).

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> I’m guessing that the latest version of autopilot-qt is not installed on the
> builder. Not much you can do about it, try pinging mzanetti on IRC.

Not sure who exactly maintains the community app jenkins jobs. I think fginther should be able to help in keeping them up to date.

> I’ve had a look at the logs of the CI run (http://91.189.93.70:8080/job/generic-mediumtests/96/console), and it
> appears the job is running on raring, and autopilot-qt must be pre-installed on the builder because it doesn’t
> appear anywhere in the logs. Which would explain why it’s not picking up the latest version that your branch
> requires.

I guess you could also depend on libautopilot-qt >= 1.3daily13.06.25. Not sure if that's a good thing with the daily releases tho... Maybe I should have bumped the version manually when adding a feature. Anyways, I think the builders should be on Saucy anyways by now? Please ask fginther about that too.

Revision history for this message
David Planella (dpm) wrote :

Al 18/07/13 14:53, En/na Michael Zanetti ha escrit:
>> I’m guessing that the latest version of autopilot-qt is not installed on the
>> builder. Not much you can do about it, try pinging mzanetti on IRC.
>
> Not sure who exactly maintains the community app jenkins jobs. I think fginther should be able to help in keeping them up to date.
>

Yep, Francis is the maintainer, so he's the best person to ping.

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

> > > > 43 +// TODO: Following function is causing regression in monthview
> > > > 44 +// It is affecting month view's layout and default date is
> select
> > > > 45 +// Temporarily reverting changes
> > > > 46 +//Date.prototype.midnight = function() {
> > > > 47 +// var date = new Date(this)
> > > > 48 +// date.setHours(0,0,0,0);
> > > > 49 +// return date
> > > > 50 +//}
> > > >
> > > > You can’t just revert the function to its previous implementation, as it
> > was
> > > > buggy.
> > > > What regression exactly is it causing? Can’t it be addressed properly?
> > >
> > > That will need some time.
> > >
> > > but the commented out code is affecting monthview's algorithm to calculate
> > num
> > > of days and first day of month and like wise.
> > >
> > > So in this case, person who made fixed should have make necessary changes
> in
> > > MonthView as well or should have left code as it is.
> > >
> > > Following is snaps of problem
> > > http://ubuntuone.com/7O0UlY3RAT4wvSxOctDpq4
> > > http://ubuntuone.com/3CWSpaxJ15IynbOIACPJ6V
> > > http://ubuntuone.com/5DVRYl8nhT8xuWc6n3nrXw
> >
> > Ah, got it, I’m now seeing the issue. In fact it exists in the latest trunk,
> > so it should be fixed there, not worked around in your branch. I filed bug
> > #1202366 to track the issue, I’m gonna look into it right away.
>
> Fixed by https://code.launchpad.net/~osomon/ubuntu-calendar-app/all-dates-
> local/+merge/175398.
> Please review, so that we can merge it prior to your branch (and once it’s
> done, revert your changes to the midnight() function).

Hi, Thanks for fix, I reverted my changes and my test case are working fine now with fix.
Let me know if anything else is required,

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

It’s unclear to me whether the CI fails because of this or for another reason, but the logs report a number of errors and warnings when running pep8 on the python code (the autopilot tests). Can you please run it locally, ensure you fix all the errors and warnings reported, and push an update?

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

> It’s unclear to me whether the CI fails because of this or for another reason,
> but the logs report a number of errors and warnings when running pep8 on the
> python code (the autopilot tests). Can you please run it locally, ensure you
> fix all the errors and warnings reported, and push an update?

ran pep8 locally and make changes accordingly, I hope it works

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

There’s a remaining pyflake warning that needs addressing:

./tests/autopilot/calendar_app/tests/test_monthview.py:17: 'time' imported but unused

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 :

Found an issue with the PPA that supplies libautopilot-qt. It was missing the most recent updates. I've pushed over the new packages and should have this restarted shortly.

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 :

165 + if goToNextMonth is True:
166 + self.assertThat(dayAfterMonthChange.month,
167 + (Equals(startDay.month + count)))
168 + else:
169 + self.assertThat(dayAfterMonthChange.month,
170 + (Equals(startDay.month - count)))

This currently works because we’re in July, but when you run the tests in December they’re gonna start failing because 12 + n > 12 (for n being an integer > 0).
If you want to see it for yourself without changing your current date, add the following test:

    def test_monthview_change_month_fail(self):
        self.test_monthview_change_month(True, 9)

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

test_monthview_today(…) and test_monthview_change_month(…) need to be renamed (remove the "test_" prefix) so that autopilot doesn’t consider them standalone test methods.

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

119 + self.ubuntusdk.click_toolbar_button("Today")

153 + self.ubuntusdk.click_toolbar_button("Today")

Those shouldn’t be needed, as when the application starts the selected day is today by default, right?

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

> 119 + self.ubuntusdk.click_toolbar_button("Today")
>
> 153 + self.ubuntusdk.click_toolbar_button("Today")
>
> Those shouldn’t be needed, as when the application starts the selected day is
> today by default, right?

When application starts then default date is today, but does autopilot start application for each test case or it reuses the application ?

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

> 165 + if goToNextMonth is True:
> 166 + self.assertThat(dayAfterMonthChange.month,
> 167 + (Equals(startDay.month + count)))
> 168 + else:
> 169 + self.assertThat(dayAfterMonthChange.month,
> 170 + (Equals(startDay.month - count)))
>
> This currently works because we’re in July, but when you run the tests in
> December they’re gonna start failing because 12 + n > 12 (for n being an
> integer > 0).
> If you want to see it for yourself without changing your current date, add the
> following test:
>
> def test_monthview_change_month_fail(self):
> self.test_monthview_change_month(True, 9)

ok, not only month it also affect year, I fixed that as well. Now I am not trying to calculate month by arithmetic but by using python-dateutil.

testDate = startDay + relativedelta( months = +count )

I added dependency for python-dateutil under Package: calendar-app-autopilot, is that correct ?

I also added dependency

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

> test_monthview_today(…) and test_monthview_change_month(…) need to be renamed
> (remove the "test_" prefix) so that autopilot doesn’t consider them standalone
> test methods.

removed prefix

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

> > 119 + self.ubuntusdk.click_toolbar_button("Today")
> >
> > 153 + self.ubuntusdk.click_toolbar_button("Today")
> >
> > Those shouldn’t be needed, as when the application starts the selected day
> is
> > today by default, right?
>
> When application starts then default date is today, but does autopilot start
> application for each test case or it reuses the application ?

Yes, autopilot starts the application afresh for each test case, so it is safe to assume the initial state is clean.

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

> > 165 + if goToNextMonth is True:
> > 166 + self.assertThat(dayAfterMonthChange.month,
> > 167 + (Equals(startDay.month + count)))
> > 168 + else:
> > 169 + self.assertThat(dayAfterMonthChange.month,
> > 170 + (Equals(startDay.month - count)))
> >
> > This currently works because we’re in July, but when you run the tests in
> > December they’re gonna start failing because 12 + n > 12 (for n being an
> > integer > 0).
> > If you want to see it for yourself without changing your current date, add
> the
> > following test:
> >
> > def test_monthview_change_month_fail(self):
> > self.test_monthview_change_month(True, 9)
>
> ok, not only month it also affect year, I fixed that as well. Now I am not
> trying to calculate month by arithmetic but by using python-dateutil.
>
> testDate = startDay + relativedelta( months = +count )
>
> I added dependency for python-dateutil under Package: calendar-app-autopilot,
> is that correct ?
>
> I also added dependency

Yes, that’s correct.

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

144 + self.assertThat(dayAfterMonthChange.day, (Equals(startDay.day)))
145 + self.assertThat(dayAfterMonthChange.month, (Equals(startDay.month)))
146 + self.assertThat(dayAfterMonthChange.year, (Equals(startDay.year)))

There are extra parentheses around the Equals statements that can be safely removed.

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

Looks like the builder is out of space:

    dpkg-source: error: cannot create directory calendar-app-0.4: No space left on device

I’ll ping an admin to get this resolved.

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 issue has been resolved. reapproving.

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
1=== modified file 'MonthView.qml'
2--- MonthView.qml 2013-07-10 10:07:59 +0000
3+++ MonthView.qml 2013-07-23 16:09:23 +0000
4@@ -82,6 +82,12 @@
5 else intern.currentDayStart = dayStart
6 }
7
8+ function goToToday() {
9+ var today = (new Date()).midnight();
10+ intern.currentDayStart = today
11+ currentIndex= intern.monthIndex0
12+ }
13+
14 focus: true
15 Keys.onLeftPressed: decrementCurrentDay()
16 Keys.onRightPressed: incrementCurrentDay()
17
18=== modified file 'calendar.qml'
19--- calendar.qml 2013-07-12 16:38:49 +0000
20+++ calendar.qml 2013-07-23 16:09:23 +0000
21@@ -52,6 +52,13 @@
22 }
23 }
24 Action {
25+ iconSource: Qt.resolvedUrl("avatar.png");
26+ text: i18n.tr("Today");
27+ onTriggered: {
28+ monthView.goToToday();
29+ }
30+ }
31+ Action {
32 iconSource: Qt.resolvedUrl("avatar.png")
33 text: i18n.tr("Year view")
34 onTriggered: pageStack.push(yearView);
35
36=== modified file 'debian/control'
37--- debian/control 2013-06-17 11:22:34 +0000
38+++ debian/control 2013-07-23 16:09:23 +0000
39@@ -28,6 +28,7 @@
40 Depends: libautopilot-qt,
41 libqt5test5,
42 calendar-app (= ${source:Version}),
43+ python-dateutil,
44 Description: Autopilot tests for Ubuntu Calendar Application
45 This package contains autopilot tests for the Ubuntu Calendar application.
46
47
48=== modified file 'tests/autopilot/calendar_app/emulators/main_window.py'
49--- tests/autopilot/calendar_app/emulators/main_window.py 2013-07-12 16:38:49 +0000
50+++ tests/autopilot/calendar_app/emulators/main_window.py 2013-07-23 16:09:23 +0000
51@@ -18,3 +18,6 @@
52
53 def get_event_view(self):
54 return self.app.select_single("EventView")
55+
56+ def get_month_view(self):
57+ return self.app.select_single("MonthView")
58
59=== added file 'tests/autopilot/calendar_app/tests/test_monthview.py'
60--- tests/autopilot/calendar_app/tests/test_monthview.py 1970-01-01 00:00:00 +0000
61+++ tests/autopilot/calendar_app/tests/test_monthview.py 2013-07-23 16:09:23 +0000
62@@ -0,0 +1,121 @@
63+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
64+# Copyright 2013 Canonical
65+#
66+# This program is free software: you can redistribute it and/or modify it
67+# under the terms of the GNU General Public License version 3, as published
68+# by the Free Software Foundation.
69+
70+"""Calendar app autopilot tests."""
71+
72+from __future__ import absolute_import
73+
74+from autopilot.matchers import Eventually
75+from testtools.matchers import Equals
76+
77+from calendar_app.tests import CalendarTestCase
78+
79+from datetime import datetime
80+from dateutil.relativedelta import relativedelta
81+
82+
83+class TestMainWindow(CalendarTestCase):
84+
85+ def setUp(self):
86+ super(TestMainWindow, self).setUp()
87+ self.assertThat(
88+ self.ubuntusdk.get_qml_view().visible, Eventually(Equals(True)))
89+
90+ def tearDown(self):
91+ super(TestMainWindow, self).tearDown()
92+
93+ # goToNextMonth True for next month, False for previous month
94+ def changeMonth(self, goToNextMonth=True, count=0):
95+
96+ month_view = self.main_window.get_month_view()
97+ y_line = int(self.ubuntusdk.get_qml_view().y
98+ + month_view.y + (month_view.height / 2))
99+
100+ for i in range(count):
101+ if goToNextMonth is True:
102+ start_x = int(self.ubuntusdk.get_qml_view().x
103+ + month_view.x + (month_view.width * 0.85))
104+ stop_x = int(self.ubuntusdk.get_qml_view().x
105+ + month_view.x + (month_view.width * 0.15))
106+ else:
107+ start_x = int(self.ubuntusdk.get_qml_view().x
108+ + month_view.x + (month_view.width * 0.15))
109+ stop_x = int(self.ubuntusdk.get_qml_view().x
110+ + month_view.x + (month_view.width * 0.85))
111+
112+ self.pointing_device.drag(start_x, y_line, stop_x, y_line)
113+
114+ def test_monthview_today_next_month(self):
115+ self.monthview_today(True, 1)
116+
117+ def test_monthview_today_prev_month(self):
118+ self.monthview_today(False, 1)
119+
120+ def test_monthview_today_next_month_multi(self):
121+ self.monthview_today(True, 12)
122+
123+ def test_monthview_today_prev_month_multi(self):
124+ self.monthview_today(False, 12)
125+
126+ # goToNextMonth True for next month, False for previous month
127+ def monthview_today(self, goToNextMonth=True, count=-1):
128+
129+ if count == -1:
130+ return
131+
132+ month_view = self.main_window.get_month_view()
133+
134+ startDay = datetime.fromtimestamp(month_view.currentDayStart)
135+
136+ self.changeMonth(goToNextMonth, count)
137+
138+ self.ubuntusdk.click_toolbar_button("Today")
139+ dayAfterMonthChange = datetime.fromtimestamp(month_view
140+ .currentDayStart)
141+
142+ self.assertThat(dayAfterMonthChange.day, Equals(startDay.day))
143+ self.assertThat(dayAfterMonthChange.month, Equals(startDay.month))
144+ self.assertThat(dayAfterMonthChange.year, Equals(startDay.year))
145+
146+ def test_monthview_change_month_next(self):
147+ self.monthview_change_month(True, 1)
148+
149+ def test_monthview_change_month_next_multiple(self):
150+ self.monthview_change_month(True, 3)
151+
152+ def test_monthview_change_month_prev(self):
153+ self.monthview_change_month(False, 1)
154+
155+ def test_monthview_change_month_prev_multiple(self):
156+ self.monthview_change_month(False, 3)
157+
158+ # goToNextMonth True for next month, False for previous month
159+ def monthview_change_month(self, goToNextMonth=True, count=-1):
160+
161+ if count == -1:
162+ return
163+
164+ month_view = self.main_window.get_month_view()
165+
166+ startDay = datetime.fromtimestamp(month_view.currentDayStart)
167+
168+ self.changeMonth(goToNextMonth, count)
169+
170+ dayAfterMonthChange = datetime.fromtimestamp(month_view
171+ .currentDayStart)
172+
173+ self.assertThat(dayAfterMonthChange.day, Equals(1))
174+ if goToNextMonth is True:
175+ testDate = startDay + relativedelta(months=+count)
176+ self.assertThat(dayAfterMonthChange.month,
177+ Equals(testDate.month))
178+ self.assertThat(dayAfterMonthChange.year, Equals(testDate.year))
179+ else:
180+ testDate = startDay + relativedelta(months=-count)
181+ self.assertThat(dayAfterMonthChange.month,
182+ Equals(testDate.month))
183+ self.assertThat(dayAfterMonthChange.year, Equals(testDate.year))

Subscribers

People subscribed via source and target branches

to status/vote changes: