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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 return false; | 94 return false; |
95 } | 95 } |
96 | 96 |
97 } // namespace | 97 } // namespace |
98 | 98 |
99 // Test that we are parsing Chrome version correctly. | 99 // Test that we are parsing Chrome version correctly. |
100 TEST_F(SetupUtilTestWithDir, GetMaxVersionFromArchiveDirTest) { | 100 TEST_F(SetupUtilTestWithDir, GetMaxVersionFromArchiveDirTest) { |
101 // Create a version dir | 101 // Create a version dir |
102 base::FilePath chrome_dir = test_dir_.path().AppendASCII("1.0.0.0"); | 102 base::FilePath chrome_dir = test_dir_.path().AppendASCII("1.0.0.0"); |
103 file_util::CreateDirectory(chrome_dir); | 103 base::CreateDirectory(chrome_dir); |
104 ASSERT_TRUE(base::PathExists(chrome_dir)); | 104 ASSERT_TRUE(base::PathExists(chrome_dir)); |
105 scoped_ptr<Version> version( | 105 scoped_ptr<Version> version( |
106 installer::GetMaxVersionFromArchiveDir(test_dir_.path())); | 106 installer::GetMaxVersionFromArchiveDir(test_dir_.path())); |
107 ASSERT_EQ(version->GetString(), "1.0.0.0"); | 107 ASSERT_EQ(version->GetString(), "1.0.0.0"); |
108 | 108 |
109 base::DeleteFile(chrome_dir, true); | 109 base::DeleteFile(chrome_dir, true); |
110 ASSERT_FALSE(base::PathExists(chrome_dir)); | 110 ASSERT_FALSE(base::PathExists(chrome_dir)); |
111 ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir_.path()) == NULL); | 111 ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir_.path()) == NULL); |
112 | 112 |
113 chrome_dir = test_dir_.path().AppendASCII("ABC"); | 113 chrome_dir = test_dir_.path().AppendASCII("ABC"); |
114 file_util::CreateDirectory(chrome_dir); | 114 base::CreateDirectory(chrome_dir); |
115 ASSERT_TRUE(base::PathExists(chrome_dir)); | 115 ASSERT_TRUE(base::PathExists(chrome_dir)); |
116 ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir_.path()) == NULL); | 116 ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir_.path()) == NULL); |
117 | 117 |
118 chrome_dir = test_dir_.path().AppendASCII("2.3.4.5"); | 118 chrome_dir = test_dir_.path().AppendASCII("2.3.4.5"); |
119 file_util::CreateDirectory(chrome_dir); | 119 base::CreateDirectory(chrome_dir); |
120 ASSERT_TRUE(base::PathExists(chrome_dir)); | 120 ASSERT_TRUE(base::PathExists(chrome_dir)); |
121 version.reset(installer::GetMaxVersionFromArchiveDir(test_dir_.path())); | 121 version.reset(installer::GetMaxVersionFromArchiveDir(test_dir_.path())); |
122 ASSERT_EQ(version->GetString(), "2.3.4.5"); | 122 ASSERT_EQ(version->GetString(), "2.3.4.5"); |
123 | 123 |
124 // Create multiple version dirs, ensure that we select the greatest. | 124 // Create multiple version dirs, ensure that we select the greatest. |
125 chrome_dir = test_dir_.path().AppendASCII("9.9.9.9"); | 125 chrome_dir = test_dir_.path().AppendASCII("9.9.9.9"); |
126 file_util::CreateDirectory(chrome_dir); | 126 base::CreateDirectory(chrome_dir); |
127 ASSERT_TRUE(base::PathExists(chrome_dir)); | 127 ASSERT_TRUE(base::PathExists(chrome_dir)); |
128 chrome_dir = test_dir_.path().AppendASCII("1.1.1.1"); | 128 chrome_dir = test_dir_.path().AppendASCII("1.1.1.1"); |
129 file_util::CreateDirectory(chrome_dir); | 129 base::CreateDirectory(chrome_dir); |
130 ASSERT_TRUE(base::PathExists(chrome_dir)); | 130 ASSERT_TRUE(base::PathExists(chrome_dir)); |
131 | 131 |
132 version.reset(installer::GetMaxVersionFromArchiveDir(test_dir_.path())); | 132 version.reset(installer::GetMaxVersionFromArchiveDir(test_dir_.path())); |
133 ASSERT_EQ(version->GetString(), "9.9.9.9"); | 133 ASSERT_EQ(version->GetString(), "9.9.9.9"); |
134 } | 134 } |
135 | 135 |
136 TEST_F(SetupUtilTestWithDir, DeleteFileFromTempProcess) { | 136 TEST_F(SetupUtilTestWithDir, DeleteFileFromTempProcess) { |
137 base::FilePath test_file; | 137 base::FilePath test_file; |
138 base::CreateTemporaryFileInDir(test_dir_.path(), &test_file); | 138 base::CreateTemporaryFileInDir(test_dir_.path(), &test_file); |
139 ASSERT_TRUE(base::PathExists(test_file)); | 139 ASSERT_TRUE(base::PathExists(test_file)); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // Prepare to update the product in the temp dir. | 299 // Prepare to update the product in the temp dir. |
300 installer_state_.reset(new installer::InstallerState( | 300 installer_state_.reset(new installer::InstallerState( |
301 kSystemInstall_ ? installer::InstallerState::SYSTEM_LEVEL : | 301 kSystemInstall_ ? installer::InstallerState::SYSTEM_LEVEL : |
302 installer::InstallerState::USER_LEVEL)); | 302 installer::InstallerState::USER_LEVEL)); |
303 installer_state_->AddProductFromState( | 303 installer_state_->AddProductFromState( |
304 kProductType_, | 304 kProductType_, |
305 *original_state_->GetProductState(kSystemInstall_, kProductType_)); | 305 *original_state_->GetProductState(kSystemInstall_, kProductType_)); |
306 | 306 |
307 // Create archives in the two version dirs. | 307 // Create archives in the two version dirs. |
308 ASSERT_TRUE( | 308 ASSERT_TRUE( |
309 file_util::CreateDirectory(GetProductVersionArchivePath().DirName())); | 309 base::CreateDirectory(GetProductVersionArchivePath().DirName())); |
310 ASSERT_EQ(1, file_util::WriteFile(GetProductVersionArchivePath(), "a", 1)); | 310 ASSERT_EQ(1, file_util::WriteFile(GetProductVersionArchivePath(), "a", 1)); |
311 ASSERT_TRUE( | 311 ASSERT_TRUE( |
312 file_util::CreateDirectory(GetMaxVersionArchivePath().DirName())); | 312 base::CreateDirectory(GetMaxVersionArchivePath().DirName())); |
313 ASSERT_EQ(1, file_util::WriteFile(GetMaxVersionArchivePath(), "b", 1)); | 313 ASSERT_EQ(1, file_util::WriteFile(GetMaxVersionArchivePath(), "b", 1)); |
314 } | 314 } |
315 | 315 |
316 virtual void TearDown() OVERRIDE { | 316 virtual void TearDown() OVERRIDE { |
317 original_state_.reset(); | 317 original_state_.reset(); |
318 SetupUtilTestWithDir::TearDown(); | 318 SetupUtilTestWithDir::TearDown(); |
319 } | 319 } |
320 | 320 |
321 base::FilePath GetArchivePath(const Version& version) const { | 321 base::FilePath GetArchivePath(const Version& version) const { |
322 return test_dir_.path() | 322 return test_dir_.path() |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 BrowserDistribution::CHROME_FRAME)); | 478 BrowserDistribution::CHROME_FRAME)); |
479 EXPECT_TRUE(chrome_frame.GetUsageStats(&usagestats)); | 479 EXPECT_TRUE(chrome_frame.GetUsageStats(&usagestats)); |
480 EXPECT_EQ(1U, usagestats); | 480 EXPECT_EQ(1U, usagestats); |
481 EXPECT_EQ(L"2.0-dev", chrome_frame.channel().value()); | 481 EXPECT_EQ(L"2.0-dev", chrome_frame.channel().value()); |
482 | 482 |
483 // Confirm that the binaries' channel no longer contains GCF. | 483 // Confirm that the binaries' channel no longer contains GCF. |
484 ASSERT_TRUE(binaries.Initialize(kSystemLevel, | 484 ASSERT_TRUE(binaries.Initialize(kSystemLevel, |
485 BrowserDistribution::CHROME_BINARIES)); | 485 BrowserDistribution::CHROME_BINARIES)); |
486 EXPECT_EQ(L"2.0-dev-multi", binaries.channel().value()); | 486 EXPECT_EQ(L"2.0-dev-multi", binaries.channel().value()); |
487 } | 487 } |
OLD | NEW |