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

Side by Side Diff: content/test/gpu/gpu_stress_tests/gpu_stress_unittest.py

Issue 11668013: Added GPU stress test with multiple tabs in one single window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moves tests to content/test/gpu. Created 7 years, 8 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 | « content/test/gpu/gpu_stress_tests/__init__.py ('k') | content/test/gpu/run_gpu_stress_tests » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import os
6 import random
7 import unittest
8
9 from telemetry.core import browser_finder
10 from telemetry.test import options_for_unittests
11
12 CUR_DIR = os.path.dirname(__file__)
13 DATA_DIR = os.path.join(CUR_DIR, os.pardir, os.pardir, 'data', 'gpu')
14
15 # Number of tabs to open for testing.
16 NUM_TABS = 100
17
18
19 class GpuValidationUnittest(unittest.TestCase):
20 """Verifies that GPU works properly under stress."""
21
22 def setUp(self):
23 """Gets the test assets and launches browser.
24
25 Test assets are html files from test data directory.
26 """
27
28 # Gets the test assets.
29 self._asset_list = []
30 for _, _, files in os.walk(DATA_DIR):
31 self._asset_list.extend([f for f in files if f.endswith('.html')])
32 self._num_assets = len(self._asset_list)
33
34 # Launches browser.
35 options = options_for_unittests.GetCopy()
36 browser_to_create = browser_finder.FindBrowser(options)
37 self._browser = browser_to_create.Create()
38 self._browser.SetHTTPServerDirectories([DATA_DIR])
39 self._tabs = self._browser.tabs
40
41 def tearDown(self):
42 self._browser.Close()
43
44 def testMultipleTabsInSingleWindow(self):
45 """Tests with multiple tabs opened in a single window."""
46
47 # Opens the tabs and navigates to the asset urls.
48 for i in xrange(NUM_TABS):
49 asset = self._asset_list[i % self._num_assets]
50 tab = self._tabs.New()
51 tab.Navigate(self._GetUrl(asset))
52
53 # Randomly cycles to the tabs.
54 tab_nums = range(1, NUM_TABS + 1)
dtu 2013/04/03 00:32:49 xrange
Danh Nguyen 2013/04/03 15:21:58 xrange doesn't work with random.shuffle() on the n
55 random.shuffle(tab_nums)
56 for num in tab_nums:
57 self._tabs[num].Activate()
58
59 # Randomly closes the tabs.
60 num_tabs = len(self._tabs)
61 while num_tabs > 1:
dtu 2013/04/03 00:32:49 Why not just always len(self._tabs)?
Danh Nguyen 2013/04/03 15:21:58 Done. Thanks, Dave. The loop looks much better no
62 self._tabs[random.randrange(1, num_tabs)].Close()
63 num_tabs -= 1
64
65 def _GetUrl(self, asset):
66 return self._browser.http_server.UrlOf(asset)
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_stress_tests/__init__.py ('k') | content/test/gpu/run_gpu_stress_tests » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698