Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/installer/setup/setup_util_unittest.cc

Issue 2321573002: //chrome misc: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix Win compilation Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <shlobj.h> 8 #include <shlobj.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return false; 86 return false;
87 } 87 }
88 88
89 } // namespace 89 } // namespace
90 90
91 // Test that we are parsing Chrome version correctly. 91 // Test that we are parsing Chrome version correctly.
92 TEST(SetupUtilTest, GetMaxVersionFromArchiveDirTest) { 92 TEST(SetupUtilTest, GetMaxVersionFromArchiveDirTest) {
93 // Create a version dir 93 // Create a version dir
94 base::ScopedTempDir test_dir; 94 base::ScopedTempDir test_dir;
95 ASSERT_TRUE(test_dir.CreateUniqueTempDir()); 95 ASSERT_TRUE(test_dir.CreateUniqueTempDir());
96 base::FilePath chrome_dir = test_dir.path().AppendASCII("1.0.0.0"); 96 base::FilePath chrome_dir = test_dir.GetPath().AppendASCII("1.0.0.0");
97 base::CreateDirectory(chrome_dir); 97 base::CreateDirectory(chrome_dir);
98 ASSERT_TRUE(base::PathExists(chrome_dir)); 98 ASSERT_TRUE(base::PathExists(chrome_dir));
99 std::unique_ptr<base::Version> version( 99 std::unique_ptr<base::Version> version(
100 installer::GetMaxVersionFromArchiveDir(test_dir.path())); 100 installer::GetMaxVersionFromArchiveDir(test_dir.GetPath()));
101 ASSERT_EQ(version->GetString(), "1.0.0.0"); 101 ASSERT_EQ(version->GetString(), "1.0.0.0");
102 102
103 base::DeleteFile(chrome_dir, true); 103 base::DeleteFile(chrome_dir, true);
104 ASSERT_FALSE(base::PathExists(chrome_dir)) << chrome_dir.value(); 104 ASSERT_FALSE(base::PathExists(chrome_dir)) << chrome_dir.value();
105 ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir.path()) == NULL); 105 ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir.GetPath()) ==
106 NULL);
106 107
107 chrome_dir = test_dir.path().AppendASCII("ABC"); 108 chrome_dir = test_dir.GetPath().AppendASCII("ABC");
108 base::CreateDirectory(chrome_dir); 109 base::CreateDirectory(chrome_dir);
109 ASSERT_TRUE(base::PathExists(chrome_dir)); 110 ASSERT_TRUE(base::PathExists(chrome_dir));
110 ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir.path()) == NULL); 111 ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir.GetPath()) ==
112 NULL);
111 113
112 chrome_dir = test_dir.path().AppendASCII("2.3.4.5"); 114 chrome_dir = test_dir.GetPath().AppendASCII("2.3.4.5");
113 base::CreateDirectory(chrome_dir); 115 base::CreateDirectory(chrome_dir);
114 ASSERT_TRUE(base::PathExists(chrome_dir)); 116 ASSERT_TRUE(base::PathExists(chrome_dir));
115 version.reset(installer::GetMaxVersionFromArchiveDir(test_dir.path())); 117 version.reset(installer::GetMaxVersionFromArchiveDir(test_dir.GetPath()));
116 ASSERT_EQ(version->GetString(), "2.3.4.5"); 118 ASSERT_EQ(version->GetString(), "2.3.4.5");
117 119
118 // Create multiple version dirs, ensure that we select the greatest. 120 // Create multiple version dirs, ensure that we select the greatest.
119 chrome_dir = test_dir.path().AppendASCII("9.9.9.9"); 121 chrome_dir = test_dir.GetPath().AppendASCII("9.9.9.9");
120 base::CreateDirectory(chrome_dir); 122 base::CreateDirectory(chrome_dir);
121 ASSERT_TRUE(base::PathExists(chrome_dir)); 123 ASSERT_TRUE(base::PathExists(chrome_dir));
122 chrome_dir = test_dir.path().AppendASCII("1.1.1.1"); 124 chrome_dir = test_dir.GetPath().AppendASCII("1.1.1.1");
123 base::CreateDirectory(chrome_dir); 125 base::CreateDirectory(chrome_dir);
124 ASSERT_TRUE(base::PathExists(chrome_dir)); 126 ASSERT_TRUE(base::PathExists(chrome_dir));
125 127
126 version.reset(installer::GetMaxVersionFromArchiveDir(test_dir.path())); 128 version.reset(installer::GetMaxVersionFromArchiveDir(test_dir.GetPath()));
127 ASSERT_EQ(version->GetString(), "9.9.9.9"); 129 ASSERT_EQ(version->GetString(), "9.9.9.9");
128 } 130 }
129 131
130 TEST(SetupUtilTest, DeleteFileFromTempProcess) { 132 TEST(SetupUtilTest, DeleteFileFromTempProcess) {
131 base::ScopedTempDir test_dir; 133 base::ScopedTempDir test_dir;
132 ASSERT_TRUE(test_dir.CreateUniqueTempDir()); 134 ASSERT_TRUE(test_dir.CreateUniqueTempDir());
133 base::FilePath test_file; 135 base::FilePath test_file;
134 base::CreateTemporaryFileInDir(test_dir.path(), &test_file); 136 base::CreateTemporaryFileInDir(test_dir.GetPath(), &test_file);
135 ASSERT_TRUE(base::PathExists(test_file)); 137 ASSERT_TRUE(base::PathExists(test_file));
136 base::WriteFile(test_file, "foo", 3); 138 base::WriteFile(test_file, "foo", 3);
137 EXPECT_TRUE(installer::DeleteFileFromTempProcess(test_file, 0)); 139 EXPECT_TRUE(installer::DeleteFileFromTempProcess(test_file, 0));
138 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 3); 140 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 3);
139 EXPECT_FALSE(base::PathExists(test_file)) << test_file.value(); 141 EXPECT_FALSE(base::PathExists(test_file)) << test_file.value();
140 } 142 }
141 143
142 // Note: This test is only valid when run at high integrity (i.e. it will fail 144 // Note: This test is only valid when run at high integrity (i.e. it will fail
143 // at medium integrity). 145 // at medium integrity).
144 TEST(SetupUtilTest, ScopedTokenPrivilegeBasic) { 146 TEST(SetupUtilTest, ScopedTokenPrivilegeBasic) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ASSERT_TRUE( 330 ASSERT_TRUE(
329 base::CreateDirectory(GetMaxVersionArchivePath().DirName())); 331 base::CreateDirectory(GetMaxVersionArchivePath().DirName()));
330 ASSERT_EQ(1, base::WriteFile(GetMaxVersionArchivePath(), "b", 1)); 332 ASSERT_EQ(1, base::WriteFile(GetMaxVersionArchivePath(), "b", 1));
331 } 333 }
332 334
333 void TearDown() override { 335 void TearDown() override {
334 original_state_.reset(); 336 original_state_.reset();
335 } 337 }
336 338
337 base::FilePath GetArchivePath(const base::Version& version) const { 339 base::FilePath GetArchivePath(const base::Version& version) const {
338 return test_dir_.path() 340 return test_dir_.GetPath()
339 .AppendASCII(version.GetString()) 341 .AppendASCII(version.GetString())
340 .Append(installer::kInstallerDir) 342 .Append(installer::kInstallerDir)
341 .Append(installer::kChromeArchive); 343 .Append(installer::kChromeArchive);
342 } 344 }
343 345
344 base::FilePath GetMaxVersionArchivePath() const { 346 base::FilePath GetMaxVersionArchivePath() const {
345 return GetArchivePath(max_version_); 347 return GetArchivePath(max_version_);
346 } 348 }
347 349
348 base::FilePath GetProductVersionArchivePath() const { 350 base::FilePath GetProductVersionArchivePath() const {
349 return GetArchivePath(product_version_); 351 return GetArchivePath(product_version_);
350 } 352 }
351 353
352 void InstallProduct() { 354 void InstallProduct() {
353 FakeProductState* product = FakeProductState::FromProductState( 355 FakeProductState* product = FakeProductState::FromProductState(
354 original_state_->GetNonVersionedProductState(kSystemInstall_, 356 original_state_->GetNonVersionedProductState(kSystemInstall_,
355 kProductType_)); 357 kProductType_));
356 358
357 product->set_version(product_version_); 359 product->set_version(product_version_);
358 base::CommandLine uninstall_command( 360 base::CommandLine uninstall_command(
359 test_dir_.path() 361 test_dir_.GetPath()
360 .AppendASCII(product_version_.GetString()) 362 .AppendASCII(product_version_.GetString())
361 .Append(installer::kInstallerDir) 363 .Append(installer::kInstallerDir)
362 .Append(installer::kSetupExe)); 364 .Append(installer::kSetupExe));
363 uninstall_command.AppendSwitch(installer::switches::kUninstall); 365 uninstall_command.AppendSwitch(installer::switches::kUninstall);
364 product->set_uninstall_command(uninstall_command); 366 product->set_uninstall_command(uninstall_command);
365 } 367 }
366 368
367 void UninstallProduct() { 369 void UninstallProduct() {
368 FakeProductState::FromProductState( 370 FakeProductState::FromProductState(
369 original_state_->GetNonVersionedProductState(kSystemInstall_, 371 original_state_->GetNonVersionedProductState(kSystemInstall_,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 } 645 }
644 646
645 // Ensure that all values are absent. 647 // Ensure that all values are absent.
646 { 648 {
647 base::win::RegistryValueIterator it(root_, path_.c_str()); 649 base::win::RegistryValueIterator it(root_, path_.c_str());
648 ASSERT_EQ(0u, it.ValueCount()); 650 ASSERT_EQ(0u, it.ValueCount());
649 } 651 }
650 } 652 }
651 653
652 } // namespace installer 654 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/setup/install_unittest.cc ('k') | chrome/installer/util/conditional_work_item_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698