diff options
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/chrome_frame.gyp | 2 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 8 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.h | 3 | ||||
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.cc | 4 | ||||
-rw-r--r-- | chrome_frame/test/perf/chrome_frame_perftest.cc | 15 | ||||
-rw-r--r-- | chrome_frame/test/perf/run_all.cc | 3 | ||||
-rw-r--r-- | chrome_frame/test/reliability/run_all_unittests.cc | 3 | ||||
-rw-r--r-- | chrome_frame/test/run_all_unittests.cc | 6 | ||||
-rw-r--r-- | chrome_frame/test/test_with_web_server.cc | 6 | ||||
-rw-r--r-- | chrome_frame/test_utils.cc | 42 | ||||
-rw-r--r-- | chrome_frame/test_utils.h | 19 |
11 files changed, 82 insertions, 29 deletions
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp index ce987be..ffd770c 100644 --- a/chrome_frame/chrome_frame.gyp +++ b/chrome_frame/chrome_frame.gyp @@ -464,6 +464,8 @@ 'test/net/test_automation_resource_message_filter.cc', 'test/net/test_automation_resource_message_filter.h', 'chrome_tab.h', + 'test_utils.cc', + 'test_utils.h', ], 'conditions': [ ['OS=="win"', { diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 85ecc5b..17f4483 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -672,4 +672,12 @@ bool KillProcesses(const std::wstring& executable_name, int exit_code, return result; } +ScopedChromeFrameRegistrar::RegistrationType GetTestBedType() { + if (GetConfigBool(false, L"PerUserTestBed")) { + return ScopedChromeFrameRegistrar::PER_USER; + } else { + return ScopedChromeFrameRegistrar::SYSTEM_LEVEL; + } +} + } // namespace chrome_frame_test diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h index cc3d2be..3715f88f 100644 --- a/chrome_frame/test/chrome_frame_test_utils.h +++ b/chrome_frame/test/chrome_frame_test_utils.h @@ -328,6 +328,9 @@ class ScopedVirtualizeHklmAndHkcu { bool KillProcesses(const std::wstring& executable_name, int exit_code, bool wait); +// Returns the type of test bed, PER_USER or SYSTEM_LEVEL. +ScopedChromeFrameRegistrar::RegistrationType GetTestBedType(); + } // namespace chrome_frame_test // TODO(tommi): This is a temporary workaround while we're getting our diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index 5b69f3a..0a3e584 100644 --- a/chrome_frame/test/net/fake_external_tab.cc +++ b/chrome_frame/test/net/fake_external_tab.cc @@ -38,6 +38,7 @@ #include "chrome_frame/test/chrome_frame_test_utils.h" #include "chrome_frame/test/net/test_automation_resource_message_filter.h" #include "chrome_frame/test/simulate_input.h" +#include "chrome_frame/test_utils.h" #include "chrome_frame/test/win_event_receiver.h" #include "chrome_frame/utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -501,6 +502,9 @@ int main(int argc, char** argv) { LOG(INFO) << "Not running ChromeFrame net tests on IE9"; return 0; } + + ScopedChromeFrameRegistrar registrar(chrome_frame_test::GetTestBedType()); + WindowWatchdog watchdog; // See url_request_unittest.cc for these credentials. SupplyProxyCredentials credentials("user", "secret"); diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc index 2f645d2..e83bf65 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.cc +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc @@ -389,7 +389,8 @@ class ChromeFrameStartupTestActiveX : public ChromeFrameStartupTest { public: virtual void SetUp() { // Register the Chrome Frame DLL in the build directory. - chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar); + chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar( + ScopedChromeFrameRegistrar::SYSTEM_LEVEL)); ChromeFrameStartupTest::SetUp(); } @@ -457,7 +458,8 @@ class ChromeFrameStartupTestActiveXReference // override the browser directory to use the reference build instead. virtual void SetUp() { // Register the reference build Chrome Frame DLL. - chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar); + chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar( + ScopedChromeFrameRegistrar::SYSTEM_LEVEL)); chrome_frame_registrar_->RegisterReferenceChromeFrameBuild(); ChromeFrameStartupTest::SetUp(); @@ -567,7 +569,8 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { virtual void SetUp() { // Register the Chrome Frame DLL in the build directory. - chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar); + chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar( + ScopedChromeFrameRegistrar::SYSTEM_LEVEL)); } void RunTest(const char* test_name, char* urls[], int total_urls) { @@ -748,7 +751,8 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { class ChromeFrameMemoryTestReference : public ChromeFrameMemoryTest { public: virtual void SetUp() { - chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar); + chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar( + ScopedChromeFrameRegistrar::SYSTEM_LEVEL)); chrome_frame_registrar_->RegisterReferenceChromeFrameBuild(); } @@ -872,7 +876,8 @@ class ChromeFrameCreationTestReference : public ChromeFrameCreationTest { public: // override the browser directory to use the reference build instead. virtual void SetUp() { - chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar); + chrome_frame_registrar_.reset(new ScopedChromeFrameRegistrar( + ScopedChromeFrameRegistrar::SYSTEM_LEVEL)); chrome_frame_registrar_->RegisterReferenceChromeFrameBuild(); ChromeFrameStartupTest::SetUp(); } diff --git a/chrome_frame/test/perf/run_all.cc b/chrome_frame/test/perf/run_all.cc index 7d66299..3b29280 100644 --- a/chrome_frame/test/perf/run_all.cc +++ b/chrome_frame/test/perf/run_all.cc @@ -28,7 +28,8 @@ int main(int argc, char **argv) { // Use ctor/raii to register the local Chrome Frame dll. scoped_ptr<ScopedChromeFrameRegistrar> registrar( - new ScopedChromeFrameRegistrar); + new ScopedChromeFrameRegistrar( + ScopedChromeFrameRegistrar::SYSTEM_LEVEL)); int ret = perf_suite.Run(); DeleteConfigValue(kChromeFrameHeadlessMode); diff --git a/chrome_frame/test/reliability/run_all_unittests.cc b/chrome_frame/test/reliability/run_all_unittests.cc index 26510e5..d5b42da 100644 --- a/chrome_frame/test/reliability/run_all_unittests.cc +++ b/chrome_frame/test/reliability/run_all_unittests.cc @@ -33,7 +33,8 @@ int main(int argc, char **argv) { // 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); + ScopedChromeFrameRegistrar scoped_chrome_frame_registrar( + dll_path, ScopedChromeFrameRegistrar::SYSTEM_LEVEL); result = test_suite.Run(); } else { result = test_suite.Run(); diff --git a/chrome_frame/test/run_all_unittests.cc b/chrome_frame/test/run_all_unittests.cc index 6fb4176..54129a2 100644 --- a/chrome_frame/test/run_all_unittests.cc +++ b/chrome_frame/test/run_all_unittests.cc @@ -81,12 +81,12 @@ int main(int argc, char **argv) { // AtExitManager. // TODO(robertshield): Make these tests restore the original registration // once done. - ScopedChromeFrameRegistrar registrar; + ScopedChromeFrameRegistrar registrar(chrome_frame_test::GetTestBedType()); // Register IAccessible2 proxy stub DLL, needed for some tests. ScopedChromeFrameRegistrar ia2_registrar( - chrome_frame_test::GetIAccessible2ProxyStubPath().value()); - + chrome_frame_test::GetIAccessible2ProxyStubPath().value(), + ScopedChromeFrameRegistrar::SYSTEM_LEVEL); ret = test_suite.Run(); } diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc index 07b099a..adb0b96 100644 --- a/chrome_frame/test/test_with_web_server.cc +++ b/chrome_frame/test/test_with_web_server.cc @@ -929,14 +929,16 @@ const wchar_t kInstallFlowTestUrl[] = TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { if (base::win::GetVersion() < base::win::VERSION_VISTA) { ScopedChromeFrameRegistrar::UnregisterAtPath( - ScopedChromeFrameRegistrar::GetChromeFrameBuildPath().value()); + ScopedChromeFrameRegistrar::GetChromeFrameBuildPath().value(), + chrome_frame_test::GetTestBedType()); ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); ScopedChromeFrameRegistrar::RegisterAtPath( - ScopedChromeFrameRegistrar::GetChromeFrameBuildPath().value()); + ScopedChromeFrameRegistrar::GetChromeFrameBuildPath().value(), + chrome_frame_test::GetTestBedType()); server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), kPostedResultSubstring); diff --git a/chrome_frame/test_utils.cc b/chrome_frame/test_utils.cc index 708db6f..18d50ff 100644 --- a/chrome_frame/test_utils.cc +++ b/chrome_frame/test_utils.cc @@ -19,6 +19,7 @@ #include "base/win/scoped_handle.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome_frame/test/chrome_frame_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" const wchar_t kChromeFrameDllName[] = L"npchrome_frame.dll"; @@ -47,21 +48,26 @@ FilePath ScopedChromeFrameRegistrar::GetChromeFrameBuildPath() { void ScopedChromeFrameRegistrar::RegisterDefaults() { FilePath dll_path = GetChromeFrameBuildPath(); - RegisterAtPath(dll_path.value()); + RegisterAtPath(dll_path.value(), SYSTEM_LEVEL); } void ScopedChromeFrameRegistrar::RegisterAtPath( - const std::wstring& path) { + const std::wstring& path, RegistrationType registration_type) { ASSERT_FALSE(path.empty()); HMODULE dll_handle = LoadLibrary(path.c_str()); ASSERT_TRUE(dll_handle != NULL); typedef HRESULT (STDAPICALLTYPE* DllRegisterServerFn)(); - DllRegisterServerFn register_server = - reinterpret_cast<DllRegisterServerFn>(GetProcAddress( - dll_handle, "DllRegisterServer")); + DllRegisterServerFn register_server = NULL; + if (registration_type == PER_USER) { + register_server = reinterpret_cast<DllRegisterServerFn>(GetProcAddress( + dll_handle, "DllRegisterUserServer")); + } else { + register_server = reinterpret_cast<DllRegisterServerFn>(GetProcAddress( + dll_handle, "DllRegisterServer")); + } ASSERT_TRUE(register_server != NULL); EXPECT_HRESULT_SUCCEEDED((*register_server)()); @@ -76,17 +82,21 @@ void ScopedChromeFrameRegistrar::RegisterAtPath( } void ScopedChromeFrameRegistrar::UnregisterAtPath( - const std::wstring& path) { + const std::wstring& path, RegistrationType registration_type) { ASSERT_FALSE(path.empty()); HMODULE dll_handle = LoadLibrary(path.c_str()); ASSERT_TRUE(dll_handle != NULL); typedef HRESULT (STDAPICALLTYPE* DllUnregisterServerFn)(); - DllUnregisterServerFn unregister_server = - reinterpret_cast<DllUnregisterServerFn>(GetProcAddress( - dll_handle, "DllUnregisterServer")); - + DllUnregisterServerFn unregister_server = NULL; + if (registration_type == PER_USER) { + unregister_server = reinterpret_cast<DllUnregisterServerFn> + (GetProcAddress(dll_handle, "DllUnregisterUserServer")); + } else { + unregister_server = reinterpret_cast<DllUnregisterServerFn> + (GetProcAddress(dll_handle, "DllUnregisterServer")); + } ASSERT_TRUE(unregister_server != NULL); EXPECT_HRESULT_SUCCEEDED((*unregister_server)()); @@ -120,12 +130,15 @@ FilePath ScopedChromeFrameRegistrar::GetReferenceChromeFrameDllPath() { // Non-statics ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar( - const std::wstring& path) { + const std::wstring& path, RegistrationType registration_type) + : registration_type_(registration_type) { original_dll_path_ = path; RegisterChromeFrameAtPath(original_dll_path_); } -ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar() { +ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar( + RegistrationType registration_type) + : registration_type_(registration_type) { original_dll_path_ = GetChromeFrameBuildPath().value(); RegisterChromeFrameAtPath(original_dll_path_); } @@ -133,12 +146,15 @@ ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar() { ScopedChromeFrameRegistrar::~ScopedChromeFrameRegistrar() { if (FilePath(original_dll_path_) != FilePath(new_chrome_frame_dll_path_)) { RegisterChromeFrameAtPath(original_dll_path_); + } else if (registration_type_ == PER_USER) { + UnregisterAtPath(new_chrome_frame_dll_path_, registration_type_); + chrome_frame_test::KillProcesses(L"chrome_frame_helper.exe", 0, false); } } void ScopedChromeFrameRegistrar::RegisterChromeFrameAtPath( const std::wstring& path) { - RegisterAtPath(path); + RegisterAtPath(path, registration_type_); new_chrome_frame_dll_path_ = path; } diff --git a/chrome_frame/test_utils.h b/chrome_frame/test_utils.h index e0d5c27..f3947c0 100644 --- a/chrome_frame/test_utils.h +++ b/chrome_frame/test_utils.h @@ -25,8 +25,14 @@ extern const wchar_t kChromeLauncherExeName[]; // registered chrome frame DLL (e.g. by looking in HKCR) on destruction. class ScopedChromeFrameRegistrar { public: - ScopedChromeFrameRegistrar(); - explicit ScopedChromeFrameRegistrar(const std::wstring& path); + enum RegistrationType { + PER_USER, + SYSTEM_LEVEL, + }; + + explicit ScopedChromeFrameRegistrar(RegistrationType registration_type); + ScopedChromeFrameRegistrar(const std::wstring& path, + RegistrationType registration_type); virtual ~ScopedChromeFrameRegistrar(); void RegisterChromeFrameAtPath(const std::wstring& path); @@ -36,8 +42,10 @@ class ScopedChromeFrameRegistrar { std::wstring GetChromeFrameDllPath() const; static FilePath GetChromeFrameBuildPath(); - static void RegisterAtPath(const std::wstring& path); - static void UnregisterAtPath(const std::wstring& path); + static void RegisterAtPath(const std::wstring& path, + RegistrationType registration_type); + static void UnregisterAtPath(const std::wstring& path, + RegistrationType registration_type); static void RegisterDefaults(); static FilePath GetReferenceChromeFrameDllPath(); @@ -47,6 +55,9 @@ class ScopedChromeFrameRegistrar { // Contains the path of the Chrome Frame DLL to be registered at destruction. std::wstring original_dll_path_; + + // Indicates whether per user or per machine registration is needed. + RegistrationType registration_type_; }; // Callback description for onload, onloaderror, onmessage |