diff options
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/dll_redirector.cc | 15 | ||||
-rw-r--r-- | chrome_frame/test/dll_redirector_loading_test.cc | 18 | ||||
-rw-r--r-- | chrome_frame/test/dll_redirector_test.cc | 25 | ||||
-rw-r--r-- | chrome_frame/test/test_with_web_server.cc | 12 |
4 files changed, 38 insertions, 32 deletions
diff --git a/chrome_frame/dll_redirector.cc b/chrome_frame/dll_redirector.cc index 0ca1546..2bba924 100644 --- a/chrome_frame/dll_redirector.cc +++ b/chrome_frame/dll_redirector.cc @@ -187,9 +187,10 @@ bool DllRedirector::RegisterAsFirstCFModule() { } else { char buffer[kSharedMemorySize] = {0}; memcpy(buffer, shared_memory_->memory(), kSharedMemorySize - 1); - dll_version_.reset(Version::GetVersionFromString(buffer)); + dll_version_.reset(new Version(buffer)); - if (!dll_version_.get() || dll_version_->Equals(*our_version.get())) { + if (!dll_version_->IsValid() || + dll_version_->Equals(*our_version.get())) { // If we either couldn't parse a valid version out of the shared // memory or we did parse a version and it is the same as our own, // then pretend we're first in to avoid trying to load any other DLLs. @@ -242,14 +243,14 @@ Version* DllRedirector::GetCurrentModuleVersion() { FileVersionInfo::CreateFileVersionInfoForCurrentModule()); DCHECK(file_version_info.get()); - Version* current_version = NULL; + scoped_ptr<Version> current_version; if (file_version_info.get()) { - current_version = Version::GetVersionFromString( - WideToASCII(file_version_info->file_version())); - DCHECK(current_version); + current_version.reset( + new Version(WideToASCII(file_version_info->file_version()))); + DCHECK(current_version->IsValid()); } - return current_version; + return current_version.release(); } HMODULE DllRedirector::GetFirstModule() { diff --git a/chrome_frame/test/dll_redirector_loading_test.cc b/chrome_frame/test/dll_redirector_loading_test.cc index bba490f..9c46425 100644 --- a/chrome_frame/test/dll_redirector_loading_test.cc +++ b/chrome_frame/test/dll_redirector_loading_test.cc @@ -45,9 +45,9 @@ class DllRedirectorLoadingTest : public testing::Test { scoped_ptr<FileVersionInfo> original_version_info( FileVersionInfo::CreateFileVersionInfo(build_chrome_frame_dll)); ASSERT_TRUE(original_version_info != NULL); - original_version_.reset(Version::GetVersionFromString( - WideToASCII(original_version_info->file_version()))); - ASSERT_TRUE(original_version_ != NULL); + original_version_.reset( + new Version(WideToASCII(original_version_info->file_version()))); + ASSERT_TRUE(original_version_->IsValid()); // Make a place for us to run the test from. ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); @@ -80,9 +80,9 @@ class DllRedirectorLoadingTest : public testing::Test { scoped_ptr<FileVersionInfo> new_version_info( FileVersionInfo::CreateFileVersionInfo(temporary_new_chrome_frame_dll)); ASSERT_TRUE(new_version_info != NULL); - new_version_.reset(Version::GetVersionFromString( - WideToASCII(new_version_info->file_version()))); - ASSERT_TRUE(new_version_ != NULL); + new_version_.reset( + new Version(WideToASCII(new_version_info->file_version()))); + ASSERT_TRUE(new_version_->IsValid()); // Make sure the new version is larger than the old. ASSERT_EQ(new_version_->CompareTo(*original_version_.get()), 1); @@ -208,10 +208,10 @@ TEST_F(DllRedirectorLoadingTest, MAYBE_TestDllRedirection) { char buffer[kSharedMemoryBytes] = {0}; memcpy(buffer, beacon.memory(), kSharedMemoryBytes - 1); - scoped_ptr<Version> beacon_version(Version::GetVersionFromString(buffer)); - ASSERT_TRUE(beacon_version != NULL); + Version beacon_version(buffer); + ASSERT_TRUE(beacon_version.IsValid()); EXPECT_EQ(0, - beacon_version->CompareTo(*test_data[i].expected_beacon_version)); + beacon_version.CompareTo(*test_data[i].expected_beacon_version)); } } diff --git a/chrome_frame/test/dll_redirector_test.cc b/chrome_frame/test/dll_redirector_test.cc index 210c904..3edd6bd 100644 --- a/chrome_frame/test/dll_redirector_test.cc +++ b/chrome_frame/test/dll_redirector_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -37,7 +37,7 @@ class MockDllRedirector : public DllRedirector { } virtual Version* GetCurrentModuleVersion() { - return Version::GetVersionFromString(kMockVersionString); + return new Version(kMockVersionString); } virtual HMODULE GetFirstModule() { @@ -46,7 +46,7 @@ class MockDllRedirector : public DllRedirector { Version* GetFirstModuleVersion() { // Lazy man's copy. - return Version::GetVersionFromString(dll_version_->GetString()); + return new Version(dll_version_->GetString()); } base::SharedMemory* shared_memory() { @@ -64,7 +64,7 @@ class MockDllRedirector2 : public MockDllRedirector { } virtual Version* GetCurrentModuleVersion() { - return Version::GetVersionFromString(kMockVersionString2); + return new Version(kMockVersionString2); } }; @@ -87,8 +87,8 @@ class DllRedirectorTest : public testing::Test { public: virtual void SetUp() { shared_memory_.reset(new base::SharedMemory); - mock_version_.reset(Version::GetVersionFromString(kMockVersionString)); - mock_version2_.reset(Version::GetVersionFromString(kMockVersionString2)); + mock_version_.reset(new Version(kMockVersionString)); + mock_version2_.reset(new Version(kMockVersionString2)); } virtual void TearDown() { @@ -119,7 +119,10 @@ class DllRedirectorTest : public testing::Test { char buffer[kSharedMemorySize] = {0}; memcpy(buffer, shared_memory_->memory(), kSharedMemorySize - 1); - return Version::GetVersionFromString(buffer); + scoped_ptr<Version> version(new Version(buffer)); + if (!version->IsValid()) + version.reset(); + return version.release(); } void CloseBeacon() { @@ -140,15 +143,15 @@ TEST_F(DllRedirectorTest, RegisterAsFirstModule) { base::SharedMemory* redirector_memory = redirector->shared_memory(); char buffer[kSharedMemorySize] = {0}; memcpy(buffer, redirector_memory->memory(), kSharedMemorySize - 1); - scoped_ptr<Version> redirector_version(Version::GetVersionFromString(buffer)); - ASSERT_TRUE(redirector_version.get()); - EXPECT_TRUE(redirector_version->Equals(*mock_version_.get())); + Version redirector_version(buffer); + ASSERT_TRUE(redirector_version.IsValid()); + EXPECT_TRUE(redirector_version.Equals(*mock_version_.get())); redirector_memory = NULL; scoped_ptr<Version> memory_version( OpenAndReadVersionFromBeacon(kTestVersionBeaconName)); ASSERT_TRUE(memory_version.get()); - EXPECT_TRUE(redirector_version->Equals(*memory_version.get())); + EXPECT_TRUE(redirector_version.Equals(*memory_version.get())); CloseBeacon(); redirector.reset(); diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc index c56b60c..065dd42 100644 --- a/chrome_frame/test/test_with_web_server.cc +++ b/chrome_frame/test/test_with_web_server.cc @@ -292,14 +292,16 @@ void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, // the directory where chrome is installed. if (!version_info) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - scoped_ptr<Version> ver_system(InstallUtil::GetChromeVersion(dist, true)); - scoped_ptr<Version> ver_user(InstallUtil::GetChromeVersion(dist, false)); - ASSERT_TRUE(ver_system.get() || ver_user.get()); + Version ver_system; + InstallUtil::GetChromeVersion(dist, true, &ver_system); + Version ver_user; + InstallUtil::GetChromeVersion(dist, false, &ver_system); + ASSERT_TRUE(ver_system.IsValid() || ver_user.IsValid()); - bool system_install = ver_system != NULL; + bool system_install = ver_system.IsValid(); FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist)); cf_dll_path = cf_dll_path.Append(UTF8ToWide( - ver_system.get() ? ver_system->GetString() : ver_user->GetString())); + ver_system.IsValid() ? ver_system.GetString() : ver_user.GetString())); cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); if (version_info) |