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

Side by Side Diff: chrome/browser/chromeos/drive/file_system/move_operation_unittest.cc

Issue 343073003: Files.app: Provide detailed change information on onDirectoryChanged event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/drive/file_system/move_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/move_operation.h"
6 6
7 #include "chrome/browser/chromeos/drive/file_change.h"
7 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" 8 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h"
8 #include "google_apis/drive/test_util.h" 9 #include "google_apis/drive/test_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace drive { 12 namespace drive {
12 namespace file_system { 13 namespace file_system {
13 14
14 class MoveOperationTest : public OperationTestBase { 15 class MoveOperationTest : public OperationTestBase {
15 protected: 16 protected:
16 virtual void SetUp() OVERRIDE { 17 virtual void SetUp() OVERRIDE {
(...skipping 22 matching lines...) Expand all
39 dest_path, 40 dest_path,
40 google_apis::test_util::CreateCopyResultCallback(&error)); 41 google_apis::test_util::CreateCopyResultCallback(&error));
41 test_util::RunBlockingPoolTask(); 42 test_util::RunBlockingPoolTask();
42 EXPECT_EQ(FILE_ERROR_OK, error); 43 EXPECT_EQ(FILE_ERROR_OK, error);
43 44
44 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); 45 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
45 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id()); 46 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id());
46 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 47 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
47 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry)); 48 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry));
48 49
49 EXPECT_EQ(1U, observer()->get_changed_paths().size()); 50 EXPECT_EQ(2U, observer()->get_changed_files().size());
50 EXPECT_TRUE(observer()->get_changed_paths().count(src_path.DirName())); 51 EXPECT_TRUE(observer()->get_changed_files().count(src_path));
52 EXPECT_TRUE(observer()->get_changed_files().count(dest_path));
51 53
52 EXPECT_EQ(1U, observer()->updated_local_ids().size()); 54 EXPECT_EQ(1U, observer()->updated_local_ids().size());
53 EXPECT_TRUE(observer()->updated_local_ids().count(src_entry.local_id())); 55 EXPECT_TRUE(observer()->updated_local_ids().count(src_entry.local_id()));
54 } 56 }
55 57
56 TEST_F(MoveOperationTest, MoveFileFromRootToSubDirectory) { 58 TEST_F(MoveOperationTest, MoveFileFromRootToSubDirectory) {
57 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); 59 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt"));
58 base::FilePath dest_path( 60 base::FilePath dest_path(
59 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log")); 61 FILE_PATH_LITERAL("drive/root/Directory 1/Test.log"));
60 62
61 ResourceEntry src_entry, dest_entry; 63 ResourceEntry src_entry, dest_entry;
62 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry)); 64 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry));
63 ASSERT_EQ(FILE_ERROR_NOT_FOUND, 65 ASSERT_EQ(FILE_ERROR_NOT_FOUND,
64 GetLocalResourceEntry(dest_path, &dest_entry)); 66 GetLocalResourceEntry(dest_path, &dest_entry));
65 67
66 FileError error = FILE_ERROR_FAILED; 68 FileError error = FILE_ERROR_FAILED;
67 operation_->Move(src_path, 69 operation_->Move(src_path,
68 dest_path, 70 dest_path,
69 google_apis::test_util::CreateCopyResultCallback(&error)); 71 google_apis::test_util::CreateCopyResultCallback(&error));
70 test_util::RunBlockingPoolTask(); 72 test_util::RunBlockingPoolTask();
71 EXPECT_EQ(FILE_ERROR_OK, error); 73 EXPECT_EQ(FILE_ERROR_OK, error);
72 74
73 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); 75 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
74 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id()); 76 EXPECT_EQ(src_entry.local_id(), dest_entry.local_id());
75 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 77 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
76 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry)); 78 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &src_entry));
77 79
78 EXPECT_EQ(2U, observer()->get_changed_paths().size()); 80 EXPECT_EQ(2U, observer()->get_changed_files().size());
79 EXPECT_TRUE(observer()->get_changed_paths().count(src_path.DirName())); 81 EXPECT_TRUE(observer()->get_changed_files().count(src_path));
80 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName())); 82 EXPECT_TRUE(observer()->get_changed_files().count(dest_path));
81 83
82 EXPECT_EQ(1U, observer()->updated_local_ids().size()); 84 EXPECT_EQ(1U, observer()->updated_local_ids().size());
83 EXPECT_TRUE(observer()->updated_local_ids().count(src_entry.local_id())); 85 EXPECT_TRUE(observer()->updated_local_ids().count(src_entry.local_id()));
84 } 86 }
85 87
86 TEST_F(MoveOperationTest, MoveNotExistingFile) { 88 TEST_F(MoveOperationTest, MoveNotExistingFile) {
87 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); 89 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt"));
88 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log")); 90 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log"));
89 91
90 FileError error = FILE_ERROR_OK; 92 FileError error = FILE_ERROR_OK;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 test_util::RunBlockingPoolTask(); 131 test_util::RunBlockingPoolTask();
130 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); 132 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error);
131 133
132 ResourceEntry entry; 134 ResourceEntry entry;
133 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); 135 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry));
134 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry)); 136 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry));
135 } 137 }
136 138
137 } // namespace file_system 139 } // namespace file_system
138 } // namespace drive 140 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698