Merge lp:~boiko/dialer-app/rtm-show_duration_hours into lp:dialer-app/rtm-14.09

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Bill Filler
Approved revision: 245
Merged at revision: 247
Proposed branch: lp:~boiko/dialer-app/rtm-show_duration_hours
Merge into: lp:dialer-app/rtm-14.09
Diff against target: 128 lines (+83/-11)
3 files modified
src/qml/LiveCallPage/StopWatch.qml (+4/-11)
tests/qml/CMakeLists.txt (+2/-0)
tests/qml/tst_StopWatch.qml (+77/-0)
To merge this branch: bzr merge lp:~boiko/dialer-app/rtm-show_duration_hours
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+244894@code.launchpad.net

Commit message

Show hours in the call duration - patch by Dennis O'Flaherty.

Description of the change

Show hours in the call duration - patch by Dennis O'Flaherty.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/LiveCallPage/StopWatch.qml'
2--- src/qml/LiveCallPage/StopWatch.qml 2014-07-23 10:13:32 +0000
3+++ src/qml/LiveCallPage/StopWatch.qml 2014-12-16 18:09:55 +0000
4@@ -20,19 +20,12 @@
5 import Ubuntu.Components 1.1
6
7 Item {
8- function pad(text, length) {
9- while (text.length < length) text = '0' + text;
10- return text;
11- }
12
13 property int time: 0
14 property string elapsed: {
15- var divisor_for_minutes = time % (60 * 60);
16- var minutes = String(Math.floor(divisor_for_minutes / 60));
17-
18- var divisor_for_seconds = divisor_for_minutes % 60;
19- var seconds = String(Math.ceil(divisor_for_seconds));
20-
21- return "%1:%2".arg(pad(minutes, 2)).arg(pad(seconds, 2));
22+ var d = new Date(0, 0, 0, 0, 0, time);
23+
24+ return d.getHours() == 0 ? Qt.formatTime(d, "mm:ss") :
25+ Qt.formatTime(d, "h:mm:ss");
26 }
27 }
28
29=== modified file 'tests/qml/CMakeLists.txt'
30--- tests/qml/CMakeLists.txt 2014-11-03 22:53:15 +0000
31+++ tests/qml/CMakeLists.txt 2014-12-16 18:09:55 +0000
32@@ -18,6 +18,7 @@
33 if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN)
34 declare_qml_test("keypad_button" tst_KeypadButton.qml)
35 declare_qml_test("main_view" tst_MainView.qml)
36+ declare_qml_test("stopwatch" tst_StopWatch.qml)
37 else()
38 if (NOT QMLTESTRUNNER_BIN)
39 message(WARNING "Qml tests disabled: qmltestrunner not found")
40@@ -28,5 +29,6 @@
41
42 set(QML_TST_FILES
43 tst_KeypadButton.qml
44+ tst_StopWatch.qml
45 )
46 add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})
47
48=== added file 'tests/qml/tst_StopWatch.qml'
49--- tests/qml/tst_StopWatch.qml 1970-01-01 00:00:00 +0000
50+++ tests/qml/tst_StopWatch.qml 2014-12-16 18:09:55 +0000
51@@ -0,0 +1,77 @@
52+/*
53+ * Copyright 2014 Canonical Ltd.
54+ *
55+ * This file is part of dialer-app.
56+ *
57+ * dialer-app is free software; you can redistribute it and/or modify
58+ * it under the terms of the GNU General Public License as published by
59+ * the Free Software Foundation; version 3.
60+ *
61+ * dialer-app is distributed in the hope that it will be useful,
62+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
63+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+ * GNU General Public License for more details.
65+ *
66+ * You should have received a copy of the GNU General Public License
67+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
68+ */
69+
70+import QtQuick 2.2
71+import QtTest 1.0
72+import Ubuntu.Test 0.1
73+
74+import '../../src/qml/LiveCallPage'
75+
76+Item {
77+ id: root
78+
79+ width: units.gu(40)
80+ height: units.gu(60)
81+
82+ StopWatch {
83+ id: timer
84+ }
85+
86+ UbuntuTestCase {
87+ id: stopWatchTestCase
88+ name: 'stopWatchTestCase'
89+
90+ when: windowShown
91+
92+ function test_zero() {
93+ timer.time = 0;
94+ compare(timer.elapsed, "00:00");
95+ }
96+
97+ function test_thirty_seconds() {
98+ timer.time = 30;
99+ compare(timer.elapsed, "00:30");
100+ }
101+
102+ function test_one_minute() {
103+ timer.time = 60;
104+ compare(timer.elapsed, "01:00");
105+ }
106+
107+ function test_one_hour() {
108+ timer.time = 3600;
109+ compare(timer.elapsed, "1:00:00");
110+ }
111+
112+ function test_hour_thirty_seconds() {
113+ timer.time = 3600 + 30;
114+ compare(timer.elapsed, "1:00:30");
115+ }
116+
117+ function test_hour_one_minute() {
118+ timer.time = 3600 + 60;
119+ compare(timer.elapsed, "1:01:00");
120+ }
121+
122+ function test_hour_one_minute_thirty_seconds() {
123+ timer.time = 3600 + 60 + 30;
124+ compare(timer.elapsed, "1:01:30");
125+ }
126+ }
127+
128+}

Subscribers

People subscribed via source and target branches