1 # Copyright 2014 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.
8 from telemetry
.core
import browser_finder
9 from telemetry
.unittest
import options_for_unittests
10 from telemetry
.util
import path
13 class BrowserTestCase(unittest
.TestCase
):
16 options
= options_for_unittests
.GetCopy()
17 cls
.CustomizeBrowserOptions(options
.browser_options
)
18 browser_to_create
= browser_finder
.FindBrowser(options
)
19 if not browser_to_create
:
20 raise Exception('No browser found, cannot continue test.')
24 cls
._browser
= browser_to_create
.Create()
31 def tearDownClass(cls
):
37 def CustomizeBrowserOptions(cls
, options
):
38 """Override to add test-specific options to the BrowserOptions object"""
42 def UrlOfUnittestFile(cls
, filename
):
43 cls
._browser
.SetHTTPServerDirectories(path
.GetUnittestDataDir())
44 file_path
= os
.path
.join(path
.GetUnittestDataDir(), filename
)
45 return cls
._browser
.http_server
.UrlOf(file_path
)