def testGestureAction(self): """Test that GestureAction.RunAction() calls RunGesture().""" mock_timer = simple_mock.MockTimer() action = MockGestureAction(mock_timer.Sleep, {'duration': 1}) action.RunAction(None, self._tab) self.assertEqual(mock_timer.GetTime(), 1)
def setUp(self): super(GTestProgressReporterTest, self).setUp() self._mock_timer = simple_mock.MockTimer(gtest_progress_reporter) self._output_stream = base_test_results_unittest.TestOutputStream() self._reporter = gtest_progress_reporter.GTestProgressReporter( self._output_stream)
def setUp(self): super(GTestProgressReporterTest, self).setUp() self._stream = TestOutputStream() self._formatter = gtest_progress_reporter.GTestProgressReporter( self._stream) self._mock_timer = simple_mock.MockTimer() self._real_time_time = gtest_progress_reporter.time.time gtest_progress_reporter.time.time = self._mock_timer.GetTime
def testWaitAction(self): self.Navigate('blank.html') self.assertEquals( self._tab.EvaluateJavaScript('document.location.pathname;'), '/blank.html') mock_timer = simple_mock.MockTimer() real_time_sleep = wait.time.sleep wait.time.sleep = mock_timer.Sleep try: i = wait.WaitAction({'condition': 'duration', 'seconds': 1}) i.RunAction(None, self._tab) self.assertEqual(mock_timer.GetTime(), 1) finally: wait.time.sleep = real_time_sleep
def testWaitAfter(self): mock_timer = simple_mock.MockTimer() real_time_sleep = wait.time.sleep wait.time.sleep = mock_timer.Sleep try: action = MockGestureAction(mock_timer.Sleep, { 'duration': 1, 'wait_after': { 'seconds': 1 } }) action.RunAction(None, self._tab) self.assertEqual(mock_timer.GetTime(), 2) finally: wait.time.sleep = real_time_sleep
def testWaitActionTimeout(self): mock_timer = simple_mock.MockTimer() real_wait_time_sleep = wait.time.sleep real_util_time_sleep = util.time.sleep real_util_time_time = util.time.time wait.time.sleep = mock_timer.Sleep util.time.sleep = mock_timer.Sleep util.time.time = mock_timer.GetTime try: wait_action = wait.WaitAction({ 'condition': 'javascript', 'javascript': '1 + 1 === 3', 'timeout': 1 }) self.assertRaises(util.TimeoutException, lambda: wait_action.RunAction(None, self._tab)) self.assertLess(mock_timer.GetTime(), 5) finally: wait.time.sleep = real_wait_time_sleep util.time.sleep = real_util_time_sleep util.time.time = real_util_time_time
def setUp(self): super(GTestUnittestResultsTest, self).setUp() self._mock_timer = simple_mock.MockTimer() self._real_gtest_time_time = gtest_unittest_results.time.time gtest_unittest_results.time.time = self._mock_timer.GetTime
def setUp(self): self._mock_timer = simple_mock.MockTimer(inspector_websocket)