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

Unified Diff: tools/telemetry/telemetry/unittest/browser_test_case.py

Issue 469593002: [telemetry] Create BrowserTestCase to reuse the browser for browser_unittest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update page_test_test_case references in tools/perf/ Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/unittest/browser_test_case.py
diff --git a/tools/telemetry/telemetry/unittest/browser_test_case.py b/tools/telemetry/telemetry/unittest/browser_test_case.py
new file mode 100644
index 0000000000000000000000000000000000000000..c824e74c5bed2b1a8c8c9c42527976b31036b57f
--- /dev/null
+++ b/tools/telemetry/telemetry/unittest/browser_test_case.py
@@ -0,0 +1,45 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import unittest
+
+from telemetry.core import browser_finder
+from telemetry.unittest import options_for_unittests
+from telemetry.util import path
+
+
+class BrowserTestCase(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ options = options_for_unittests.GetCopy()
+ cls.CustomizeBrowserOptions(options.browser_options)
+ browser_to_create = browser_finder.FindBrowser(options)
+ if not browser_to_create:
+ raise Exception('No browser found, cannot continue test.')
+
+ cls._browser = None
+ try:
+ cls._browser = browser_to_create.Create()
+ cls._browser.Start()
+ except:
+ cls.tearDownClass()
+ raise
+
+ @classmethod
+ def tearDownClass(cls):
+ if cls._browser:
+ cls._browser.Close()
+ cls._browser = None
+
+ @classmethod
+ def CustomizeBrowserOptions(cls, options):
+ """Override to add test-specific options to the BrowserOptions object"""
+ pass
+
+ @classmethod
+ def UrlOfUnittestFile(cls, filename):
+ cls._browser.SetHTTPServerDirectories(path.GetUnittestDataDir())
+ file_path = os.path.join(path.GetUnittestDataDir(), filename)
+ return cls._browser.http_server.UrlOf(file_path)
« no previous file with comments | « tools/telemetry/telemetry/testing/page_test_test_case.py ('k') | tools/telemetry/telemetry/unittest/page_test_test_case.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698