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

Side by Side Diff: tools/chrome_remote_control/chrome_remote_control/multi_page_benchmark_unittest_base.py

Issue 10984018: [chrome_remote_control] Add pylint to PRESUMMIT and fix lint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for landing Created 8 years, 2 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
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 4 import os
5 import unittest 5 import unittest
6 6
7 from chrome_remote_control import browser_finder 7 from chrome_remote_control import browser_finder
8 from chrome_remote_control import browser_options 8 from chrome_remote_control import browser_options
9 from chrome_remote_control import multi_page_benchmark 9 from chrome_remote_control import multi_page_benchmark
10 from chrome_remote_control import page_runner 10 from chrome_remote_control import page_runner
11 from chrome_remote_control import page_set 11 from chrome_remote_control import page_set
12 12
13 class MultiPageBenchmarkUnitTestBase(unittest.TestCase): 13 class MultiPageBenchmarkUnitTestBase(unittest.TestCase):
14 """unittest.TestCase-derived class to help in the construction of unit tests 14 """unittest.TestCase-derived class to help in the construction of unit tests
15 for a benchmark.""" 15 for a benchmark."""
16 16
17 unittest_data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 17 unittest_data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
18 '..', 'unittest_data')) 18 '..', 'unittest_data'))
19 19
20 def CreatePageSetFromFileInUnittestDataDir(self, test_filename): 20 def CreatePageSetFromFileInUnittestDataDir(self, test_filename):
21 path = os.path.join(self.unittest_data_dir, test_filename) 21 path = os.path.join(self.unittest_data_dir, test_filename)
22 self.assertTrue(os.path.exists(path)) 22 self.assertTrue(os.path.exists(path))
23 page = page_set.Page('file://%s' % path)
24 23
25 ps = page_set.PageSet() 24 page = page_set.Page('file://%s' % test_filename)
25
26 ps = page_set.PageSet(description='',
27 file_path=os.path.join(self.unittest_data_dir,
28 'test_pageset.json'))
26 ps.pages.append(page) 29 ps.pages.append(page)
27 return ps 30 return ps
28 31
29 def CustomizeOptionsForTest(self, options): 32 def CustomizeOptionsForTest(self, options):
30 """Override to customize default options.""" 33 """Override to customize default options."""
31 pass 34 pass
32 35
33 def RunBenchmark(self, benchmark, ps): 36 def RunBenchmark(self, benchmark, ps):
34 """Runs a benchmark against a pageset, returning the rows its outputs.""" 37 """Runs a benchmark against a pageset, returning the rows its outputs."""
35 assert browser_options.options_for_unittests 38 assert browser_options.options_for_unittests
36 options = ( 39 options = (
37 browser_options.options_for_unittests.Copy()) 40 browser_options.options_for_unittests.Copy())
38 temp_parser = options.CreateParser() 41 temp_parser = options.CreateParser()
39 benchmark.AddOptions(temp_parser) 42 benchmark.AddOptions(temp_parser)
40 defaults = temp_parser.get_default_values() 43 defaults = temp_parser.get_default_values()
41 for k, v in defaults.__dict__.items(): 44 for k, v in defaults.__dict__.items():
42 if hasattr(options, k): 45 if hasattr(options, k):
43 continue 46 continue
44 setattr(options, k, v) 47 setattr(options, k, v)
45 48
46 benchmark.CustomizeBrowserOptions(options) 49 benchmark.CustomizeBrowserOptions(options)
47 self.CustomizeOptionsForTest(options) 50 self.CustomizeOptionsForTest(options)
48 possible_browser = browser_finder.FindBrowser(options) 51 possible_browser = browser_finder.FindBrowser(options)
49 52
50 results = multi_page_benchmark.BenchmarkResults() 53 results = multi_page_benchmark.BenchmarkResults()
51 with page_runner.PageRunner(ps) as runner: 54 with page_runner.PageRunner(ps) as runner:
52 runner.Run(options, possible_browser, benchmark, results) 55 runner.Run(options, possible_browser, benchmark, results)
53 return results 56 return results
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698