Merge lp:~doflah/ubuntu-calendar-app/testing into lp:ubuntu-calendar-app

Proposed by Dennis O'Flaherty
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 126
Merged at revision: 122
Proposed branch: lp:~doflah/ubuntu-calendar-app/testing
Merge into: lp:ubuntu-calendar-app
Diff against target: 135 lines (+108/-0)
3 files modified
debian/control (+4/-0)
debian/rules (+3/-0)
tests/unittests/tst_date.qml (+101/-0)
To merge this branch: bzr merge lp:~doflah/ubuntu-calendar-app/testing
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Olivier Tilloy (community) Approve
Review via email: mp+186943@code.launchpad.net

Commit message

Add unit tests for JS date functions.

Description of the change

Add unit tests for js date functions.

To post a comment you must log in.
Revision history for this message
Dennis O'Flaherty (doflah) wrote :

Some of the routines in dateExt.js aren't used anywhere or seem to be duplicated, so it may be worth cleaning that file up in addition to adding the tests.

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

91 + compare(todayTest.getMonth(), todayReal.getMonth(), "Today's year");
92 + compare(todayTest.getDate(), todayReal.getDate(), "Today's year");

I guess this should be "Today’s month" and "Today’s day".

review: Needs Fixing
Revision history for this message
Dennis O'Flaherty (doflah) wrote :

Fixed. Thanks for catching that.

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

Overall this looks like a great addition to the already existing autopilot tests, to ensure no regressions in the JS helpers. Thanks for this!

