24
24
from ubuntuuitoolkit import tests
27
class HeaderTestCase(tests.QMLFileAppTestCase):
27
class ActionsTestCase(tests.QMLFileAppTestCase):
29
29
path = os.path.abspath(__file__)
30
30
dir_path = os.path.dirname(path)
31
31
tools_test_qml_file_path = os.path.join(
32
dir_path, 'test_header.HeaderToolsTestCase.qml')
32
dir_path, 'test_header.ToolsTestCase.qml')
33
33
actions_test_qml_file_path = os.path.join(
34
dir_path, 'test_header.HeaderActionsTestCase.qml')
34
dir_path, 'test_header.ActionsTestCase.qml')
37
37
('deprecated tools',
98
97
self.assertEqual(overflow_button.visible, False)
100
class SectionsTestCase(tests.QMLFileAppTestCase):
102
path = os.path.abspath(__file__)
103
dir_path = os.path.dirname(path)
104
test_qml_file_path = os.path.join(
105
dir_path, 'test_header.SectionsTestCase.qml')
108
super(SectionsTestCase, self).setUp()
109
self.header = self.main_view.get_header()
110
# initially, section 0 is selected
111
self.assertEqual(self.header.get_selected_section_index(), 0)
113
def test_select_sections(self):
114
for index in [1, 0, 2]:
115
self.header.switch_to_section_by_index(index)
116
self.assertEqual(self.header.get_selected_section_index(), index)
118
def test_select_sections_with_sections_disabled(self):
119
sectionsEnabledSwitch = self.app.select_single(
120
'CheckBox', objectName='sections_enabled_switch')
121
sectionsEnabledSwitch.uncheck()
122
for index in [1, 0, 2]:
123
self.header.switch_to_section_by_index(index)
124
# cannot change section by tapping the section name in divider
125
self.assertEqual(self.header.get_selected_section_index(), 0)
128
class DeprecatedHeaderSectionsTestCase(tests.QMLFileAppTestCase):
130
path = os.path.abspath(__file__)
131
dir_path = os.path.dirname(path)
132
test_qml_file_path = os.path.join(
133
dir_path, 'test_header.DeprecatedHeaderSectionsTestCase.qml')
136
super(DeprecatedHeaderSectionsTestCase, self).setUp()
137
self.header = self.main_view.get_header()
139
def test_get_selection_index(self):
140
error = self.assertRaises(
141
ubuntuuitoolkit.ToolkitException,
142
self.header.get_selected_section_index)
145
'Old header has no sections')
147
def test_select_sections(self):
148
error = self.assertRaises(
149
ubuntuuitoolkit.ToolkitException,
150
self.header.switch_to_section_by_index, 1)
153
'Old header has no sections')
155
def test_select_sections_with_sections_disabled(self):
156
sectionsEnabledSwitch = self.app.select_single(
157
'CheckBox', objectName='sections_enabled_switch')
158
sectionsEnabledSwitch.uncheck()
159
error = self.assertRaises(
160
ubuntuuitoolkit.ToolkitException,
161
self.header.switch_to_section_by_index, 1)
164
'Old header has no sections')
101
167
class CustomMainView(ubuntuuitoolkit.MainView):
102
168
"""Autopilot helper for a custom main view."""