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 #include <iostream> | 8 #include <iostream> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 wchar_t text_content_1[] = L"delete me"; | 54 wchar_t text_content_1[] = L"delete me"; |
55 wchar_t text_content_2[] = L"delete me as well"; | 55 wchar_t text_content_2[] = L"delete me as well"; |
56 }; | 56 }; |
57 | 57 |
58 // Delete version directories. Everything lower than the given version | 58 // Delete version directories. Everything lower than the given version |
59 // should be deleted. | 59 // should be deleted. |
60 TEST_F(SetupHelperTest, Delete) { | 60 TEST_F(SetupHelperTest, Delete) { |
61 // Create a Chrome dir | 61 // Create a Chrome dir |
62 FilePath chrome_dir(test_dir_); | 62 FilePath chrome_dir(test_dir_); |
63 chrome_dir = chrome_dir.AppendASCII("chrome"); | 63 chrome_dir = chrome_dir.AppendASCII("chrome"); |
64 CreateDirectory(chrome_dir.value().c_str(), NULL); | 64 file_util::CreateDirectory(chrome_dir); |
65 ASSERT_TRUE(file_util::PathExists(chrome_dir)); | 65 ASSERT_TRUE(file_util::PathExists(chrome_dir)); |
66 | 66 |
67 FilePath chrome_dir_1(chrome_dir); | 67 FilePath chrome_dir_1(chrome_dir); |
68 chrome_dir_1 = chrome_dir_1.AppendASCII("1.0.1.0"); | 68 chrome_dir_1 = chrome_dir_1.AppendASCII("1.0.1.0"); |
69 CreateDirectory(chrome_dir_1.value().c_str(), NULL); | 69 file_util::CreateDirectory(chrome_dir_1); |
70 ASSERT_TRUE(file_util::PathExists(chrome_dir_1)); | 70 ASSERT_TRUE(file_util::PathExists(chrome_dir_1)); |
71 | 71 |
72 FilePath chrome_dir_2(chrome_dir); | 72 FilePath chrome_dir_2(chrome_dir); |
73 chrome_dir_2 = chrome_dir_2.AppendASCII("1.0.2.0"); | 73 chrome_dir_2 = chrome_dir_2.AppendASCII("1.0.2.0"); |
74 CreateDirectory(chrome_dir_2.value().c_str(), NULL); | 74 file_util::CreateDirectory(chrome_dir_2); |
75 ASSERT_TRUE(file_util::PathExists(chrome_dir_2)); | 75 ASSERT_TRUE(file_util::PathExists(chrome_dir_2)); |
76 | 76 |
77 FilePath chrome_dir_3(chrome_dir); | 77 FilePath chrome_dir_3(chrome_dir); |
78 chrome_dir_3 = chrome_dir_3.AppendASCII("1.0.3.0"); | 78 chrome_dir_3 = chrome_dir_3.AppendASCII("1.0.3.0"); |
79 CreateDirectory(chrome_dir_3.value().c_str(), NULL); | 79 file_util::CreateDirectory(chrome_dir_3); |
80 ASSERT_TRUE(file_util::PathExists(chrome_dir_3)); | 80 ASSERT_TRUE(file_util::PathExists(chrome_dir_3)); |
81 | 81 |
82 FilePath chrome_dir_4(chrome_dir); | 82 FilePath chrome_dir_4(chrome_dir); |
83 chrome_dir_4 = chrome_dir_4.AppendASCII("1.0.4.0"); | 83 chrome_dir_4 = chrome_dir_4.AppendASCII("1.0.4.0"); |
84 CreateDirectory(chrome_dir_4.value().c_str(), NULL); | 84 file_util::CreateDirectory(chrome_dir_4); |
85 ASSERT_TRUE(file_util::PathExists(chrome_dir_4)); | 85 ASSERT_TRUE(file_util::PathExists(chrome_dir_4)); |
86 | 86 |
87 FilePath chrome_dll_1(chrome_dir_1); | 87 FilePath chrome_dll_1(chrome_dir_1); |
88 chrome_dll_1 = chrome_dll_1.AppendASCII("chrome.dll"); | 88 chrome_dll_1 = chrome_dll_1.AppendASCII("chrome.dll"); |
89 CreateTextFile(chrome_dll_1.value(), text_content_1); | 89 CreateTextFile(chrome_dll_1.value(), text_content_1); |
90 ASSERT_TRUE(file_util::PathExists(chrome_dll_1)); | 90 ASSERT_TRUE(file_util::PathExists(chrome_dll_1)); |
91 | 91 |
92 FilePath chrome_dll_2(chrome_dir_2); | 92 FilePath chrome_dll_2(chrome_dir_2); |
93 chrome_dll_2 = chrome_dll_2.AppendASCII("chrome.dll"); | 93 chrome_dll_2 = chrome_dll_2.AppendASCII("chrome.dll"); |
94 CreateTextFile(chrome_dll_2.value(), text_content_1); | 94 CreateTextFile(chrome_dll_2.value(), text_content_1); |
(...skipping 18 matching lines...) Expand all Loading... |
113 EXPECT_FALSE(file_util::PathExists(chrome_dir_3)); | 113 EXPECT_FALSE(file_util::PathExists(chrome_dir_3)); |
114 // the latest version should stay | 114 // the latest version should stay |
115 EXPECT_TRUE(file_util::PathExists(chrome_dll_4)); | 115 EXPECT_TRUE(file_util::PathExists(chrome_dll_4)); |
116 } | 116 } |
117 | 117 |
118 // Delete older version directories, keeping the one in used intact. | 118 // Delete older version directories, keeping the one in used intact. |
119 TEST_F(SetupHelperTest, DeleteInUsed) { | 119 TEST_F(SetupHelperTest, DeleteInUsed) { |
120 // Create a Chrome dir | 120 // Create a Chrome dir |
121 FilePath chrome_dir(test_dir_); | 121 FilePath chrome_dir(test_dir_); |
122 chrome_dir = chrome_dir.AppendASCII("chrome"); | 122 chrome_dir = chrome_dir.AppendASCII("chrome"); |
123 CreateDirectory(chrome_dir.value().c_str(), NULL); | 123 file_util::CreateDirectory(chrome_dir); |
124 ASSERT_TRUE(file_util::PathExists(chrome_dir)); | 124 ASSERT_TRUE(file_util::PathExists(chrome_dir)); |
125 | 125 |
126 FilePath chrome_dir_1(chrome_dir); | 126 FilePath chrome_dir_1(chrome_dir); |
127 chrome_dir_1 = chrome_dir_1.AppendASCII("1.0.1.0"); | 127 chrome_dir_1 = chrome_dir_1.AppendASCII("1.0.1.0"); |
128 CreateDirectory(chrome_dir_1.value().c_str(), NULL); | 128 file_util::CreateDirectory(chrome_dir_1); |
129 ASSERT_TRUE(file_util::PathExists(chrome_dir_1)); | 129 ASSERT_TRUE(file_util::PathExists(chrome_dir_1)); |
130 | 130 |
131 FilePath chrome_dir_2(chrome_dir); | 131 FilePath chrome_dir_2(chrome_dir); |
132 chrome_dir_2 = chrome_dir_2.AppendASCII("1.0.2.0"); | 132 chrome_dir_2 = chrome_dir_2.AppendASCII("1.0.2.0"); |
133 CreateDirectory(chrome_dir_2.value().c_str(), NULL); | 133 file_util::CreateDirectory(chrome_dir_2); |
134 ASSERT_TRUE(file_util::PathExists(chrome_dir_2)); | 134 ASSERT_TRUE(file_util::PathExists(chrome_dir_2)); |
135 | 135 |
136 FilePath chrome_dir_3(chrome_dir); | 136 FilePath chrome_dir_3(chrome_dir); |
137 chrome_dir_3 = chrome_dir_3.AppendASCII("1.0.3.0"); | 137 chrome_dir_3 = chrome_dir_3.AppendASCII("1.0.3.0"); |
138 CreateDirectory(chrome_dir_3.value().c_str(), NULL); | 138 file_util::CreateDirectory(chrome_dir_3); |
139 ASSERT_TRUE(file_util::PathExists(chrome_dir_3)); | 139 ASSERT_TRUE(file_util::PathExists(chrome_dir_3)); |
140 | 140 |
141 FilePath chrome_dir_4(chrome_dir); | 141 FilePath chrome_dir_4(chrome_dir); |
142 chrome_dir_4 = chrome_dir_4.AppendASCII("1.0.4.0"); | 142 chrome_dir_4 = chrome_dir_4.AppendASCII("1.0.4.0"); |
143 CreateDirectory(chrome_dir_4.value().c_str(), NULL); | 143 file_util::CreateDirectory(chrome_dir_4); |
144 ASSERT_TRUE(file_util::PathExists(chrome_dir_4)); | 144 ASSERT_TRUE(file_util::PathExists(chrome_dir_4)); |
145 | 145 |
146 FilePath chrome_dll_1(chrome_dir_1); | 146 FilePath chrome_dll_1(chrome_dir_1); |
147 chrome_dll_1 = chrome_dll_1.AppendASCII("chrome.dll"); | 147 chrome_dll_1 = chrome_dll_1.AppendASCII("chrome.dll"); |
148 CreateTextFile(chrome_dll_1.value(), text_content_1); | 148 CreateTextFile(chrome_dll_1.value(), text_content_1); |
149 ASSERT_TRUE(file_util::PathExists(chrome_dll_1)); | 149 ASSERT_TRUE(file_util::PathExists(chrome_dll_1)); |
150 | 150 |
151 FilePath chrome_dll_2(chrome_dir_2); | 151 FilePath chrome_dll_2(chrome_dir_2); |
152 chrome_dll_2 = chrome_dll_2.AppendASCII("chrome.dll"); | 152 chrome_dll_2 = chrome_dll_2.AppendASCII("chrome.dll"); |
153 CreateTextFile(chrome_dll_2.value(), text_content_1); | 153 CreateTextFile(chrome_dll_2.value(), text_content_1); |
(...skipping 30 matching lines...) Expand all Loading... |
184 EXPECT_FALSE(file_util::PathExists(chrome_dir_1)); | 184 EXPECT_FALSE(file_util::PathExists(chrome_dir_1)); |
185 EXPECT_FALSE(file_util::PathExists(chrome_dir_3)); | 185 EXPECT_FALSE(file_util::PathExists(chrome_dir_3)); |
186 // every thing under in used version should stay | 186 // every thing under in used version should stay |
187 EXPECT_TRUE(file_util::PathExists(chrome_dir_2)); | 187 EXPECT_TRUE(file_util::PathExists(chrome_dir_2)); |
188 EXPECT_TRUE(file_util::PathExists(chrome_dll_2)); | 188 EXPECT_TRUE(file_util::PathExists(chrome_dll_2)); |
189 EXPECT_TRUE(file_util::PathExists(chrome_othera_2)); | 189 EXPECT_TRUE(file_util::PathExists(chrome_othera_2)); |
190 EXPECT_TRUE(file_util::PathExists(chrome_otherb_2)); | 190 EXPECT_TRUE(file_util::PathExists(chrome_otherb_2)); |
191 // the latest version should stay | 191 // the latest version should stay |
192 EXPECT_TRUE(file_util::PathExists(chrome_dll_4)); | 192 EXPECT_TRUE(file_util::PathExists(chrome_dll_4)); |
193 } | 193 } |
OLD | NEW |