Merge lp:~paulliu/unity/phablet-add_unit_test into lp:unity/phablet

Proposed by Ying-Chun Liu
Status: Merged
Approved by: Michael Zanetti
Approved revision: no longer in the source branch.
Merged at revision: 601
Proposed branch: lp:~paulliu/unity/phablet-add_unit_test
Merge into: lp:unity/phablet
Diff against target: 86 lines (+72/-0)
2 files modified
tests/unittests/Components/CMakeLists.txt (+1/-0)
tests/unittests/Components/tst_OpenEffect.qml (+71/-0)
To merge this branch: bzr merge lp:~paulliu/unity/phablet-add_unit_test
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Needs Fixing
Albert Astals Cid (community) Needs Fixing
Review via email: mp+156859@code.launchpad.net

Commit message

Add unittests for Components/OpenEffect.qml

Description of the change

Add unittests for Components/OpenEffect.qml

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

I don't have a good feeling about this: Writing this entire file to test a single expression (a single line of code) in OpenEffect.qml

Revision history for this message
Albert Astals Cid (aacid) wrote :

I'm with Daniel, the test does indeed feel a bit weird, but on the other hand it is actually doing some testing...

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

IMO it would be better to have only one OpenEffect element and use multiple test functions to change the gap and check if the others adapt accordingly.

This test only checks if the properties are initilized correctly but not if they also reflect changes during runtime.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Doesn't merge properly with master

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

You have a trailing whitespace on line 60 of tst_OpenEffect.qml

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

lets get this in

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/unittests/Components/CMakeLists.txt'
--- tests/unittests/Components/CMakeLists.txt 2013-04-08 17:08:40 +0000
+++ tests/unittests/Components/CMakeLists.txt 2013-04-12 12:04:26 +0000
@@ -2,5 +2,6 @@
2add_qml_test(Carousel)2add_qml_test(Carousel)
3add_qml_test(CrossFadeImage)3add_qml_test(CrossFadeImage)
4add_qml_test(MathLocal)4add_qml_test(MathLocal)
5add_qml_test(OpenEffect)
5add_qml_test(RatingStars)6add_qml_test(RatingStars)
6add_qml_test(TimeLocal)7add_qml_test(TimeLocal)
78
=== added file 'tests/unittests/Components/tst_OpenEffect.qml'
--- tests/unittests/Components/tst_OpenEffect.qml 1970-01-01 00:00:00 +0000
+++ tests/unittests/Components/tst_OpenEffect.qml 2013-04-12 12:04:26 +0000
@@ -0,0 +1,71 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import QtTest 1.0
19import "../../../Components"
20
21TestCase {
22 name: "OpenEffectTest"
23
24 function test_openeffect_enabled() {
25 compare(openEffect1.enabled, true, "OpenEffect should be enabled if gap is greather than 0.0")
26 }
27
28 function test_openeffect_shadereffectsource() {
29 compare(openEffect1.source.hideSource, true, "OpenEffect ShaderEffectSource is incorrect")
30 compare(openEffect1.source.sourceItem, rectangle2, "OpenEffect ShaderEffectSource is incorrect")
31 compare(openEffect1.source.live, true, "OpenEffect ShaderEffectSource is incorrect")
32 compare(openEffect1.source.sourceRect.x, 0, "OpenEffect ShaderEffectSource is incorrect")
33 compare(openEffect1.source.sourceRect.y, 0, "OpenEffect ShaderEffectSource is incorrect")
34 compare(openEffect1.source.sourceRect.width, 50, "OpenEffect ShaderEffectSource is incorrect")
35 compare(openEffect1.source.sourceRect.height, 71, "OpenEffect ShaderEffectSource is incorrect")
36 openEffect1.gap=2.0
37 compare(openEffect1.source.sourceRect.x, 0, "OpenEffect ShaderEffectSource is incorrect")
38 compare(openEffect1.source.sourceRect.y, 0, "OpenEffect ShaderEffectSource is incorrect")
39 compare(openEffect1.source.sourceRect.width, 50, "OpenEffect ShaderEffectSource is incorrect")
40 compare(openEffect1.source.sourceRect.height, 72, "OpenEffect ShaderEffectSource is incorrect")
41 }
42
43 Rectangle {
44 id: rectangle1
45
46 width: 100; height: 100
47
48 Rectangle {
49 id: rectangle2
50 width: 50; height: 50
51 }
52
53 OpenEffect {
54 id: openEffect1
55 anchors {
56 fill: parent
57 }
58
59 property real gap: 1.0
60
61 topGapPx: (1 - gap) * positionPx
62 topOpacity: (1 - gap * 1.2)
63 bottomGapPx: positionPx + gap * 10
64 bottomOverflow: 20 + gap
65 bottomOpacity: 1 - (gap * 0.8)
66
67 positionPx: gap
68 sourceItem: rectangle2
69 }
70 }
71}

Subscribers

People subscribed via source and target branches