~nick-dedekind/ubuntu-ui-toolkit/lp1378821.time-translation

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_main_view.py

  • Committer: Nick Dedekind
  • Date: 2015-07-15 11:56:22 UTC
  • mfrom: (1114.1.89 ubuntu-ui-toolkit)
  • Revision ID: nick.dedekind@canonical.com-20150715115622-u4qntuhuqx8vw24o
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
2
#
3
 
# Copyright (C) 2013, 2014 Canonical Ltd.
 
3
# Copyright (C) 2013-2015 Canonical Ltd.
4
4
#
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU Lesser General Public License as published by
14
14
# You should have received a copy of the GNU Lesser General Public License
15
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
 
try:
18
 
    from unittest import mock
19
 
except ImportError:
20
 
    import mock
 
17
from unittest import mock
21
18
 
22
19
import ubuntuuitoolkit
23
20
from ubuntuuitoolkit import tests
24
21
 
25
22
 
26
 
class MainViewTestCase(tests.QMLStringAppTestCase):
 
23
class MainView10TestCase(tests.QMLStringAppTestCase):
27
24
 
28
25
    test_qml = ("""
29
26
import QtQuick 2.0
30
 
import Ubuntu.Components 0.1
 
27
import Ubuntu.Components 1.0
31
28
 
32
29
MainView {
33
30
    width: units.gu(48)
34
31
    height: units.gu(60)
 
32
    objectName: "mainView"
35
33
}
36
34
""")
37
35
 
77
75
            str(error), 'The MainView has no Tabs.')
78
76
 
79
77
 
 
78
class MainView12TestCase(tests.QMLStringAppTestCase):
 
79
 
 
80
    test_qml = ("""
 
81
import QtQuick 2.3
 
82
import Ubuntu.Components 1.2
 
83
 
 
84
MainView {
 
85
    width: units.gu(48)
 
86
    height: units.gu(60)
 
87
    objectName: "mainView"
 
88
}
 
89
""")
 
90
 
 
91
    def test_main_view_custom_proxy_object(self):
 
92
        self.assertIsInstance(self.main_view, ubuntuuitoolkit.MainView)
 
93
 
 
94
    def test_get_header_without_header(self):
 
95
        header = self.main_view.get_header()
 
96
        self.assertFalse(header.visible)
 
97
 
 
98
    def test_get_tabs_without_tabs(self):
 
99
        error = self.assertRaises(
 
100
            ubuntuuitoolkit.ToolkitException, self.main_view.get_tabs)
 
101
        self.assertEqual(
 
102
            str(error), 'The MainView has no Tabs.')
 
103
 
 
104
    def test_switch_to_next_tab_without_tabs(self):
 
105
        header = self.main_view.get_header()
 
106
        error = self.assertRaises(
 
107
            ubuntuuitoolkit.ToolkitException,
 
108
            header.switch_to_next_tab)
 
109
        self.assertEqual(
 
110
            str(error), 'The MainView has no Tabs.')
 
111
 
 
112
    def test_get_toolbar_without_toolbar(self):
 
113
        error = self.assertRaises(
 
114
            ubuntuuitoolkit.ToolkitException, self.main_view.get_toolbar)
 
115
        self.assertEqual(
 
116
            str(error), 'The MainView has no Toolbar.')
 
117
 
 
118
    def test_open_toolbar_without_toolbar(self):
 
119
        error = self.assertRaises(
 
120
            ubuntuuitoolkit.ToolkitException, self.main_view.open_toolbar)
 
121
        self.assertEqual(
 
122
            str(error), 'The MainView has no Toolbar.')
 
123
 
 
124
    def test_close_toolbar_without_toolbar(self):
 
125
        error = self.assertRaises(
 
126
            ubuntuuitoolkit.ToolkitException, self.main_view.close_toolbar)
 
127
        self.assertEqual(
 
128
            str(error), 'The MainView has no Toolbar.')
 
129
 
 
130
 
80
131
TEST_GO_BACK_QML_FORMAT = ("""
81
132
import QtQuick 2.0
82
133
import Ubuntu.Components 1.0
84
135
MainView {{
85
136
    width: units.gu(48)
86
137
    height: units.gu(60)
 
138
    objectName: "mainView"
87
139
    useDeprecatedToolbar: {use_deprecated_toolbar}
88
140
 
89
141
    PageStack {{
124
176
    ]
125
177
 
126
178
    def setUp(self):
127
 
        super(GoBackTestCase, self).setUp()
 
179
        super().setUp()
128
180
        self.header = self.main_view.get_header()
129
181
        self.assertEqual(self.header.title, 'Page 0')
130
182