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

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

Issue 5754002: Moving away from shell api to support long path names on windows for filesystem. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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) 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 "webkit/fileapi/file_system_operation.h" 5 #include "webkit/fileapi/file_system_operation.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 ScopedTempDir dir; 421 ScopedTempDir dir;
422 ASSERT_TRUE(dir.CreateUniqueTempDir()); 422 ASSERT_TRUE(dir.CreateUniqueTempDir());
423 FilePath file; 423 FilePath file;
424 424
425 file_util::CreateTemporaryFileInDir(dir.path(), &file); 425 file_util::CreateTemporaryFileInDir(dir.path(), &file);
426 operation()->CreateFile(file, true); 426 operation()->CreateFile(file, true);
427 MessageLoop::current()->RunAllPending(); 427 MessageLoop::current()->RunAllPending();
428 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); 428 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status());
429 } 429 }
430 430
431 TEST_F(FileSystemOperationTest, TestCreateVeryLongName) {
432 ScopedTempDir dir;
433 ASSERT_TRUE(dir.CreateUniqueTempDir());
434
435 #if defined(OS_WIN)
436 FilePath dir_path(FilePath::kExtendedPathPrefix + dir.path().value());
437 #else
438 FilePath dir_path = dir.path();
439 #endif
440
441 // TODO(kkanetkar): Once each platform's limitations have been enforced
442 // consider that in this test. Currently this test is for
443 // windows primarily.
444 const char kLongPathChar160[] =
445 "012345678901234567890123456789012345678901234567890123456789"
446 "012345678901234567890123456789012345678901234567890123456789"
447 "0123456789012345678901234567890123456789";
448
449 FilePath dir1 = dir_path.AppendASCII(kLongPathChar160);
450
451 FilePath dir2 = dir1.AppendASCII(kLongPathChar160);
452
453 FilePath file = dir2.AppendASCII(kLongPathChar160);
454
455 operation()->CreateDirectory(dir1, false, true);
456 MessageLoop::current()->RunAllPending();
457
458 operation()->CreateDirectory(dir2, false, true);
459 MessageLoop::current()->RunAllPending();
460
461 operation()->CreateFile(file, true);
462 MessageLoop::current()->RunAllPending();
463 EXPECT_TRUE(file_util::PathExists(file));
464 // ScopedTempDir does not delete dir with long name since it does
Paweł Hajdan Jr. 2010/12/16 08:58:40 Oh, should we rather fix ScopedTempDir?
Erik does not do reviews 2010/12/16 18:34:54 Agree. We use ScopedTempDir in a number of places
465 // not prefix \\?\. So Delete the long file here.
466 EXPECT_TRUE(file_util::Delete(dir1, true));
467 }
468
431 TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) { 469 TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) {
432 // Already existing file and exclusive false. 470 // Already existing file and exclusive false.
433 ScopedTempDir dir; 471 ScopedTempDir dir;
434 ASSERT_TRUE(dir.CreateUniqueTempDir()); 472 ASSERT_TRUE(dir.CreateUniqueTempDir());
435 FilePath file; 473 FilePath file;
436 file_util::CreateTemporaryFileInDir(dir.path(), &file); 474 file_util::CreateTemporaryFileInDir(dir.path(), &file);
437 475
438 operation()->CreateFile(file, false); 476 operation()->CreateFile(file, false);
439 MessageLoop::current()->RunAllPending(); 477 MessageLoop::current()->RunAllPending();
440 EXPECT_EQ(kFileOperationSucceeded, status()); 478 EXPECT_EQ(kFileOperationSucceeded, status());
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 759
722 // Check that its length is now 3 and that it contains only bits of test data. 760 // Check that its length is now 3 and that it contains only bits of test data.
723 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); 761 EXPECT_TRUE(file_util::GetFileInfo(file, &info));
724 EXPECT_EQ(length, info.size); 762 EXPECT_EQ(length, info.size);
725 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); 763 EXPECT_EQ(length, file_util::ReadFile(file, data, length));
726 for (int i = 0; i < length; ++i) 764 for (int i = 0; i < length; ++i)
727 EXPECT_EQ(test_data[i], data[i]); 765 EXPECT_EQ(test_data[i], data[i]);
728 } 766 }
729 767
730 } // namespace fileapi 768 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698