| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import os | 4 import os |
| 5 import time | 5 import time |
| 6 | 6 |
| 7 from telemetry import wait_action | 7 from telemetry import wait_action |
| 8 from telemetry import tab_test_case | 8 from telemetry import tab_test_case |
| 9 | 9 |
| 10 class WaitActionTest(tab_test_case.TabTestCase): | 10 class WaitActionTest(tab_test_case.TabTestCase): |
| 11 def testWaitAction(self): | 11 def testWaitAction(self): |
| 12 unittest_data_dir = os.path.join(os.path.dirname(__file__), | 12 unittest_data_dir = os.path.join(os.path.dirname(__file__), |
| 13 '..', 'unittest_data') | 13 '..', 'unittest_data') |
| 14 self._browser.SetHTTPServerDirectory(unittest_data_dir) | 14 self._browser.SetHTTPServerDirectory(unittest_data_dir) |
| 15 self._tab.Navigate( | 15 self._tab.Navigate( |
| 16 self._browser.http_server.UrlOf('blank.html')) | 16 self._browser.http_server.UrlOf('blank.html')) |
| 17 self._tab.WaitForDocumentReadyStateToBeComplete() | 17 self._tab.WaitForDocumentReadyStateToBeComplete() |
| 18 self.assertEquals( | 18 self.assertEquals( |
| 19 self._tab.EvaluateJavaScript('document.location.pathname;'), | 19 self._tab.EvaluateJavaScript('document.location.pathname;'), |
| 20 '/blank.html') | 20 '/blank.html') |
| 21 | 21 |
| 22 i = wait_action.WaitAction({ 'condition': 'duration', 'seconds': 1 }) | 22 i = wait_action.WaitAction({ 'condition': 'duration', 'seconds': 1 }) |
| 23 | 23 |
| 24 start_time = time.time() | 24 start_time = time.time() |
| 25 i.RunAction(None, self._tab, None) | 25 i.RunAction(None, self._tab, None) |
| 26 self.assertAlmostEqual(time.time() - start_time, 1, places=2) | 26 self.assertAlmostEqual(time.time() - start_time, 1, places=2) |
| OLD | NEW |