Пример #1
0
    def test_wait_non_existing(self):
        """test timing of the wait method for non-existing element"""
        allowable_error = .2

        start = timestamp()
        self.assertRaises(TimeoutError, self.app.BlahBlah.wait, 'exists')
        expected = Timings.window_find_timeout
        self.assertEqual(True, expected - allowable_error <= (timestamp() - start) < expected + allowable_error)
Пример #2
0
    def test_exists(self):
        """Check that windows exist"""
        self.assertEquals(True, self.dlgspec.Exists())
        self.assertEquals(True, self.dlgspec.Exists(0))
        self.assertEquals(True, self.ctrlspec.Exists())
        # TODO: test a control that is not visible but exists
        #self.assertEquals(True, self.app.DefaultIME.Exists())

        start = timestamp()
        self.assertEquals(False, self.app.BlahBlah.Exists(timeout=.1))
        self.assertEquals(True, timestamp() - start < .3)

        start = timestamp()
        self.assertEquals(False, self.app.BlahBlah.exists(timeout=3))
        self.assertEquals(True, 2.7 < timestamp() - start < 3.3)
Пример #3
0
    def test_wait_invisible(self):
        """test timing of the wait method for non-existing element and existing invisible one"""
        # TODO: re-use an MFC sample for this test
        allowable_error = .2

        start = timestamp()
        self.assertRaises(TimeoutError, self.app.BlahBlah.wait, 'visible')
        expected = Timings.window_find_timeout
        self.assertEqual(
            True, expected - allowable_error <=
            (timestamp() - start) < expected + allowable_error)

        # make sure Status Bar is not visible
        status_bar_menu = self.app.UntitledNotepad.menu().item(
            '&View').sub_menu().item('&Status Bar')
        if status_bar_menu.is_checked():
            status_bar_menu.select()

        # check that existing invisible control is still found with 'exists' criterion
        status_bar_spec = self.app.UntitledNotepad.child_window(
            class_name="msctls_statusbar32", visible_only=False)
        self.assertEqual('StatusBar',
                         status_bar_spec.wait('exists').friendly_class_name())

        start = timestamp()
        self.assertRaises(TimeoutError, status_bar_spec.wait, 'exists visible')
        self.assertEqual(
            True, expected - allowable_error <=
            (timestamp() - start) < expected + allowable_error)

        start = timestamp()
        self.assertRaises(TimeoutError, status_bar_spec.wait, 'visible exists')
        self.assertEqual(
            True, expected - allowable_error <=
            (timestamp() - start) < expected + allowable_error)
Пример #4
0
    def test_exists_timing(self):
        """test the timing of the exists method"""
        # try ones that should be found immediately
        start = timestamp()
        self.assertEquals(True, self.dlgspec.Exists())
        self.assertEquals(True, timestamp() - start < .3)

        start = timestamp()
        self.assertEquals(True, self.ctrlspec.Exists())
        self.assertEquals(True, timestamp() - start < .3)

        # try one that should not be found
        start = timestamp()
        self.assertEquals(True, self.dlgspec.Exists(.5))
        timedif = timestamp() - start
        self.assertEquals(True, .49 > timedif < .6)
Пример #5
0
    def test_wait_not(self):
        """
        Test that wait not fails for all the following

        * raises and error when criteria not met
        * timing is close to the timeout value
        """
        allowable_error = .16

        start = timestamp()
        self.assertRaises(TimeoutError, self.dlgspec.WaitNot, "enaBleD ", .1,
                          .05)
        taken = timestamp() - start
        if .1 < (taken) > .1 + allowable_error:
            self.assertEqual(.12, taken)

        start = timestamp()
        self.assertRaises(TimeoutError, self.dlgspec.WaitNot, "  ready", .1,
                          .05)
        self.assertEqual(True, .1 <=
                         (timestamp() - start) < .1 + allowable_error)

        start = timestamp()
        self.assertRaises(TimeoutError, self.dlgspec.WaitNot, " exiSTS", .1,
                          .05)
        self.assertEqual(True, .1 <=
                         (timestamp() - start) < .1 + allowable_error)

        start = timestamp()
        self.assertRaises(TimeoutError, self.dlgspec.WaitNot, " VISIBLE ", .1,
                          .05)
        self.assertEqual(True, .1 <=
                         (timestamp() - start) < .1 + allowable_error)

        start = timestamp()
        self.assertRaises(TimeoutError, self.dlgspec.WaitNot, " ready enabled",
                          .1, .05)
        self.assertEqual(True, .1 <=
                         (timestamp() - start) < .1 + allowable_error)

        start = timestamp()
        self.assertRaises(TimeoutError, self.dlgspec.WaitNot,
                          "visible exists ", .1, .05)
        self.assertEqual(True, .1 <=
                         (timestamp() - start) < .1 + allowable_error)

        start = timestamp()
        self.assertRaises(TimeoutError, self.dlgspec.WaitNot, "exists ", .1,
                          .05)
        self.assertEqual(True, .1 <=
                         (timestamp() - start) < .1 + allowable_error)

        start = timestamp()
        self.assertRaises(TimeoutError, self.dlgspec.WaitNot, "actIve ", .1,
                          .05)
        self.assertEqual(True, .1 <=
                         (timestamp() - start) < .1 + allowable_error)

        self.assertRaises(SyntaxError, self.dlgspec.WaitNot,
                          "Invalid_criteria")
Пример #6
0
    def test_wait(self):
        """test the functionality and timing of the wait method"""
        allowable_error = .2

        start = timestamp()
        self.assertEqual(self.dlgspec.WrapperObject(),
                         self.dlgspec.Wait("enaBleD "))
        time_taken = (timestamp() - start)
        if not 0 <= time_taken < (0 + 2 * allowable_error):
            self.assertEqual(.02, time_taken)

        start = timestamp()
        self.assertEqual(self.dlgspec.WrapperObject(),
                         self.dlgspec.Wait("  ready"))
        self.assertEqual(True, 0 <=
                         (timestamp() - start) < 0 + allowable_error)

        start = timestamp()
        self.assertEqual(self.dlgspec.WrapperObject(),
                         self.dlgspec.Wait(" exiSTS"))
        self.assertEqual(True, 0 <=
                         (timestamp() - start) < 0 + allowable_error)

        start = timestamp()
        self.assertEqual(self.dlgspec.WrapperObject(),
                         self.dlgspec.Wait(" VISIBLE "))
        self.assertEqual(True, 0 <=
                         (timestamp() - start) < 0 + allowable_error)

        start = timestamp()
        self.assertEqual(self.dlgspec.WrapperObject(),
                         self.dlgspec.Wait(" ready enabled"))
        self.assertEqual(True, 0 <=
                         (timestamp() - start) < 0 + allowable_error)

        start = timestamp()
        self.assertEqual(self.dlgspec.WrapperObject(),
                         self.dlgspec.Wait("visible exists "))
        self.assertEqual(True, 0 <=
                         (timestamp() - start) < 0 + allowable_error)

        start = timestamp()
        self.assertEqual(self.dlgspec.WrapperObject(),
                         self.dlgspec.Wait("exists "))
        self.assertEqual(True, 0 <=
                         (timestamp() - start) < 0 + allowable_error)

        start = timestamp()
        self.assertEqual(self.dlgspec.WrapperObject(),
                         self.dlgspec.Wait("actIve "))
        self.assertEqual(True, 0 <=
                         (timestamp() - start) < 0 + allowable_error)

        self.assertRaises(SyntaxError, self.dlgspec.Wait, "Invalid_criteria")