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
=== modified file 'src/qml/LiveCallPage/StopWatch.qml'
--- src/qml/LiveCallPage/StopWatch.qml 2014-07-23 10:13:32 +0000
+++ src/qml/LiveCallPage/StopWatch.qml 2014-12-16 18:09:55 +0000
@@ -20,19 +20,12 @@
20import Ubuntu.Components 1.120import Ubuntu.Components 1.1
2121
22Item {22Item {
23 function pad(text, length) {
24 while (text.length < length) text = '0' + text;
25 return text;
26 }
2723
28 property int time: 024 property int time: 0
29 property string elapsed: {25 property string elapsed: {
30 var divisor_for_minutes = time % (60 * 60);26 var d = new Date(0, 0, 0, 0, 0, time);
31 var minutes = String(Math.floor(divisor_for_minutes / 60));27
3228 return d.getHours() == 0 ? Qt.formatTime(d, "mm:ss") :
33 var divisor_for_seconds = divisor_for_minutes % 60;29 Qt.formatTime(d, "h:mm:ss");
34 var seconds = String(Math.ceil(divisor_for_seconds));
35
36 return "%1:%2".arg(pad(minutes, 2)).arg(pad(seconds, 2));
37 }30 }
38}31}
3932
=== modified file 'tests/qml/CMakeLists.txt'
--- tests/qml/CMakeLists.txt 2014-11-03 22:53:15 +0000
+++ tests/qml/CMakeLists.txt 2014-12-16 18:09:55 +0000
@@ -18,6 +18,7 @@
18if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN)18if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN)
19 declare_qml_test("keypad_button" tst_KeypadButton.qml)19 declare_qml_test("keypad_button" tst_KeypadButton.qml)
20 declare_qml_test("main_view" tst_MainView.qml)20 declare_qml_test("main_view" tst_MainView.qml)
21 declare_qml_test("stopwatch" tst_StopWatch.qml)
21else()22else()
22 if (NOT QMLTESTRUNNER_BIN)23 if (NOT QMLTESTRUNNER_BIN)
23 message(WARNING "Qml tests disabled: qmltestrunner not found")24 message(WARNING "Qml tests disabled: qmltestrunner not found")
@@ -28,5 +29,6 @@
2829
29set(QML_TST_FILES30set(QML_TST_FILES
30 tst_KeypadButton.qml31 tst_KeypadButton.qml
32 tst_StopWatch.qml
31)33)
32add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})34add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})
3335
=== added file 'tests/qml/tst_StopWatch.qml'
--- tests/qml/tst_StopWatch.qml 1970-01-01 00:00:00 +0000
+++ tests/qml/tst_StopWatch.qml 2014-12-16 18:09:55 +0000
@@ -0,0 +1,77 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This file is part of dialer-app.
5 *
6 * dialer-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * dialer-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.2
20import QtTest 1.0
21import Ubuntu.Test 0.1
22
23import '../../src/qml/LiveCallPage'
24
25Item {
26 id: root
27
28 width: units.gu(40)
29 height: units.gu(60)
30
31 StopWatch {
32 id: timer
33 }
34
35 UbuntuTestCase {
36 id: stopWatchTestCase
37 name: 'stopWatchTestCase'
38
39 when: windowShown
40
41 function test_zero() {
42 timer.time = 0;
43 compare(timer.elapsed, "00:00");
44 }
45
46 function test_thirty_seconds() {
47 timer.time = 30;
48 compare(timer.elapsed, "00:30");
49 }
50
51 function test_one_minute() {
52 timer.time = 60;
53 compare(timer.elapsed, "01:00");
54 }
55
56 function test_one_hour() {
57 timer.time = 3600;
58 compare(timer.elapsed, "1:00:00");
59 }
60
61 function test_hour_thirty_seconds() {
62 timer.time = 3600 + 30;
63 compare(timer.elapsed, "1:00:30");
64 }
65
66 function test_hour_one_minute() {
67 timer.time = 3600 + 60;
68 compare(timer.elapsed, "1:01:00");
69 }
70
71 function test_hour_one_minute_thirty_seconds() {
72 timer.time = 3600 + 60 + 30;
73 compare(timer.elapsed, "1:01:30");
74 }
75 }
76
77}

Subscribers

People subscribed via source and target branches