OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 FilePath chrome_dll_3(chrome_dir_3); | 102 FilePath chrome_dll_3(chrome_dir_3); |
103 chrome_dll_3 = chrome_dll_3.AppendASCII("chrome.dll"); | 103 chrome_dll_3 = chrome_dll_3.AppendASCII("chrome.dll"); |
104 CreateTextFile(chrome_dll_3.value(), text_content_1); | 104 CreateTextFile(chrome_dll_3.value(), text_content_1); |
105 ASSERT_TRUE(file_util::PathExists(chrome_dll_3)); | 105 ASSERT_TRUE(file_util::PathExists(chrome_dll_3)); |
106 | 106 |
107 FilePath chrome_dll_4(chrome_dir_4); | 107 FilePath chrome_dll_4(chrome_dir_4); |
108 chrome_dll_4 = chrome_dll_4.AppendASCII("chrome.dll"); | 108 chrome_dll_4 = chrome_dll_4.AppendASCII("chrome.dll"); |
109 CreateTextFile(chrome_dll_4.value(), text_content_1); | 109 CreateTextFile(chrome_dll_4.value(), text_content_1); |
110 ASSERT_TRUE(file_util::PathExists(chrome_dll_4)); | 110 ASSERT_TRUE(file_util::PathExists(chrome_dll_4)); |
111 | 111 |
112 scoped_ptr<Version> latest_version(Version::GetVersionFromString(L"1.0.4.0")); | 112 scoped_ptr<Version> latest_version(Version::GetVersionFromString("1.0.4.0")); |
113 ChromePackageProperties properties; | 113 ChromePackageProperties properties; |
114 scoped_refptr<Package> package(new Package(true, chrome_dir, &properties)); | 114 scoped_refptr<Package> package(new Package(true, chrome_dir, &properties)); |
115 package->RemoveOldVersionDirectories(*latest_version.get()); | 115 package->RemoveOldVersionDirectories(*latest_version.get()); |
116 | 116 |
117 // old versions should be gone | 117 // old versions should be gone |
118 EXPECT_FALSE(file_util::PathExists(chrome_dir_1)); | 118 EXPECT_FALSE(file_util::PathExists(chrome_dir_1)); |
119 EXPECT_FALSE(file_util::PathExists(chrome_dir_2)); | 119 EXPECT_FALSE(file_util::PathExists(chrome_dir_2)); |
120 EXPECT_FALSE(file_util::PathExists(chrome_dir_3)); | 120 EXPECT_FALSE(file_util::PathExists(chrome_dir_3)); |
121 // the latest version should stay | 121 // the latest version should stay |
122 EXPECT_TRUE(file_util::PathExists(chrome_dll_4)); | 122 EXPECT_TRUE(file_util::PathExists(chrome_dll_4)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 FilePath chrome_dll_3(chrome_dir_3); | 177 FilePath chrome_dll_3(chrome_dir_3); |
178 chrome_dll_3 = chrome_dll_3.AppendASCII("chrome.dll"); | 178 chrome_dll_3 = chrome_dll_3.AppendASCII("chrome.dll"); |
179 CreateTextFile(chrome_dll_3.value(), text_content_1); | 179 CreateTextFile(chrome_dll_3.value(), text_content_1); |
180 ASSERT_TRUE(file_util::PathExists(chrome_dll_3)); | 180 ASSERT_TRUE(file_util::PathExists(chrome_dll_3)); |
181 | 181 |
182 FilePath chrome_dll_4(chrome_dir_4); | 182 FilePath chrome_dll_4(chrome_dir_4); |
183 chrome_dll_4 = chrome_dll_4.AppendASCII("chrome.dll"); | 183 chrome_dll_4 = chrome_dll_4.AppendASCII("chrome.dll"); |
184 CreateTextFile(chrome_dll_4.value(), text_content_1); | 184 CreateTextFile(chrome_dll_4.value(), text_content_1); |
185 ASSERT_TRUE(file_util::PathExists(chrome_dll_4)); | 185 ASSERT_TRUE(file_util::PathExists(chrome_dll_4)); |
186 | 186 |
187 scoped_ptr<Version> latest_version(Version::GetVersionFromString(L"1.0.4.0")); | 187 scoped_ptr<Version> latest_version(Version::GetVersionFromString("1.0.4.0")); |
188 ChromePackageProperties properties; | 188 ChromePackageProperties properties; |
189 scoped_refptr<Package> install_path(new Package(true, chrome_dir, | 189 scoped_refptr<Package> install_path(new Package(true, chrome_dir, |
190 &properties)); | 190 &properties)); |
191 install_path->RemoveOldVersionDirectories(*latest_version.get()); | 191 install_path->RemoveOldVersionDirectories(*latest_version.get()); |
192 | 192 |
193 // old versions not in used should be gone | 193 // old versions not in used should be gone |
194 EXPECT_FALSE(file_util::PathExists(chrome_dir_1)); | 194 EXPECT_FALSE(file_util::PathExists(chrome_dir_1)); |
195 EXPECT_FALSE(file_util::PathExists(chrome_dir_3)); | 195 EXPECT_FALSE(file_util::PathExists(chrome_dir_3)); |
196 // every thing under in used version should stay | 196 // every thing under in used version should stay |
197 EXPECT_TRUE(file_util::PathExists(chrome_dir_2)); | 197 EXPECT_TRUE(file_util::PathExists(chrome_dir_2)); |
198 EXPECT_TRUE(file_util::PathExists(chrome_dll_2)); | 198 EXPECT_TRUE(file_util::PathExists(chrome_dll_2)); |
199 EXPECT_TRUE(file_util::PathExists(chrome_othera_2)); | 199 EXPECT_TRUE(file_util::PathExists(chrome_othera_2)); |
200 EXPECT_TRUE(file_util::PathExists(chrome_otherb_2)); | 200 EXPECT_TRUE(file_util::PathExists(chrome_otherb_2)); |
201 // the latest version should stay | 201 // the latest version should stay |
202 EXPECT_TRUE(file_util::PathExists(chrome_dll_4)); | 202 EXPECT_TRUE(file_util::PathExists(chrome_dll_4)); |
203 } | 203 } |
OLD | NEW |