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

Side by Side Diff: webkit/fileapi/isolated_file_util_unittest.cc

Issue 14671020: FileAPI: Copy base::FileUtilProxy::Entry to fileapi::DirectoryEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build and remove base/ change Created 7 years, 7 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 | « webkit/fileapi/file_system_operation.h ('k') | webkit/fileapi/local_file_system_operation.h » ('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) 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 <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 TEST_F(IsolatedFileUtilTest, ReadDirectoryTest) { 353 TEST_F(IsolatedFileUtilTest, ReadDirectoryTest) {
354 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { 354 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) {
355 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; 355 const test::TestCaseRecord& test_case = test::kRegularTestCases[i];
356 if (!test_case.is_directory) 356 if (!test_case.is_directory)
357 continue; 357 continue;
358 358
359 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i 359 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i
360 << ": " << test_case.path); 360 << ": " << test_case.path);
361 361
362 // Read entries in the directory to construct the expected results map. 362 // Read entries in the directory to construct the expected results map.
363 typedef std::map<base::FilePath::StringType, 363 typedef std::map<base::FilePath::StringType, DirectoryEntry> EntryMap;
364 base::FileUtilProxy::Entry> EntryMap;
365 EntryMap expected_entry_map; 364 EntryMap expected_entry_map;
366 365
367 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path); 366 base::FilePath dir_path = GetTestCasePlatformPath(test_case.path);
368 FileEnumerator file_enum( 367 FileEnumerator file_enum(
369 dir_path, false /* not recursive */, 368 dir_path, false /* not recursive */,
370 FileEnumerator::FILES | FileEnumerator::DIRECTORIES); 369 FileEnumerator::FILES | FileEnumerator::DIRECTORIES);
371 base::FilePath current; 370 base::FilePath current;
372 while (!(current = file_enum.Next()).empty()) { 371 while (!(current = file_enum.Next()).empty()) {
373 FileEnumerator::FindInfo file_info; 372 FileEnumerator::FindInfo file_info;
374 file_enum.GetFindInfo(&file_info); 373 file_enum.GetFindInfo(&file_info);
375 base::FileUtilProxy::Entry entry; 374 DirectoryEntry entry;
376 entry.is_directory = FileEnumerator::IsDirectory(file_info); 375 entry.is_directory = FileEnumerator::IsDirectory(file_info);
377 entry.name = current.BaseName().value(); 376 entry.name = current.BaseName().value();
378 entry.size = FileEnumerator::GetFilesize(file_info); 377 entry.size = FileEnumerator::GetFilesize(file_info);
379 entry.last_modified_time = FileEnumerator::GetLastModifiedTime(file_info); 378 entry.last_modified_time = FileEnumerator::GetLastModifiedTime(file_info);
380 expected_entry_map[entry.name] = entry; 379 expected_entry_map[entry.name] = entry;
381 380
382 #if defined(OS_POSIX) 381 #if defined(OS_POSIX)
383 // Creates a symlink for each file/directory. 382 // Creates a symlink for each file/directory.
384 // They should be ignored by ReadDirectory, so we don't add them 383 // They should be ignored by ReadDirectory, so we don't add them
385 // to expected_entry_map. 384 // to expected_entry_map.
386 file_util::CreateSymbolicLink( 385 file_util::CreateSymbolicLink(
387 current, 386 current,
388 dir_path.Append(current.BaseName().AddExtension( 387 dir_path.Append(current.BaseName().AddExtension(
389 FILE_PATH_LITERAL("link")))); 388 FILE_PATH_LITERAL("link"))));
390 #endif 389 #endif
391 } 390 }
392 391
393 // Perform ReadDirectory in the isolated filesystem. 392 // Perform ReadDirectory in the isolated filesystem.
394 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); 393 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path));
395 FileEntryList entries; 394 FileEntryList entries;
396 ASSERT_EQ(base::PLATFORM_FILE_OK, 395 ASSERT_EQ(base::PLATFORM_FILE_OK,
397 AsyncFileTestHelper::ReadDirectory( 396 AsyncFileTestHelper::ReadDirectory(
398 file_system_context(), url, &entries)); 397 file_system_context(), url, &entries));
399 398
400 EXPECT_EQ(expected_entry_map.size(), entries.size()); 399 EXPECT_EQ(expected_entry_map.size(), entries.size());
401 for (size_t i = 0; i < entries.size(); ++i) { 400 for (size_t i = 0; i < entries.size(); ++i) {
402 const base::FileUtilProxy::Entry& entry = entries[i]; 401 const DirectoryEntry& entry = entries[i];
403 EntryMap::iterator found = expected_entry_map.find(entry.name); 402 EntryMap::iterator found = expected_entry_map.find(entry.name);
404 EXPECT_TRUE(found != expected_entry_map.end()); 403 EXPECT_TRUE(found != expected_entry_map.end());
405 EXPECT_EQ(found->second.name, entry.name); 404 EXPECT_EQ(found->second.name, entry.name);
406 EXPECT_EQ(found->second.is_directory, entry.is_directory); 405 EXPECT_EQ(found->second.is_directory, entry.is_directory);
407 EXPECT_EQ(found->second.size, entry.size); 406 EXPECT_EQ(found->second.size, entry.size);
408 EXPECT_EQ(found->second.last_modified_time.ToDoubleT(), 407 EXPECT_EQ(found->second.last_modified_time.ToDoubleT(),
409 entry.last_modified_time.ToDoubleT()); 408 entry.last_modified_time.ToDoubleT());
410 } 409 }
411 } 410 }
412 } 411 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 EXPECT_EQ(base::PLATFORM_FILE_OK, 544 EXPECT_EQ(base::PLATFORM_FILE_OK,
546 file_util()->Truncate(GetOperationContext().get(), url, 999)); 545 file_util()->Truncate(GetOperationContext().get(), url, 999));
547 ASSERT_EQ(base::PLATFORM_FILE_OK, 546 ASSERT_EQ(base::PLATFORM_FILE_OK,
548 file_util()->GetFileInfo(GetOperationContext().get(), url, 547 file_util()->GetFileInfo(GetOperationContext().get(), url,
549 &info, &platform_path)); 548 &info, &platform_path));
550 EXPECT_EQ(999, info.size); 549 EXPECT_EQ(999, info.size);
551 } 550 }
552 } 551 }
553 552
554 } // namespace fileapi 553 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_operation.h ('k') | webkit/fileapi/local_file_system_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698