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

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntuuitoolkit/tests/__init__.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:
39
39
    desktop_file_dir = get_local_desktop_file_directory()
40
40
    if not os.path.exists(desktop_file_dir):
41
41
        os.makedirs(desktop_file_dir)
 
42
    # Strip underscores which look like an APP_ID to Unity
 
43
    # See https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1329141
 
44
    chars = tempfile._RandomNameSequence.characters.strip("_")
 
45
    tempfile._RandomNameSequence.characters = chars
42
46
    desktop_file = tempfile.NamedTemporaryFile(
43
47
        suffix='.desktop', dir=desktop_file_dir, delete=False)
44
48
    desktop_file.write(_DESKTOP_FILE_CONTENTS.encode('utf-8'))
60
64
            os.path.dirname(__file__), '..', '..', '..', '..'))
61
65
 
62
66
 
63
 
class QMLStringAppTestCase(base.UbuntuUIToolkitAppTestCase):
64
 
    """Base test case for self tests that define the QML on an string."""
 
67
class UbuntuUIToolkitWithFakeAppRunningTestCase(
 
68
        base.UbuntuUIToolkitAppTestCase):
65
69
 
66
70
    test_qml = ("""
67
71
import QtQuick 2.0
69
73
 
70
74
MainView {
71
75
    width: units.gu(48)
72
 
    height: units.gu(60)
 
76
    height: units.gu(80)
73
77
}
74
78
""")
75
79
 
76
80
    def setUp(self):
77
 
        super(QMLStringAppTestCase, self).setUp()
78
 
        self.pointing_device = Pointer(self.input_device_class.create())
 
81
        super(UbuntuUIToolkitWithFakeAppRunningTestCase, self).setUp()
79
82
        self.launch_application()
80
83
 
81
84
    def launch_application(self):
83
86
            qml_file_contents=self.test_qml)
84
87
        self.useFixture(fake_application)
85
88
 
86
 
        self.app = self.launch_test_application(
87
 
            base.get_qmlscene_launch_command(),
88
 
            '-I' + _get_module_include_path(),
89
 
            fake_application.qml_file_path,
90
 
            '--desktop_file_hint={0}'.format(
91
 
                fake_application.desktop_file_path),
92
 
            emulator_base=emulators.UbuntuUIToolkitEmulatorBase,
93
 
            app_type='qt')
94
 
 
 
89
        desktop_file_name = os.path.basename(
 
90
            fake_application.desktop_file_path)
 
91
        application_name, _ = os.path.splitext(desktop_file_name)
 
92
        self.app = self.launch_upstart_application(
 
93
            application_name,
 
94
            emulator_base=emulators.UbuntuUIToolkitEmulatorBase)
 
95
 
 
96
 
 
97
class QMLStringAppTestCase(UbuntuUIToolkitWithFakeAppRunningTestCase):
 
98
    """Base test case for self tests that define the QML on an string."""
 
99
 
 
100
    def setUp(self):
 
101
        super(QMLStringAppTestCase, self).setUp()
95
102
        self.assertThat(
96
103
            self.main_view.visible, Eventually(Equals(True)))
97
104
 
 
105
        self.pointing_device = Pointer(self.input_device_class.create())
 
106
 
98
107
    @property
99
108
    def main_view(self):
100
109
        return self.app.select_single(emulators.MainView)