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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc

Issue 10408071: gdata: Fix a crash when adding a new file to a new but deleted directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
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 <errno.h> 5 #include <errno.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 Eq(FilePath(FILE_PATH_LITERAL("drive/New Directory"))))).Times(1); 1427 Eq(FilePath(FILE_PATH_LITERAL("drive/New Directory"))))).Times(1);
1428 1428
1429 LoadChangeFeed("delta_file_added_in_new_directory.json", ++latest_changelog); 1429 LoadChangeFeed("delta_file_added_in_new_directory.json", ++latest_changelog);
1430 1430
1431 EXPECT_TRUE(FindEntry(FilePath( 1431 EXPECT_TRUE(FindEntry(FilePath(
1432 FILE_PATH_LITERAL("drive/New Directory")))); 1432 FILE_PATH_LITERAL("drive/New Directory"))));
1433 EXPECT_TRUE(FindEntry(FilePath( 1433 EXPECT_TRUE(FindEntry(FilePath(
1434 FILE_PATH_LITERAL("drive/New Directory/File in new dir.gdoc")))); 1434 FILE_PATH_LITERAL("drive/New Directory/File in new dir.gdoc"))));
1435 } 1435 }
1436 1436
1437 TEST_F(GDataFileSystemTest, ChangeFeed_AddFileToNewButDeletedDirectory) {
1438 int latest_changelog = 0;
1439 LoadRootFeedDocument("root_feed.json");
1440
1441 // This feed contains thw following updates:
1442 // 1) A new PDF file is added to a new directory
1443 // 2) but the new directory is marked "deleted" (i.e. moved to Trash)
1444 // Hence, the PDF file should be just ignored.
1445 LoadChangeFeed("delta_file_added_in_new_but_deleted_directory.json",
1446 ++latest_changelog);
1447 }
1448
1437 TEST_F(GDataFileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) { 1449 TEST_F(GDataFileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) {
1438 int latest_changelog = 0; 1450 int latest_changelog = 0;
1439 LoadRootFeedDocument("root_feed.json"); 1451 LoadRootFeedDocument("root_feed.json");
1440 1452
1441 EXPECT_TRUE(FindEntry(FilePath(FILE_PATH_LITERAL( 1453 EXPECT_TRUE(FindEntry(FilePath(FILE_PATH_LITERAL(
1442 "drive/Directory 2")))); 1454 "drive/Directory 2"))));
1443 EXPECT_TRUE(FindEntry(FilePath(FILE_PATH_LITERAL( 1455 EXPECT_TRUE(FindEntry(FilePath(FILE_PATH_LITERAL(
1444 "drive/Directory 1")))); 1456 "drive/Directory 1"))));
1445 EXPECT_TRUE(FindEntry(FilePath(FILE_PATH_LITERAL( 1457 EXPECT_TRUE(FindEntry(FilePath(FILE_PATH_LITERAL(
1446 "drive/Directory 1/SubDirectory File 1.txt")))); 1458 "drive/Directory 1/SubDirectory File 1.txt"))));
(...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after
3670 .Times(1); 3682 .Times(1);
3671 // We'll notify the directory change to the observer. 3683 // We'll notify the directory change to the observer.
3672 EXPECT_CALL(*mock_directory_observer_, 3684 EXPECT_CALL(*mock_directory_observer_,
3673 OnDirectoryChanged(Eq(FilePath(kGDataRootDirectory)))).Times(1); 3685 OnDirectoryChanged(Eq(FilePath(kGDataRootDirectory)))).Times(1);
3674 3686
3675 file_system_->RequestDirectoryRefresh(FilePath(kGDataRootDirectory)); 3687 file_system_->RequestDirectoryRefresh(FilePath(kGDataRootDirectory));
3676 message_loop_.RunAllPending(); 3688 message_loop_.RunAllPending();
3677 } 3689 }
3678 3690
3679 } // namespace gdata 3691 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698