A few remarks:

 - For consistency with other apps, instead of "unit-tests/", I would place those tests under "tests/unittests/" (when you do that you’ll have to add another "../" to the import statement for dateExt.js.

 - It would be great to have the build system automatically run those tests when building a package. To achieve this, you’ll need to apply the following changes:

=== modified file 'debian/control'
--- debian/control 2013-08-20 08:24:45 +0000
+++ debian/control 2013-09-23 11:23:04 +0000
@@ -1,7 +1,8 @@
 Source: calendar-app
 Priority: extra
 Maintainer: Ubuntu App Cats <email address hidden>
-Build-Depends: debhelper (>= 9),
+Build-Depends: debhelper (>= 9),
+ qtdeclarative5-dev-tools,
 Standards-Version: 3.9.4
 Section: misc
 Homepage: https://launchpad.net/ubuntu-calendar-app

=== modified file 'debian/rules'
--- debian/rules 2013-06-17 11:10:21 +0000
+++ debian/rules 2013-09-23 11:20:25 +0000
@@ -7,6 +7,9 @@
 %:
  dh $@

+override_dh_auto_test:
+ QT_QPA_PLATFORM=minimal qmltestrunner -input tests/unittests/
+
 override_dh_install:
  dh_install --fail-missing
  appname=calendar-app; \

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

Thanks for the changes!
I’ve had a go at building a package in a saucy chroot, and it appears we are missing the following build dependencies:

    qt5-default,
    qtdeclarative5-qtquick2-plugin,
    qtdeclarative5-test-plugin,

(on top of qtdeclarative5-dev-tools that was already added).

Can you please add those to the Build-Depends section (and while you’re at it, ensure they are all aligned on the same column as the first dependency, using spaces not tabs)?
Thanks!

review: Needs Fixing
Revision history for this message
Dennis O'Flaherty (doflah) wrote :

No problem! Hopefully you should be all set now.

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

Looks perfect now!

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

It looks like there a problem with the jenkins setup, it can’t find the Qt5 build dependencies on precise and quantal, I asked the CI team to look into this.

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: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-08-20 08:24:45 +0000
3+++ debian/control 2013-09-24 11:19:44 +0000
4@@ -2,6 +2,10 @@
5 Priority: extra
6 Maintainer: Ubuntu App Cats <ubuntu-touch-coreapps@lists.launchpad.net>
7 Build-Depends: debhelper (>= 9),
8+ qtdeclarative5-dev-tools,
9+ qt5-default,
10+ qtdeclarative5-qtquick2-plugin,
11+ qtdeclarative5-test-plugin,
12 Standards-Version: 3.9.4
13 Section: misc
14 Homepage: https://launchpad.net/ubuntu-calendar-app
15
16=== modified file 'debian/rules'
17--- debian/rules 2013-06-17 11:10:21 +0000
18+++ debian/rules 2013-09-24 11:19:44 +0000
19@@ -7,6 +7,9 @@
20 %:
21 dh $@
22
23+override_dh_auto_test:
24+ QT_QPA_PLATFORM=minimal qmltestrunner -input tests/unittests/
25+
26 override_dh_install:
27 dh_install --fail-missing
28 appname=calendar-app; \
29
30=== added directory 'tests/unittests'
31=== added file 'tests/unittests/tst_date.qml'
32--- tests/unittests/tst_date.qml 1970-01-01 00:00:00 +0000
33+++ tests/unittests/tst_date.qml 2013-09-24 11:19:44 +0000
34@@ -0,0 +1,101 @@
35+import QtQuick 2.0
36+import QtTest 1.0
37+import "../../dateExt.js" as DATE
38+
39+TestCase{
40+ name: "Date tests"
41+
42+ // Data \\
43+
44+ function test_leap_year_data() {
45+ return [{year:2013}, {year: 2000}, {year: 2012}, {year: 2100}];
46+ }
47+
48+ function test_days_per_month_data() {
49+ return [
50+ // all months in a non-leap year
51+ new Date(2013, 0),
52+ new Date(2013, 1),
53+ new Date(2013, 2),
54+ new Date(2013, 3),
55+ new Date(2013, 4),
56+ new Date(2013, 5),
57+ new Date(2013, 6),
58+ new Date(2013, 7),
59+ new Date(2013, 8),
60+ new Date(2013, 9),
61+ new Date(2013, 10),
62+ new Date(2013, 11),
63+ // Feb in leap year, century, and millenium
64+ new Date(2112, 1),
65+ new Date(2000, 1),
66+ new Date(2100, 1)
67+ ];
68+ }
69+
70+ function test_add_days_data() {
71+ return [
72+ // regular add days
73+ { start: new Date(2013, 0, 1), days: 4, end: new Date(2013, 0, 5)},
74+ // start daylight savings: March 10, 2013
75+ { start: new Date(2013, 2, 10), days: 1, end: new Date(2013, 2, 11)},
76+ // end daylight savings: November 3, 2013
77+ { start: new Date(2013, 10, 3), days: 1, end: new Date(2013, 10, 4)},
78+ // cross month boundary
79+ { start: new Date(2013, 2, 31), days: 2, end: new Date(2013, 3, 2)},
80+ // cross year boundary
81+ { start: new Date(2013, 11, 31), days: 2, end: new Date(2014, 0, 2)},
82+ ];
83+ }
84+
85+ function test_add_months_data() {
86+ return [
87+ // regular add months
88+ { start: new Date(2013, 0, 1), months: 1, end: new Date(2013, 1, 1)},
89+ // add multiple months
90+ { start: new Date(2013, 0, 1), months: 4, end: new Date(2013, 4, 1)},
91+ // start daylight savings: March 10, 2013
92+ { start: new Date(2013, 2, 1), months: 1, end: new Date(2013, 3, 1)},
93+ // end daylight savings: November 3, 2013
94+ { start: new Date(2013, 10, 1), months: 1, end: new Date(2013, 11, 1)},
95+ // cross year boundary
96+ { start: new Date(2013, 11, 1), months: 1, end: new Date(2014, 0, 1)},
97+ ];
98+ }
99+
100+ // Tests \\
101+
102+ function test_days_per_month(month) {
103+ compare(Date.daysInMonth(month.getFullYear(), month.getMonth()),
104+ new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate(),
105+ Qt.locale().standaloneMonthName(month.getMonth()) + ", " + month.getFullYear());
106+ }
107+
108+ function test_leap_year(test) {
109+ compare(Date.leapYear(test.year), new Date(test.year, 2, 0).getDate() == 29, "Check if Feb, " + test.year + " has the right number of days.");
110+ }
111+
112+ function test_midnight() {
113+ var date = new Date();
114+ compare(date.midnight(), new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0), "Midnight");
115+ }
116+
117+ function test_today() {
118+ var todayReal = new Date(), todayTest = DATE.today();
119+ compare(todayTest.getFullYear(), todayReal.getFullYear(), "Today's year");
120+ compare(todayTest.getMonth(), todayReal.getMonth(), "Today's month");
121+ compare(todayTest.getDate(), todayReal.getDate(), "Today's date");
122+ compare(todayTest.getHours(), 0, "Midnight, zero hours");
123+ compare(todayTest.getMinutes(), 0, "Midnight, zero minutes");
124+ compare(todayTest.getSeconds(), 0, "Midnight, zero seconds");
125+ }
126+
127+ function test_add_days(test) {
128+ compare(test.start.addDays(test.days), test.end, test.start + " + " + test.days + " days");
129+ }
130+
131+ function test_add_months(test) {
132+ compare(test.start.addMonths(test.months), test.end, test.start + " + " + test.months + " months");
133+ }
134+
135+}

Subscribers

People subscribed via source and target branches

to status/vote changes: