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

Side by Side Diff: chrome/browser/page_cycler/page_cycler_browsertest.cc

Issue 11359217: Move scoped_temp_dir from base to base/files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 errors_file_ = temp_path.AppendASCII("errors"); 172 errors_file_ = temp_path.AppendASCII("errors");
173 stats_file_ = temp_path.AppendASCII("stats"); 173 stats_file_ = temp_path.AppendASCII("stats");
174 174
175 ASSERT_TRUE(file_util::PathExists(urls_file_)); 175 ASSERT_TRUE(file_util::PathExists(urls_file_));
176 ASSERT_FALSE(file_util::PathExists(errors_file_)); 176 ASSERT_FALSE(file_util::PathExists(errors_file_));
177 ASSERT_FALSE(file_util::PathExists(stats_file_)); 177 ASSERT_FALSE(file_util::PathExists(stats_file_));
178 } 178 }
179 179
180 private: 180 private:
181 // The directory storing the copy of the UserDataDir. 181 // The directory storing the copy of the UserDataDir.
182 ScopedTempDir user_data_dir_; 182 base::ScopedTempDir user_data_dir_;
183 }; 183 };
184 184
185 // Sanity check; iterate through a series of URLs and make sure there are no 185 // Sanity check; iterate through a series of URLs and make sure there are no
186 // errors. 186 // errors.
187 IN_PROC_BROWSER_TEST_F(PageCyclerBrowserTest, BasicTest) { 187 IN_PROC_BROWSER_TEST_F(PageCyclerBrowserTest, BasicTest) {
188 ScopedTempDir temp; 188 base::ScopedTempDir temp;
189 ASSERT_TRUE(temp.CreateUniqueTempDir()); 189 ASSERT_TRUE(temp.CreateUniqueTempDir());
190 190
191 RegisterForNotifications(); 191 RegisterForNotifications();
192 InitFilePaths(temp.path()); 192 InitFilePaths(temp.path());
193 193
194 ASSERT_TRUE(test_server()->Start()); 194 ASSERT_TRUE(test_server()->Start());
195 195
196 std::string urls_string = GetStringFromURLs(GetURLs());; 196 std::string urls_string = GetStringFromURLs(GetURLs());;
197 197
198 ASSERT_TRUE(file_util::WriteFile(urls_file(), urls_string.c_str(), 198 ASSERT_TRUE(file_util::WriteFile(urls_file(), urls_string.c_str(),
199 urls_string.size())); 199 urls_string.size()));
200 200
201 InitPageCycler(); 201 InitPageCycler();
202 page_cycler()->Run(); 202 page_cycler()->Run();
203 203
204 content::RunMessageLoop(); 204 content::RunMessageLoop();
205 ASSERT_FALSE(file_util::PathExists(errors_file())); 205 ASSERT_FALSE(file_util::PathExists(errors_file()));
206 ASSERT_TRUE(file_util::PathExists(stats_file())); 206 ASSERT_TRUE(file_util::PathExists(stats_file()));
207 } 207 }
208 208
209 // Test to make sure that PageCycler will recognize unvisitable URLs, and will 209 // Test to make sure that PageCycler will recognize unvisitable URLs, and will
210 // handle them appropriately. 210 // handle them appropriately.
211 IN_PROC_BROWSER_TEST_F(PageCyclerBrowserTest, UnvisitableURL) { 211 IN_PROC_BROWSER_TEST_F(PageCyclerBrowserTest, UnvisitableURL) {
212 const size_t kNumErrors = 1; 212 const size_t kNumErrors = 1;
213 const char kFakeURL[] = "http://www.pleasenoonehavethisurlanytimeinthenext" 213 const char kFakeURL[] = "http://www.pleasenoonehavethisurlanytimeinthenext"
214 "century.com/gibberish"; 214 "century.com/gibberish";
215 ScopedTempDir temp; 215 base::ScopedTempDir temp;
216 ASSERT_TRUE(temp.CreateUniqueTempDir()); 216 ASSERT_TRUE(temp.CreateUniqueTempDir());
217 217
218 RegisterForNotifications(); 218 RegisterForNotifications();
219 InitFilePaths(temp.path()); 219 InitFilePaths(temp.path());
220 220
221 ASSERT_TRUE(test_server()->Start()); 221 ASSERT_TRUE(test_server()->Start());
222 222
223 std::vector<GURL> urls = GetURLs(); 223 std::vector<GURL> urls = GetURLs();
224 urls.push_back(GURL(kFakeURL)); 224 urls.push_back(GURL(kFakeURL));
225 std::string urls_string = GetStringFromURLs(urls); 225 std::string urls_string = GetStringFromURLs(urls);
(...skipping 14 matching lines...) Expand all
240 240
241 // Check that each error message contains the fake URL (i.e., that it wasn't 241 // Check that each error message contains the fake URL (i.e., that it wasn't
242 // from a valid URL, and that the fake URL was caught each time). 242 // from a valid URL, and that the fake URL was caught each time).
243 ASSERT_NE(std::string::npos, errors[0].find(kFakeURL)); 243 ASSERT_NE(std::string::npos, errors[0].find(kFakeURL));
244 } 244 }
245 245
246 // Test that PageCycler will remove an invalid URL prior to running. 246 // Test that PageCycler will remove an invalid URL prior to running.
247 IN_PROC_BROWSER_TEST_F(PageCyclerBrowserTest, InvalidURL) { 247 IN_PROC_BROWSER_TEST_F(PageCyclerBrowserTest, InvalidURL) {
248 const char kBadURL[] = "notarealurl"; 248 const char kBadURL[] = "notarealurl";
249 249
250 ScopedTempDir temp; 250 base::ScopedTempDir temp;
251 ASSERT_TRUE(temp.CreateUniqueTempDir()); 251 ASSERT_TRUE(temp.CreateUniqueTempDir());
252 252
253 RegisterForNotifications(); 253 RegisterForNotifications();
254 InitFilePaths(temp.path()); 254 InitFilePaths(temp.path());
255 255
256 ASSERT_TRUE(test_server()->Start()); 256 ASSERT_TRUE(test_server()->Start());
257 257
258 std::string urls_string = GetStringFromURLs(GetURLs()); 258 std::string urls_string = GetStringFromURLs(GetURLs());
259 urls_string.append(kBadURL).append("\n"); 259 urls_string.append(kBadURL).append("\n");
260 260
(...skipping 11 matching lines...) Expand all
272 ASSERT_EQ(1u, errors.size()); 272 ASSERT_EQ(1u, errors.size());
273 273
274 std::string expected_error = "Omitting invalid URL: "; 274 std::string expected_error = "Omitting invalid URL: ";
275 expected_error.append(kBadURL).append("."); 275 expected_error.append(kBadURL).append(".");
276 276
277 ASSERT_FALSE(errors[0].compare(expected_error)); 277 ASSERT_FALSE(errors[0].compare(expected_error));
278 } 278 }
279 279
280 // Test that PageCycler will remove a Chrome Error URL prior to running. 280 // Test that PageCycler will remove a Chrome Error URL prior to running.
281 IN_PROC_BROWSER_TEST_F(PageCyclerBrowserTest, ChromeErrorURL) { 281 IN_PROC_BROWSER_TEST_F(PageCyclerBrowserTest, ChromeErrorURL) {
282 ScopedTempDir temp; 282 base::ScopedTempDir temp;
283 ASSERT_TRUE(temp.CreateUniqueTempDir()); 283 ASSERT_TRUE(temp.CreateUniqueTempDir());
284 284
285 RegisterForNotifications(); 285 RegisterForNotifications();
286 InitFilePaths(temp.path()); 286 InitFilePaths(temp.path());
287 287
288 ASSERT_TRUE(test_server()->Start()); 288 ASSERT_TRUE(test_server()->Start());
289 289
290 std::vector<GURL> urls = GetURLs(); 290 std::vector<GURL> urls = GetURLs();
291 urls.push_back(GURL(content::kUnreachableWebDataURL)); 291 urls.push_back(GURL(content::kUnreachableWebDataURL));
292 std::string urls_string = GetStringFromURLs(urls); 292 std::string urls_string = GetStringFromURLs(urls);
(...skipping 27 matching lines...) Expand all
320 #if defined(OS_LINUX) 320 #if defined(OS_LINUX)
321 // Bug 159026: Fails on Linux in both debug and release mode. 321 // Bug 159026: Fails on Linux in both debug and release mode.
322 #define MAYBE_PlaybackMode DISABLED_PlaybackMode 322 #define MAYBE_PlaybackMode DISABLED_PlaybackMode
323 #elif (defined(OS_WIN) || defined(OS_MACOSX) ) && !defined(NDEBUG) 323 #elif (defined(OS_WIN) || defined(OS_MACOSX) ) && !defined(NDEBUG)
324 // Bug 131333: This test fails on a XP debug bot since Build 17609. 324 // Bug 131333: This test fails on a XP debug bot since Build 17609.
325 #define MAYBE_PlaybackMode DISABLED_PlaybackMode 325 #define MAYBE_PlaybackMode DISABLED_PlaybackMode
326 #else 326 #else
327 #define MAYBE_PlaybackMode PlaybackMode 327 #define MAYBE_PlaybackMode PlaybackMode
328 #endif 328 #endif
329 IN_PROC_BROWSER_TEST_F(PageCyclerCachedBrowserTest, MAYBE_PlaybackMode) { 329 IN_PROC_BROWSER_TEST_F(PageCyclerCachedBrowserTest, MAYBE_PlaybackMode) {
330 ScopedTempDir temp; 330 base::ScopedTempDir temp;
331 ASSERT_TRUE(temp.CreateUniqueTempDir()); 331 ASSERT_TRUE(temp.CreateUniqueTempDir());
332 332
333 RegisterForNotifications(); 333 RegisterForNotifications();
334 InitFilePaths(temp.path()); 334 InitFilePaths(temp.path());
335 335
336 InitPageCycler(); 336 InitPageCycler();
337 337
338 page_cycler()->Run(); 338 page_cycler()->Run();
339 339
340 content::RunMessageLoop(); 340 content::RunMessageLoop();
(...skipping 10 matching lines...) Expand all
351 // cache directory while in playback mode. 351 // cache directory while in playback mode.
352 // Bug 131333: This test fails on a XP debug bot since Build 17609. 352 // Bug 131333: This test fails on a XP debug bot since Build 17609.
353 #if (defined(OS_WIN) || defined(OS_MACOSX)) && !defined(NDEBUG) 353 #if (defined(OS_WIN) || defined(OS_MACOSX)) && !defined(NDEBUG)
354 #define MAYBE_URLNotInCache DISABLED_URLNotInCache 354 #define MAYBE_URLNotInCache DISABLED_URLNotInCache
355 #else 355 #else
356 #define MAYBE_URLNotInCache URLNotInCache 356 #define MAYBE_URLNotInCache URLNotInCache
357 #endif 357 #endif
358 IN_PROC_BROWSER_TEST_F(PageCyclerCachedBrowserTest, MAYBE_URLNotInCache) { 358 IN_PROC_BROWSER_TEST_F(PageCyclerCachedBrowserTest, MAYBE_URLNotInCache) {
359 const char kCacheMissURL[] = "http://www.images.google.com/"; 359 const char kCacheMissURL[] = "http://www.images.google.com/";
360 360
361 ScopedTempDir temp; 361 base::ScopedTempDir temp;
362 ASSERT_TRUE(temp.CreateUniqueTempDir()); 362 ASSERT_TRUE(temp.CreateUniqueTempDir());
363 363
364 RegisterForNotifications(); 364 RegisterForNotifications();
365 InitFilePaths(temp.path()); 365 InitFilePaths(temp.path());
366 366
367 std::string urls_string; 367 std::string urls_string;
368 ASSERT_TRUE(file_util::ReadFileToString(urls_file(), 368 ASSERT_TRUE(file_util::ReadFileToString(urls_file(),
369 &urls_string)); 369 &urls_string));
370 370
371 urls_string.append("\n").append(kCacheMissURL); 371 urls_string.append("\n").append(kCacheMissURL);
(...skipping 14 matching lines...) Expand all
386 ASSERT_EQ(1u, errors.size()); 386 ASSERT_EQ(1u, errors.size());
387 387
388 std::string expected_error; 388 std::string expected_error;
389 expected_error.append("Failed to load the page at: ") 389 expected_error.append("Failed to load the page at: ")
390 .append(kCacheMissURL) 390 .append(kCacheMissURL)
391 .append(": The requested entry was not found in the cache."); 391 .append(": The requested entry was not found in the cache.");
392 392
393 ASSERT_FALSE(errors[0].compare(expected_error)); 393 ASSERT_FALSE(errors[0].compare(expected_error));
394 } 394 }
395 #endif // !defined(OS_CHROMEOS) 395 #endif // !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/net/transport_security_persister_unittest.cc ('k') | chrome/browser/page_cycler/page_cycler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698