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

Side by Side Diff: base/file_util_unittest.cc

Issue 87039: Fixes for comments on the review 87003.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 8 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/file_util_posix.cc ('k') | no next file » | 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) 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 "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 <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
11 #endif 11 #endif
12 12
13 #include <fstream> 13 #include <fstream>
14 #include <iostream> 14 #include <iostream>
15 #include <set> 15 #include <set>
16 16
17 #include "base/base_paths.h" 17 #include "base/base_paths.h"
18 #include "base/file_path.h" 18 #include "base/file_path.h"
19 #include "base/file_util.h" 19 #include "base/file_util.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/path_service.h" 21 #include "base/path_service.h"
22 #include "base/platform_thread.h"
22 #include "base/string_util.h" 23 #include "base/string_util.h"
23 #include "base/time.h" 24 #include "base/time.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "testing/platform_test.h" 26 #include "testing/platform_test.h"
26 27
27 // This macro helps avoid wrapped lines in the test structs. 28 // This macro helps avoid wrapped lines in the test structs.
28 #define FPL(x) FILE_PATH_LITERAL(x) 29 #define FPL(x) FILE_PATH_LITERAL(x)
29 30
30 namespace { 31 namespace {
31 32
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 314 }
314 } 315 }
315 316
316 TEST_F(FileUtilTest, CountFilesCreatedAfter) { 317 TEST_F(FileUtilTest, CountFilesCreatedAfter) {
317 // Create old file (that we don't want to count) 318 // Create old file (that we don't want to count)
318 FilePath old_file_name = test_dir_.Append(FILE_PATH_LITERAL("Old File.txt")); 319 FilePath old_file_name = test_dir_.Append(FILE_PATH_LITERAL("Old File.txt"));
319 CreateTextFile(old_file_name, L"Just call me Mr. Creakybits"); 320 CreateTextFile(old_file_name, L"Just call me Mr. Creakybits");
320 321
321 // Age to perfection 322 // Age to perfection
322 #if defined(OS_WIN) 323 #if defined(OS_WIN)
323 Sleep(100); 324 PlatformThread::Sleep(100);
324 #elif defined(OS_POSIX) 325 #elif defined(OS_POSIX)
325 // We need to wait at least one second here because the precision of 326 // We need to wait at least one second here because the precision of
326 // file creation time is one second. 327 // file creation time is one second.
327 sleep(1); 328 PlatformThread::Sleep(1500);
328 #endif 329 #endif
329 330
330 // Establish our cutoff time 331 // Establish our cutoff time
331 base::Time now(base::Time::NowFromSystemTime()); 332 base::Time now(base::Time::NowFromSystemTime());
332 EXPECT_EQ(0, file_util::CountFilesCreatedAfter(test_dir_, now)); 333 EXPECT_EQ(0, file_util::CountFilesCreatedAfter(test_dir_, now));
333 334
334 // Create a new file (that we do want to count) 335 // Create a new file (that we do want to count)
335 FilePath new_file_name = test_dir_.Append(FILE_PATH_LITERAL("New File.txt")); 336 FilePath new_file_name = test_dir_.Append(FILE_PATH_LITERAL("New File.txt"));
336 CreateTextFile(new_file_name, L"Waaaaaaaaaaaaaah."); 337 CreateTextFile(new_file_name, L"Waaaaaaaaaaaaaah.");
337 338
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 #elif defined(OS_LINUX) 1087 #elif defined(OS_LINUX)
1087 EXPECT_FALSE(file_util::ContainsPath(foo, 1088 EXPECT_FALSE(file_util::ContainsPath(foo,
1088 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); 1089 foo_caps.Append(FILE_PATH_LITERAL("bar.txt"))));
1089 #else 1090 #else
1090 // We can't really do this test on osx since the case-sensitivity of the 1091 // We can't really do this test on osx since the case-sensitivity of the
1091 // filesystem is configurable. 1092 // filesystem is configurable.
1092 #endif 1093 #endif
1093 } 1094 }
1094 1095
1095 } // namespace 1096 } // namespace
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698