~dandrader/unity8/surfaceDrawn

« back to all changes in this revision

Viewing changes to tests/qmltests/Dash/Filters/tst_FilterExpandableWidget.qml

  • Committer: CI Train Bot
  • Author(s): Albert Astals Cid
  • Date: 2016-05-04 18:09:25 UTC
  • mfrom: (1944.15.9 expandable_filter)
  • Revision ID: ci-train-bot@canonical.com-20160504180925-cey9wa2qnkh0yahw
Expandable Filter Widget
Approved by: Andrea Cimitan, Pawel Stolowski

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2016 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
 
 
17
import QtQuick 2.4
 
18
import QtTest 1.0
 
19
import Ubuntu.Components 1.3
 
20
import "../../../../qml/Dash/Filters"
 
21
import Unity.Test 0.1 as UT
 
22
import Unity 0.2
 
23
 
 
24
Rectangle {
 
25
    id: root
 
26
    width: units.gu(60)
 
27
    height: units.gu(80)
 
28
    color: theme.palette.selected.background
 
29
 
 
30
    QtObject {
 
31
        id: widgetData1
 
32
 
 
33
        property string title: "Expand me!"
 
34
        property ListModel filters: ListModel {
 
35
            dynamicRoles: true
 
36
        }
 
37
    }
 
38
 
 
39
    QtObject {
 
40
        id: sliderObject
 
41
 
 
42
        property string title
 
43
        property int value: 30
 
44
        property int minValue: 10
 
45
        property int maxValue: 150
 
46
 
 
47
        property ListModel values: ListModel {
 
48
            ListElement {
 
49
                value: 10
 
50
                label: "10"
 
51
            }
 
52
            ListElement {
 
53
                value: 30
 
54
                label: "30"
 
55
            }
 
56
            ListElement {
 
57
                value: 100
 
58
                label: "100"
 
59
            }
 
60
            ListElement {
 
61
                value: 150
 
62
                label: "150"
 
63
            }
 
64
        }
 
65
    }
 
66
 
 
67
    Component.onCompleted: {
 
68
        widgetData1.filters.append({"type": Filters.ValueSliderFilter, "filter": sliderObject, id: "trololo"});
 
69
    }
 
70
 
 
71
    FilterWidgetFactory {
 
72
        id: factory
 
73
        widgetId: "testExpandableWidget"
 
74
        widgetType: Filters.ExpandableFilterWidget
 
75
        widgetData: widgetData1
 
76
        anchors {
 
77
            left: parent.left
 
78
            right: parent.right
 
79
        }
 
80
        height: implicitHeight
 
81
        clip: true
 
82
    }
 
83
 
 
84
    UT.UnityTestCase {
 
85
        name: "FilterExpandableWidget"
 
86
        when: windowShown
 
87
 
 
88
        function test_expandedChanges() {
 
89
            var expandingItem = findChild(factory, "expandingItem");
 
90
            verify(!expandingItem.expanded)
 
91
            compare(expandingItem.height, expandingItem.collapsedHeight)
 
92
            mouseClick(expandingItem);
 
93
            verify(expandingItem.expanded)
 
94
            tryCompare(expandingItem, "height", expandingItem.expandedHeight)
 
95
            verify(expandingItem.collapsedHeight < expandingItem.expandedHeight / 2);
 
96
        }
 
97
 
 
98
    }
 
99
}