| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/installer/setup/setup_util_unittest.h" | 5 #include "chrome/installer/setup/setup_util_unittest.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/installer/util/google_update_constants.h" | 26 #include "chrome/installer/util/google_update_constants.h" |
| 27 #include "chrome/installer/util/installation_state.h" | 27 #include "chrome/installer/util/installation_state.h" |
| 28 #include "chrome/installer/util/installer_state.h" | 28 #include "chrome/installer/util/installer_state.h" |
| 29 #include "chrome/installer/util/util_constants.h" | 29 #include "chrome/installer/util/util_constants.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 class SetupUtilTestWithDir : public testing::Test { | 34 class SetupUtilTestWithDir : public testing::Test { |
| 35 protected: | 35 protected: |
| 36 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() override { |
| 37 // Create a temp directory for testing. | 37 // Create a temp directory for testing. |
| 38 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); | 38 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual void TearDown() OVERRIDE { | 41 virtual void TearDown() override { |
| 42 // Clean up test directory manually so we can fail if it leaks. | 42 // Clean up test directory manually so we can fail if it leaks. |
| 43 ASSERT_TRUE(test_dir_.Delete()); | 43 ASSERT_TRUE(test_dir_.Delete()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // The temporary directory used to contain the test operations. | 46 // The temporary directory used to contain the test operations. |
| 47 base::ScopedTempDir test_dir_; | 47 base::ScopedTempDir test_dir_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // The privilege tested in ScopeTokenPrivilege tests below. | 50 // The privilege tested in ScopeTokenPrivilege tests below. |
| 51 // Use SE_RESTORE_NAME as it is one of the many privileges that is available, | 51 // Use SE_RESTORE_NAME as it is one of the many privileges that is available, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 version_.reset(new Version(version)); | 282 version_.reset(new Version(version)); |
| 283 else | 283 else |
| 284 version_.reset(); | 284 version_.reset(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void set_uninstall_command(const CommandLine& uninstall_command) { | 287 void set_uninstall_command(const CommandLine& uninstall_command) { |
| 288 uninstall_command_ = uninstall_command; | 288 uninstall_command_ = uninstall_command; |
| 289 } | 289 } |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 virtual void SetUp() OVERRIDE { | 292 virtual void SetUp() override { |
| 293 SetupUtilTestWithDir::SetUp(); | 293 SetupUtilTestWithDir::SetUp(); |
| 294 product_version_ = Version("30.0.1559.0"); | 294 product_version_ = Version("30.0.1559.0"); |
| 295 max_version_ = Version("47.0.1559.0"); | 295 max_version_ = Version("47.0.1559.0"); |
| 296 | 296 |
| 297 // Install the product according to the version. | 297 // Install the product according to the version. |
| 298 original_state_.reset(new FakeInstallationState()); | 298 original_state_.reset(new FakeInstallationState()); |
| 299 InstallProduct(); | 299 InstallProduct(); |
| 300 | 300 |
| 301 // Prepare to update the product in the temp dir. | 301 // Prepare to update the product in the temp dir. |
| 302 installer_state_.reset(new installer::InstallerState( | 302 installer_state_.reset(new installer::InstallerState( |
| 303 kSystemInstall_ ? installer::InstallerState::SYSTEM_LEVEL : | 303 kSystemInstall_ ? installer::InstallerState::SYSTEM_LEVEL : |
| 304 installer::InstallerState::USER_LEVEL)); | 304 installer::InstallerState::USER_LEVEL)); |
| 305 installer_state_->AddProductFromState( | 305 installer_state_->AddProductFromState( |
| 306 kProductType_, | 306 kProductType_, |
| 307 *original_state_->GetProductState(kSystemInstall_, kProductType_)); | 307 *original_state_->GetProductState(kSystemInstall_, kProductType_)); |
| 308 | 308 |
| 309 // Create archives in the two version dirs. | 309 // Create archives in the two version dirs. |
| 310 ASSERT_TRUE( | 310 ASSERT_TRUE( |
| 311 base::CreateDirectory(GetProductVersionArchivePath().DirName())); | 311 base::CreateDirectory(GetProductVersionArchivePath().DirName())); |
| 312 ASSERT_EQ(1, base::WriteFile(GetProductVersionArchivePath(), "a", 1)); | 312 ASSERT_EQ(1, base::WriteFile(GetProductVersionArchivePath(), "a", 1)); |
| 313 ASSERT_TRUE( | 313 ASSERT_TRUE( |
| 314 base::CreateDirectory(GetMaxVersionArchivePath().DirName())); | 314 base::CreateDirectory(GetMaxVersionArchivePath().DirName())); |
| 315 ASSERT_EQ(1, base::WriteFile(GetMaxVersionArchivePath(), "b", 1)); | 315 ASSERT_EQ(1, base::WriteFile(GetMaxVersionArchivePath(), "b", 1)); |
| 316 } | 316 } |
| 317 | 317 |
| 318 virtual void TearDown() OVERRIDE { | 318 virtual void TearDown() override { |
| 319 original_state_.reset(); | 319 original_state_.reset(); |
| 320 SetupUtilTestWithDir::TearDown(); | 320 SetupUtilTestWithDir::TearDown(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 base::FilePath GetArchivePath(const Version& version) const { | 323 base::FilePath GetArchivePath(const Version& version) const { |
| 324 return test_dir_.path() | 324 return test_dir_.path() |
| 325 .AppendASCII(version.GetString()) | 325 .AppendASCII(version.GetString()) |
| 326 .Append(installer::kInstallerDir) | 326 .Append(installer::kInstallerDir) |
| 327 .Append(installer::kChromeArchive); | 327 .Append(installer::kChromeArchive); |
| 328 } | 328 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 402 |
| 403 base::FilePath patch_source(installer::FindArchiveToPatch( | 403 base::FilePath patch_source(installer::FindArchiveToPatch( |
| 404 *original_state_, *installer_state_)); | 404 *original_state_, *installer_state_)); |
| 405 EXPECT_EQ(base::FilePath::StringType(), patch_source.value()); | 405 EXPECT_EQ(base::FilePath::StringType(), patch_source.value()); |
| 406 } | 406 } |
| 407 | 407 |
| 408 namespace { | 408 namespace { |
| 409 | 409 |
| 410 class MigrateMultiToSingleTest : public testing::Test { | 410 class MigrateMultiToSingleTest : public testing::Test { |
| 411 protected: | 411 protected: |
| 412 virtual void SetUp() OVERRIDE { | 412 virtual void SetUp() override { |
| 413 registry_override_manager_.OverrideRegistry(kRootKey); | 413 registry_override_manager_.OverrideRegistry(kRootKey); |
| 414 } | 414 } |
| 415 | 415 |
| 416 static const bool kSystemLevel = false; | 416 static const bool kSystemLevel = false; |
| 417 static const HKEY kRootKey; | 417 static const HKEY kRootKey; |
| 418 static const wchar_t kVersionString[]; | 418 static const wchar_t kVersionString[]; |
| 419 static const wchar_t kMultiChannel[]; | 419 static const wchar_t kMultiChannel[]; |
| 420 registry_util::RegistryOverrideManager registry_override_manager_; | 420 registry_util::RegistryOverrideManager registry_override_manager_; |
| 421 }; | 421 }; |
| 422 | 422 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 488 } |
| 489 | 489 |
| 490 TEST(SetupUtilTest, ContainsUnsupportedSwitch) { | 490 TEST(SetupUtilTest, ContainsUnsupportedSwitch) { |
| 491 EXPECT_FALSE(installer::ContainsUnsupportedSwitch( | 491 EXPECT_FALSE(installer::ContainsUnsupportedSwitch( |
| 492 CommandLine::FromString(L"foo.exe"))); | 492 CommandLine::FromString(L"foo.exe"))); |
| 493 EXPECT_FALSE(installer::ContainsUnsupportedSwitch( | 493 EXPECT_FALSE(installer::ContainsUnsupportedSwitch( |
| 494 CommandLine::FromString(L"foo.exe --multi-install --chrome"))); | 494 CommandLine::FromString(L"foo.exe --multi-install --chrome"))); |
| 495 EXPECT_TRUE(installer::ContainsUnsupportedSwitch( | 495 EXPECT_TRUE(installer::ContainsUnsupportedSwitch( |
| 496 CommandLine::FromString(L"foo.exe --chrome-frame"))); | 496 CommandLine::FromString(L"foo.exe --chrome-frame"))); |
| 497 } | 497 } |
| OLD | NEW |