~themuso/ubuntu-ui-toolkit/add-accessibility-metadata

« back to all changes in this revision

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

  • Committer: Luke Yelavich
  • Date: 2014-07-28 07:04:49 UTC
  • mfrom: (992.51.43 ubuntu-ui-toolkit)
  • Revision ID: luke.yelavich@canonical.com-20140728070449-30bfzhu758caz058
Merge with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from ubuntuuitoolkit import tests
25
25
 
26
26
 
27
 
class HeaderTestCase(tests.QMLFileAppTestCase):
 
27
class ActionsTestCase(tests.QMLFileAppTestCase):
28
28
 
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')
35
35
 
36
36
    scenarios = [
37
37
        ('deprecated tools',
41
41
    ]
42
42
 
43
43
    def setUp(self):
44
 
        super(HeaderTestCase, self).setUp()
 
44
        super(ActionsTestCase, self).setUp()
45
45
        self.header = self.main_view.get_header()
46
46
        self.label = self.app.select_single(
47
47
            'Label', objectName='clicked_label')
85
85
    def test_overflow_button(self):
86
86
        # there are 5 actions plus a custom back action
87
87
        overflow_button = self.header.select_single(
88
 
            'AbstractButton',
89
88
            objectName='actions_overflow_button')
90
89
        self.assertEqual(overflow_button.visible, True)
91
90
 
98
97
        self.assertEqual(overflow_button.visible, False)
99
98
 
100
99
 
 
100
class SectionsTestCase(tests.QMLFileAppTestCase):
 
101
 
 
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')
 
106
 
 
107
    def setUp(self):
 
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)
 
112
 
 
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)
 
117
 
 
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)
 
126
 
 
127
 
 
128
class DeprecatedHeaderSectionsTestCase(tests.QMLFileAppTestCase):
 
129
 
 
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')
 
134
 
 
135
    def setUp(self):
 
136
        super(DeprecatedHeaderSectionsTestCase, self).setUp()
 
137
        self.header = self.main_view.get_header()
 
138
 
 
139
    def test_get_selection_index(self):
 
140
        error = self.assertRaises(
 
141
            ubuntuuitoolkit.ToolkitException,
 
142
            self.header.get_selected_section_index)
 
143
        self.assertEqual(
 
144
            str(error),
 
145
            'Old header has no sections')
 
146
 
 
147
    def test_select_sections(self):
 
148
        error = self.assertRaises(
 
149
            ubuntuuitoolkit.ToolkitException,
 
150
            self.header.switch_to_section_by_index, 1)
 
151
        self.assertEqual(
 
152
            str(error),
 
153
            'Old header has no sections')
 
154
 
 
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)
 
162
        self.assertEqual(
 
163
            str(error),
 
164
            'Old header has no sections')
 
165
 
 
166
 
101
167
class CustomMainView(ubuntuuitoolkit.MainView):
102
168
    """Autopilot helper for a custom main view."""
103
169