Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: tools/telemetry/telemetry/tab_unittest.py

Issue 11819018: [Telemetry] Clean separation between tab (public API) and tab_backend (Chrome implementation). Flat… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make unit tests pass and merge. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/telemetry/telemetry/tab_test_case.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
5
4 from telemetry import tab_test_case 6 from telemetry import tab_test_case
5 from telemetry import tab_crash_exception 7 from telemetry import tab_crash_exception
6 from telemetry import util 8 from telemetry import util
7 9
8 10
9 def _IsDocumentVisible(tab): 11 def _IsDocumentVisible(tab):
10 state = tab.runtime.Evaluate('document.webkitVisibilityState') 12 state = tab.runtime.Evaluate('document.webkitVisibilityState')
11 tab.Disconnect() 13 # TODO(dtu): Remove when crbug.com/166243 is fixed.
14 tab._backend._Disconnect() # pylint: disable=W0212
12 return state == 'visible' 15 return state == 'visible'
13 16
14 17
15 class TabTest(tab_test_case.TabTestCase): 18 class TabTest(tab_test_case.TabTestCase):
16 def testNavigateAndWaitToForCompleteState(self): 19 def testNavigateAndWaitToForCompleteState(self):
17 self._tab.page.Navigate('http://www.google.com') 20 self._tab.page.Navigate('http://www.google.com')
18 self._tab.WaitForDocumentReadyStateToBeComplete() 21 self._tab.WaitForDocumentReadyStateToBeComplete()
19 22
20 def testNavigateAndWaitToForInteractiveState(self): 23 def testNavigateAndWaitToForInteractiveState(self):
21 self._tab.page.Navigate('http://www.google.com') 24 self._tab.page.Navigate('http://www.google.com')
(...skipping 11 matching lines...) Expand all
33 if not self._browser.supports_tab_control: 36 if not self._browser.supports_tab_control:
34 return 37 return
35 self.assertTrue(_IsDocumentVisible(self._tab)) 38 self.assertTrue(_IsDocumentVisible(self._tab))
36 new_tab = self._browser.tabs.New() 39 new_tab = self._browser.tabs.New()
37 util.WaitFor(lambda: _IsDocumentVisible(new_tab), timeout=5) 40 util.WaitFor(lambda: _IsDocumentVisible(new_tab), timeout=5)
38 self.assertFalse(_IsDocumentVisible(self._tab)) 41 self.assertFalse(_IsDocumentVisible(self._tab))
39 self._tab.Activate() 42 self._tab.Activate()
40 util.WaitFor(lambda: _IsDocumentVisible(self._tab), timeout=5) 43 util.WaitFor(lambda: _IsDocumentVisible(self._tab), timeout=5)
41 self.assertFalse(_IsDocumentVisible(new_tab)) 44 self.assertFalse(_IsDocumentVisible(new_tab))
42 45
46
47 class GpuTabTest(tab_test_case.TabTestCase):
48 def setUp(self):
49 self._extra_browser_args = ['--enable-gpu-benchmarking']
50 super(GpuTabTest, self).setUp()
51
52 def testScreenshot(self):
53 unittest_data_dir = os.path.join(os.path.dirname(__file__),
54 '..', 'unittest_data')
55 self._browser.SetHTTPServerDirectory(unittest_data_dir)
56 self._tab.page.Navigate(
57 self._browser.http_server.UrlOf('green_rect.html'))
58 self._tab.WaitForDocumentReadyStateToBeComplete()
59
60 # Skip this test if running against a browser without screenshot support
61 if self._tab.screenshot_supported:
62 screenshot = self._tab.Screenshot(5)
63 assert screenshot
64 screenshot.GetPixelColor(0, 0).AssertIsRGB(0, 255, 0)
65 screenshot.GetPixelColor(31, 31).AssertIsRGB(0, 255, 0)
66 screenshot.GetPixelColor(32, 32).AssertIsRGB(255, 255, 255)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/tab_test_case.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698