~nskaggs/autopilot/add-isolation-apparmor-rules

« back to all changes in this revision

Viewing changes to autopilot/tests/functional/test_dbus_query.py

  • Committer: CI bot
  • Author(s): Tarmac
  • Date: 2014-05-09 00:48:06 UTC
  • mfrom: (483.2.19 temp-dev)
  • Revision ID: ps-jenkins@lists.canonical.com-20140509004806-8528si3da584w57j
Initial release of 1.5. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import os
23
23
import subprocess
24
24
import signal
25
 
from time import time
 
25
from timeit import default_timer
26
26
from tempfile import mktemp
27
27
from testtools import skipIf
28
28
from testtools.matchers import Equals, NotEquals, raises, LessThan, GreaterThan
29
29
 
30
30
from autopilot import platform
31
31
from autopilot.testcase import AutopilotTestCase
32
 
from autopilot.introspection.dbus import StateNotFoundError
 
32
from autopilot.exceptions import StateNotFoundError
33
33
 
34
34
 
35
35
@skipIf(platform.model() != "Desktop", "Only suitable on Desktop (WinMocker)")
141
141
    def test_select_single_no_name_no_parameter_raises_exception(self):
142
142
        app = self.start_fully_featured_app()
143
143
        fn = lambda: app.select_single()
144
 
        self.assertThat(fn, raises(TypeError))
 
144
        self.assertThat(fn, raises(ValueError))
145
145
 
146
146
    def test_select_single_no_match_raises_exception(self):
147
147
        app = self.start_fully_featured_app()
171
171
    def test_select_many_no_name_no_parameter_raises_exception(self):
172
172
        app = self.start_fully_featured_app()
173
173
        fn = lambda: app.select_single()
174
 
        self.assertThat(fn, raises(TypeError))
 
174
        self.assertThat(fn, raises(ValueError))
175
175
 
176
176
    def test_select_many_only_using_parameters(self):
177
177
        app = self.start_fully_featured_app()
185
185
 
186
186
    def test_wait_select_single_succeeds_quickly(self):
187
187
        app = self.start_fully_featured_app()
188
 
        start_time = time()
 
188
        start_time = default_timer()
189
189
        main_window = app.wait_select_single('QMainWindow')
190
 
        end_time = time()
 
190
        end_time = default_timer()
191
191
        self.assertThat(main_window, NotEquals(None))
192
192
        self.assertThat(abs(end_time - start_time), LessThan(1))
193
193
 
194
194
    def test_wait_select_single_fails_slowly(self):
195
195
        app = self.start_fully_featured_app()
196
 
        start_time = time()
 
196
        start_time = default_timer()
197
197
        fn = lambda: app.wait_select_single('QMadeupType')
198
198
        self.assertThat(fn, raises(StateNotFoundError('QMadeupType')))
199
 
        end_time = time()
 
199
        end_time = default_timer()
200
200
        self.assertThat(abs(end_time - start_time), GreaterThan(9))
201
201
        self.assertThat(abs(end_time - start_time), LessThan(11))
202
202