diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 18:54:12 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 18:54:12 +0000 |
commit | 39b3349ed1694810b454f9af793c8c9bb0a3bd5d (patch) | |
tree | 8e92fc7f6db78f088b5c399565510b128d6bd484 | |
parent | b0614347a82164372648a92ee07ee1d9bc5eb3a1 (diff) | |
download | chromium_src-39b3349ed1694810b454f9af793c8c9bb0a3bd5d.zip chromium_src-39b3349ed1694810b454f9af793c8c9bb0a3bd5d.tar.gz chromium_src-39b3349ed1694810b454f9af793c8c9bb0a3bd5d.tar.bz2 |
Update Chrome Frame's reliability tests to allow them to register a given CF dll.
BUG=29451
TEST=Reliability tests can be staged more easily on the vm tests.
Review URL: http://codereview.chromium.org/656021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39903 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome_frame/chrome_frame.gyp | 4 | ||||
-rw-r--r-- | chrome_frame/test/reliability/run_all_unittests.cc | 31 | ||||
-rw-r--r-- | chrome_frame/test_utils.cc | 25 | ||||
-rw-r--r-- | chrome_frame/test_utils.h | 4 |
4 files changed, 58 insertions, 6 deletions
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp index a158134..168083f 100644 --- a/chrome_frame/chrome_frame.gyp +++ b/chrome_frame/chrome_frame.gyp @@ -393,9 +393,11 @@ 'dependencies': [ '../build/temp_gyp/googleurl.gyp:googleurl', '../chrome/chrome.gyp:browser', + '../chrome/chrome.gyp:common', '../chrome/chrome.gyp:utility', '../testing/gtest.gyp:gtest', '../base/allocator/allocator.gyp:allocator', + 'base_noicu', 'chrome_frame_npapi', 'chrome_frame_strings', ], @@ -406,6 +408,8 @@ 'test/reliability/reliability_test_suite.h', 'test/chrome_frame_test_utils.cc', 'test/chrome_frame_test_utils.h', + 'test_utils.cc', + 'test_utils.h', 'test/simulate_input.cc', 'test/simulate_input.h', 'chrome_tab.h', diff --git a/chrome_frame/test/reliability/run_all_unittests.cc b/chrome_frame/test/reliability/run_all_unittests.cc index 734a801..3b23a8a 100644 --- a/chrome_frame/test/reliability/run_all_unittests.cc +++ b/chrome_frame/test/reliability/run_all_unittests.cc @@ -4,7 +4,36 @@ #include "chrome_frame/test/reliability/reliability_test_suite.h" +#include "base/command_line.h" +#include "chrome/common/chrome_paths.h" +#include "chrome_frame/test_utils.h" + +const wchar_t kRegisterDllFlag[] = L"register"; + int main(int argc, char **argv) { - return ReliabilityTestSuite(argc, argv).Run(); + + // If --register is passed, then we need to ensure that Chrome Frame is + // registered before starting up the reliability tests. + CommandLine::Init(argc, argv); + CommandLine* cmd_line = CommandLine::ForCurrentProcess(); + DCHECK(cmd_line); + + // We create this slightly early as it is the one who instantiates THE + // AtExitManager which some of the other stuff below relies on. + ReliabilityTestSuite test_suite(argc, argv); + + int result = -1; + if (cmd_line->HasSwitch(kRegisterDllFlag)) { + std::wstring dll_path = cmd_line->GetSwitchValue(kRegisterDllFlag); + + // Run() must be called within the scope of the ScopedChromeFrameRegistrar + // to ensure that the correct DLL remains registered during the tests. + ScopedChromeFrameRegistrar scoped_chrome_frame_registrar(dll_path); + result = test_suite.Run(); + } else { + result = test_suite.Run(); + } + + return result; } diff --git a/chrome_frame/test_utils.cc b/chrome_frame/test_utils.cc index cf6b219..e87c4bb 100644 --- a/chrome_frame/test_utils.cc +++ b/chrome_frame/test_utils.cc @@ -25,10 +25,21 @@ const wchar_t kChromeFrameDllName[] = L"npchrome_frame.dll"; FilePath ScopedChromeFrameRegistrar::GetChromeFrameBuildPath() { FilePath build_path; PathService::Get(chrome::DIR_APP, &build_path); - build_path = build_path.Append(L"servers"). - Append(kChromeFrameDllName); - file_util::PathExists(build_path); - return build_path; + + FilePath dll_path = build_path.Append(L"servers"). + Append(kChromeFrameDllName); + + if (!file_util::PathExists(dll_path)) { + // Well, dang.. try looking in the current directory. + dll_path = build_path.Append(kChromeFrameDllName); + } + + if (!file_util::PathExists(dll_path)) { + // No luck, return something empty. + dll_path = FilePath(); + } + + return dll_path; } void ScopedChromeFrameRegistrar::RegisterDefaults() { @@ -63,6 +74,12 @@ void ScopedChromeFrameRegistrar::RegisterAtPath( // Non-statics +ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar( + const std::wstring& path) { + original_dll_path_ = path; + RegisterChromeFrameAtPath(original_dll_path_); +} + ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar() { original_dll_path_ = GetChromeFrameBuildPath().ToWStringHack(); RegisterChromeFrameAtPath(original_dll_path_); diff --git a/chrome_frame/test_utils.h b/chrome_frame/test_utils.h index 0d18379..f3ad937 100644 --- a/chrome_frame/test_utils.h +++ b/chrome_frame/test_utils.h @@ -15,7 +15,8 @@ extern const wchar_t kChromeFrameDllName[]; // Helper class used to register different chrome frame DLLs while running -// tests. At construction, this registers the DLL found in the build path. +// tests. The default constructor registers the DLL found in the build path. + // At destruction, again registers the DLL found in the build path if another // DLL has since been registered. Triggers GTEST asserts on failure. // @@ -24,6 +25,7 @@ extern const wchar_t kChromeFrameDllName[]; class ScopedChromeFrameRegistrar { public: ScopedChromeFrameRegistrar(); + ScopedChromeFrameRegistrar(const std::wstring& path); virtual ~ScopedChromeFrameRegistrar(); void RegisterChromeFrameAtPath(const std::wstring& path); |