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

Side by Side Diff: base/file_util_unittest.cc

Issue 6001010: Move platform_thread to base/threading and put in the base namespace. I left ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event.cc ('k') | base/lazy_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <winioctl.h> 9 #include <winioctl.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
11 #include <shlobj.h> 11 #include <shlobj.h>
12 #include <tchar.h> 12 #include <tchar.h>
13 #endif 13 #endif
14 14
15 #include <fstream> 15 #include <fstream>
16 #include <set> 16 #include <set>
17 17
18 #include "base/base_paths.h" 18 #include "base/base_paths.h"
19 #include "base/file_path.h" 19 #include "base/file_path.h"
20 #include "base/file_util.h" 20 #include "base/file_util.h"
21 #include "base/path_service.h" 21 #include "base/path_service.h"
22 #include "base/platform_thread.h"
23 #include "base/scoped_handle.h" 22 #include "base/scoped_handle.h"
24 #include "base/scoped_temp_dir.h" 23 #include "base/scoped_temp_dir.h"
24 #include "base/threading/platform_thread.h"
25 #include "base/time.h" 25 #include "base/time.h"
26 #include "base/utf_string_conversions.h" 26 #include "base/utf_string_conversions.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 #include "testing/platform_test.h" 28 #include "testing/platform_test.h"
29 29
30 // This macro helps avoid wrapped lines in the test structs. 30 // This macro helps avoid wrapped lines in the test structs.
31 #define FPL(x) FILE_PATH_LITERAL(x) 31 #define FPL(x) FILE_PATH_LITERAL(x)
32 32
33 namespace { 33 namespace {
34 34
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 // Flaky, http://crbug.com/46246 341 // Flaky, http://crbug.com/46246
342 TEST_F(FileUtilTest, FLAKY_CountFilesCreatedAfter) { 342 TEST_F(FileUtilTest, FLAKY_CountFilesCreatedAfter) {
343 // Create old file (that we don't want to count) 343 // Create old file (that we don't want to count)
344 FilePath old_file_name = 344 FilePath old_file_name =
345 temp_dir_.path().Append(FILE_PATH_LITERAL("Old File.txt")); 345 temp_dir_.path().Append(FILE_PATH_LITERAL("Old File.txt"));
346 CreateTextFile(old_file_name, L"Just call me Mr. Creakybits"); 346 CreateTextFile(old_file_name, L"Just call me Mr. Creakybits");
347 347
348 // Age to perfection 348 // Age to perfection
349 #if defined(OS_WIN) 349 #if defined(OS_WIN)
350 PlatformThread::Sleep(100); 350 base::PlatformThread::Sleep(100);
351 #elif defined(OS_POSIX) 351 #elif defined(OS_POSIX)
352 // We need to wait at least one second here because the precision of 352 // We need to wait at least one second here because the precision of
353 // file creation time is one second. 353 // file creation time is one second.
354 PlatformThread::Sleep(1500); 354 base::PlatformThread::Sleep(1500);
355 #endif 355 #endif
356 356
357 // Establish our cutoff time 357 // Establish our cutoff time
358 base::Time now(base::Time::NowFromSystemTime()); 358 base::Time now(base::Time::NowFromSystemTime());
359 EXPECT_EQ(0, file_util::CountFilesCreatedAfter(temp_dir_.path(), now)); 359 EXPECT_EQ(0, file_util::CountFilesCreatedAfter(temp_dir_.path(), now));
360 360
361 // Create a new file (that we do want to count) 361 // Create a new file (that we do want to count)
362 FilePath new_file_name = 362 FilePath new_file_name =
363 temp_dir_.path().Append(FILE_PATH_LITERAL("New File.txt")); 363 temp_dir_.path().Append(FILE_PATH_LITERAL("New File.txt"));
364 CreateTextFile(new_file_name, L"Waaaaaaaaaaaaaah."); 364 CreateTextFile(new_file_name, L"Waaaaaaaaaaaaaah.");
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); 1827 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir));
1828 1828
1829 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); 1829 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt")));
1830 std::string bar("baz"); 1830 std::string bar("baz");
1831 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); 1831 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length()));
1832 1832
1833 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); 1833 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir));
1834 } 1834 }
1835 1835
1836 } // namespace 1836 } // namespace
OLDNEW
« no previous file with comments | « base/debug/trace_event.cc ('k') | base/lazy_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698