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 unittest | 5 import unittest |
6 | 6 |
7 from telemetry import browser_finder | 7 from telemetry.core import browser_finder |
8 from telemetry import options_for_unittests | 8 from telemetry.test import options_for_unittests |
9 | 9 |
10 class TemporaryHTTPServerTest(unittest.TestCase): | 10 class TemporaryHTTPServerTest(unittest.TestCase): |
11 def testBasicHosting(self): | 11 def testBasicHosting(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 options = options_for_unittests.GetCopy() | 14 options = options_for_unittests.GetCopy() |
15 browser_to_create = browser_finder.FindBrowser(options) | 15 browser_to_create = browser_finder.FindBrowser(options) |
16 with browser_to_create.Create() as b: | 16 with browser_to_create.Create() as b: |
17 b.SetHTTPServerDirectory(unittest_data_dir) | 17 b.SetHTTPServerDirectory(unittest_data_dir) |
18 t = b.tabs[0] | 18 t = b.tabs[0] |
19 t.Navigate(b.http_server.UrlOf('/blank.html')) | 19 t.Navigate(b.http_server.UrlOf('/blank.html')) |
20 t.WaitForDocumentReadyStateToBeComplete() | 20 t.WaitForDocumentReadyStateToBeComplete() |
21 x = t.EvaluateJavaScript('document.body.innerHTML') | 21 x = t.EvaluateJavaScript('document.body.innerHTML') |
22 x = x.strip() | 22 x = x.strip() |
23 | 23 |
24 self.assertEquals(x, 'Hello world') | 24 self.assertEquals(x, 'Hello world') |
OLD | NEW |