OLD | NEW |
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/sync_file_system/drive/fake_api_util.h" | 5 #include "chrome/browser/sync_file_system/drive/fake_api_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 void DidDeleteFile(google_apis::GDataErrorCode* error_out, | 38 void DidDeleteFile(google_apis::GDataErrorCode* error_out, |
39 google_apis::GDataErrorCode error) { | 39 google_apis::GDataErrorCode error) { |
40 *error_out = error; | 40 *error_out = error; |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 TEST(FakeAPIUtilTest, ChangeSquashTest) { | 45 TEST(FakeAPIUtilTest, ChangeSquashTest) { |
46 MessageLoop message_loop; | 46 base::MessageLoop message_loop; |
47 FakeAPIUtil api_util; | 47 FakeAPIUtil api_util; |
48 std::string kParentResourceId("parent resource id"); | 48 std::string kParentResourceId("parent resource id"); |
49 std::string kParentTitle("app-id"); | 49 std::string kParentTitle("app-id"); |
50 std::string kTitle1("title 1"); | 50 std::string kTitle1("title 1"); |
51 std::string kTitle2("title 2"); | 51 std::string kTitle2("title 2"); |
52 std::string kTitle3("title 3"); | 52 std::string kTitle3("title 3"); |
53 std::string kResourceId1("resource id 1"); | 53 std::string kResourceId1("resource id 1"); |
54 std::string kResourceId2("resource id 2"); | 54 std::string kResourceId2("resource id 2"); |
55 std::string kMD5_1("md5 1"); | 55 std::string kMD5_1("md5 1"); |
56 std::string kMD5_2("md5 2"); | 56 std::string kMD5_2("md5 2"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 EXPECT_EQ(kResourceId1, change_list->entries()[0]->resource_id()); | 111 EXPECT_EQ(kResourceId1, change_list->entries()[0]->resource_id()); |
112 EXPECT_TRUE(change_list->entries()[0]->deleted()); | 112 EXPECT_TRUE(change_list->entries()[0]->deleted()); |
113 | 113 |
114 EXPECT_EQ(kResourceId2, change_list->entries()[1]->resource_id()); | 114 EXPECT_EQ(kResourceId2, change_list->entries()[1]->resource_id()); |
115 EXPECT_EQ(kMD5_3, change_list->entries()[1]->file_md5()); | 115 EXPECT_EQ(kMD5_3, change_list->entries()[1]->file_md5()); |
116 EXPECT_FALSE(change_list->entries()[1]->deleted()); | 116 EXPECT_FALSE(change_list->entries()[1]->deleted()); |
117 } | 117 } |
118 | 118 |
119 TEST(FakeAPIUtilTest, DeleteFile) { | 119 TEST(FakeAPIUtilTest, DeleteFile) { |
120 MessageLoop message_loop; | 120 base::MessageLoop message_loop; |
121 FakeAPIUtil api_util; | 121 FakeAPIUtil api_util; |
122 std::string resource_id = "resource_id_to_be_deleted"; | 122 std::string resource_id = "resource_id_to_be_deleted"; |
123 api_util.PushRemoteChange("parent_id", | 123 api_util.PushRemoteChange("parent_id", |
124 "parent_title", | 124 "parent_title", |
125 "resource_title", | 125 "resource_title", |
126 resource_id, | 126 resource_id, |
127 "resource_md5", | 127 "resource_md5", |
128 SYNC_FILE_TYPE_FILE, | 128 SYNC_FILE_TYPE_FILE, |
129 false /* deleted */); | 129 false /* deleted */); |
130 | 130 |
131 google_apis::GDataErrorCode error = google_apis::HTTP_NOT_FOUND; | 131 google_apis::GDataErrorCode error = google_apis::HTTP_NOT_FOUND; |
132 api_util.DeleteFile( | 132 api_util.DeleteFile( |
133 resource_id, std::string(), base::Bind(&DidDeleteFile, &error)); | 133 resource_id, std::string(), base::Bind(&DidDeleteFile, &error)); |
134 message_loop.RunUntilIdle(); | 134 message_loop.RunUntilIdle(); |
135 | 135 |
136 EXPECT_EQ(google_apis::HTTP_SUCCESS, error); | 136 EXPECT_EQ(google_apis::HTTP_SUCCESS, error); |
137 EXPECT_TRUE(api_util.remote_resources().find(resource_id)->second.deleted); | 137 EXPECT_TRUE(api_util.remote_resources().find(resource_id)->second.deleted); |
138 } | 138 } |
139 | 139 |
140 } // namespace drive | 140 } // namespace drive |
141 } // namespace sync_file_system | 141 } // namespace sync_file_system |
OLD | NEW |