OLD | NEW |
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 "chrome/browser/drive/fake_drive_service.h" | 5 #include "chrome/browser/drive/fake_drive_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/md5.h" | 12 #include "base/md5.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/browser/drive/test_util.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "google_apis/drive/drive_api_parser.h" | 19 #include "google_apis/drive/drive_api_parser.h" |
19 #include "google_apis/drive/gdata_wapi_parser.h" | 20 #include "google_apis/drive/gdata_wapi_parser.h" |
20 #include "google_apis/drive/gdata_wapi_requests.h" | 21 #include "google_apis/drive/gdata_wapi_requests.h" |
21 #include "google_apis/drive/test_util.h" | 22 #include "google_apis/drive/test_util.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 using google_apis::AboutResource; | 25 using google_apis::AboutResource; |
25 using google_apis::AppList; | 26 using google_apis::AppList; |
26 using google_apis::GDataErrorCode; | |
27 using google_apis::GDATA_NO_CONNECTION; | 27 using google_apis::GDATA_NO_CONNECTION; |
28 using google_apis::GDATA_OTHER_ERROR; | 28 using google_apis::GDATA_OTHER_ERROR; |
| 29 using google_apis::GDataErrorCode; |
29 using google_apis::GetContentCallback; | 30 using google_apis::GetContentCallback; |
30 using google_apis::HTTP_CREATED; | 31 using google_apis::HTTP_CREATED; |
31 using google_apis::HTTP_NOT_FOUND; | 32 using google_apis::HTTP_NOT_FOUND; |
32 using google_apis::HTTP_NO_CONTENT; | 33 using google_apis::HTTP_NO_CONTENT; |
33 using google_apis::HTTP_PRECONDITION; | 34 using google_apis::HTTP_PRECONDITION; |
34 using google_apis::HTTP_RESUME_INCOMPLETE; | 35 using google_apis::HTTP_RESUME_INCOMPLETE; |
35 using google_apis::HTTP_SUCCESS; | 36 using google_apis::HTTP_SUCCESS; |
36 using google_apis::Link; | 37 using google_apis::Link; |
37 using google_apis::ProgressCallback; | 38 using google_apis::ProgressCallback; |
38 using google_apis::ResourceEntry; | 39 using google_apis::ResourceEntry; |
39 using google_apis::ResourceList; | 40 using google_apis::ResourceList; |
40 using google_apis::UploadRangeResponse; | 41 using google_apis::UploadRangeResponse; |
41 namespace test_util = google_apis::test_util; | |
42 | 42 |
43 namespace drive { | 43 namespace drive { |
44 | 44 |
| 45 namespace test_util { |
| 46 |
| 47 using google_apis::test_util::AppendProgressCallbackResult; |
| 48 using google_apis::test_util::CreateCopyResultCallback; |
| 49 using google_apis::test_util::ProgressInfo; |
| 50 using google_apis::test_util::TestGetContentCallback; |
| 51 using google_apis::test_util::WriteStringToFile; |
| 52 |
| 53 } // namespace test_util |
| 54 |
45 namespace { | 55 namespace { |
46 | 56 |
47 class FakeDriveServiceTest : public testing::Test { | 57 class FakeDriveServiceTest : public testing::Test { |
48 protected: | 58 protected: |
49 // Returns the resource entry that matches |resource_id|. | 59 // Returns the resource entry that matches |resource_id|. |
50 scoped_ptr<ResourceEntry> FindEntry(const std::string& resource_id) { | 60 scoped_ptr<ResourceEntry> FindEntry(const std::string& resource_id) { |
51 GDataErrorCode error = GDATA_OTHER_ERROR; | 61 GDataErrorCode error = GDATA_OTHER_ERROR; |
52 scoped_ptr<ResourceEntry> resource_entry; | 62 scoped_ptr<ResourceEntry> resource_entry; |
53 fake_service_.GetResourceEntry( | 63 fake_service_.GetResourceEntry( |
54 resource_id, | 64 resource_id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 test_util::CreateCopyResultCallback(&error, &about_resource)); | 110 test_util::CreateCopyResultCallback(&error, &about_resource)); |
101 base::RunLoop().RunUntilIdle(); | 111 base::RunLoop().RunUntilIdle(); |
102 return about_resource->largest_change_id(); | 112 return about_resource->largest_change_id(); |
103 } | 113 } |
104 | 114 |
105 content::TestBrowserThreadBundle thread_bundle_; | 115 content::TestBrowserThreadBundle thread_bundle_; |
106 FakeDriveService fake_service_; | 116 FakeDriveService fake_service_; |
107 }; | 117 }; |
108 | 118 |
109 TEST_F(FakeDriveServiceTest, GetAllResourceList) { | 119 TEST_F(FakeDriveServiceTest, GetAllResourceList) { |
110 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 120 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
111 "gdata/root_feed.json")); | |
112 | 121 |
113 GDataErrorCode error = GDATA_OTHER_ERROR; | 122 GDataErrorCode error = GDATA_OTHER_ERROR; |
114 scoped_ptr<ResourceList> resource_list; | 123 scoped_ptr<ResourceList> resource_list; |
115 fake_service_.GetAllResourceList( | 124 fake_service_.GetAllResourceList( |
116 test_util::CreateCopyResultCallback(&error, &resource_list)); | 125 test_util::CreateCopyResultCallback(&error, &resource_list)); |
117 base::RunLoop().RunUntilIdle(); | 126 base::RunLoop().RunUntilIdle(); |
118 | 127 |
119 EXPECT_EQ(HTTP_SUCCESS, error); | 128 EXPECT_EQ(HTTP_SUCCESS, error); |
120 ASSERT_TRUE(resource_list); | 129 ASSERT_TRUE(resource_list); |
121 // Do some sanity check. | 130 // Do some sanity check. |
122 EXPECT_EQ(15U, resource_list->entries().size()); | 131 EXPECT_EQ(15U, resource_list->entries().size()); |
123 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 132 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
124 } | 133 } |
125 | 134 |
126 TEST_F(FakeDriveServiceTest, GetAllResourceList_Offline) { | 135 TEST_F(FakeDriveServiceTest, GetAllResourceList_Offline) { |
127 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 136 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
128 "gdata/root_feed.json")); | |
129 fake_service_.set_offline(true); | 137 fake_service_.set_offline(true); |
130 | 138 |
131 GDataErrorCode error = GDATA_OTHER_ERROR; | 139 GDataErrorCode error = GDATA_OTHER_ERROR; |
132 scoped_ptr<ResourceList> resource_list; | 140 scoped_ptr<ResourceList> resource_list; |
133 fake_service_.GetAllResourceList( | 141 fake_service_.GetAllResourceList( |
134 test_util::CreateCopyResultCallback(&error, &resource_list)); | 142 test_util::CreateCopyResultCallback(&error, &resource_list)); |
135 base::RunLoop().RunUntilIdle(); | 143 base::RunLoop().RunUntilIdle(); |
136 | 144 |
137 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 145 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
138 EXPECT_FALSE(resource_list); | 146 EXPECT_FALSE(resource_list); |
139 } | 147 } |
140 | 148 |
141 TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_InRootDirectory) { | 149 TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_InRootDirectory) { |
142 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 150 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
143 "gdata/root_feed.json")); | |
144 | 151 |
145 GDataErrorCode error = GDATA_OTHER_ERROR; | 152 GDataErrorCode error = GDATA_OTHER_ERROR; |
146 scoped_ptr<ResourceList> resource_list; | 153 scoped_ptr<ResourceList> resource_list; |
147 fake_service_.GetResourceListInDirectory( | 154 fake_service_.GetResourceListInDirectory( |
148 fake_service_.GetRootResourceId(), | 155 fake_service_.GetRootResourceId(), |
149 test_util::CreateCopyResultCallback(&error, &resource_list)); | 156 test_util::CreateCopyResultCallback(&error, &resource_list)); |
150 base::RunLoop().RunUntilIdle(); | 157 base::RunLoop().RunUntilIdle(); |
151 | 158 |
152 EXPECT_EQ(HTTP_SUCCESS, error); | 159 EXPECT_EQ(HTTP_SUCCESS, error); |
153 ASSERT_TRUE(resource_list); | 160 ASSERT_TRUE(resource_list); |
154 // Do some sanity check. There are 8 entries in the root directory. | 161 // Do some sanity check. There are 8 entries in the root directory. |
155 EXPECT_EQ(8U, resource_list->entries().size()); | 162 EXPECT_EQ(8U, resource_list->entries().size()); |
156 EXPECT_EQ(1, fake_service_.directory_load_count()); | 163 EXPECT_EQ(1, fake_service_.directory_load_count()); |
157 } | 164 } |
158 | 165 |
159 TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_InNonRootDirectory) { | 166 TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_InNonRootDirectory) { |
160 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 167 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
161 "gdata/root_feed.json")); | |
162 | 168 |
163 GDataErrorCode error = GDATA_OTHER_ERROR; | 169 GDataErrorCode error = GDATA_OTHER_ERROR; |
164 scoped_ptr<ResourceList> resource_list; | 170 scoped_ptr<ResourceList> resource_list; |
165 fake_service_.GetResourceListInDirectory( | 171 fake_service_.GetResourceListInDirectory( |
166 "folder:1_folder_resource_id", | 172 "folder:1_folder_resource_id", |
167 test_util::CreateCopyResultCallback(&error, &resource_list)); | 173 test_util::CreateCopyResultCallback(&error, &resource_list)); |
168 base::RunLoop().RunUntilIdle(); | 174 base::RunLoop().RunUntilIdle(); |
169 | 175 |
170 EXPECT_EQ(HTTP_SUCCESS, error); | 176 EXPECT_EQ(HTTP_SUCCESS, error); |
171 ASSERT_TRUE(resource_list); | 177 ASSERT_TRUE(resource_list); |
172 // Do some sanity check. There is three entries in 1_folder_resource_id | 178 // Do some sanity check. There is three entries in 1_folder_resource_id |
173 // directory. | 179 // directory. |
174 EXPECT_EQ(3U, resource_list->entries().size()); | 180 EXPECT_EQ(3U, resource_list->entries().size()); |
175 EXPECT_EQ(1, fake_service_.directory_load_count()); | 181 EXPECT_EQ(1, fake_service_.directory_load_count()); |
176 } | 182 } |
177 | 183 |
178 TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_Offline) { | 184 TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_Offline) { |
179 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 185 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
180 "gdata/root_feed.json")); | |
181 fake_service_.set_offline(true); | 186 fake_service_.set_offline(true); |
182 | 187 |
183 GDataErrorCode error = GDATA_OTHER_ERROR; | 188 GDataErrorCode error = GDATA_OTHER_ERROR; |
184 scoped_ptr<ResourceList> resource_list; | 189 scoped_ptr<ResourceList> resource_list; |
185 fake_service_.GetResourceListInDirectory( | 190 fake_service_.GetResourceListInDirectory( |
186 fake_service_.GetRootResourceId(), | 191 fake_service_.GetRootResourceId(), |
187 test_util::CreateCopyResultCallback(&error, &resource_list)); | 192 test_util::CreateCopyResultCallback(&error, &resource_list)); |
188 base::RunLoop().RunUntilIdle(); | 193 base::RunLoop().RunUntilIdle(); |
189 | 194 |
190 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 195 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
191 EXPECT_FALSE(resource_list); | 196 EXPECT_FALSE(resource_list); |
192 } | 197 } |
193 | 198 |
194 TEST_F(FakeDriveServiceTest, Search) { | 199 TEST_F(FakeDriveServiceTest, Search) { |
195 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 200 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
196 "gdata/root_feed.json")); | |
197 | 201 |
198 GDataErrorCode error = GDATA_OTHER_ERROR; | 202 GDataErrorCode error = GDATA_OTHER_ERROR; |
199 scoped_ptr<ResourceList> resource_list; | 203 scoped_ptr<ResourceList> resource_list; |
200 fake_service_.Search( | 204 fake_service_.Search( |
201 "File", // search_query | 205 "File", // search_query |
202 test_util::CreateCopyResultCallback(&error, &resource_list)); | 206 test_util::CreateCopyResultCallback(&error, &resource_list)); |
203 base::RunLoop().RunUntilIdle(); | 207 base::RunLoop().RunUntilIdle(); |
204 | 208 |
205 EXPECT_EQ(HTTP_SUCCESS, error); | 209 EXPECT_EQ(HTTP_SUCCESS, error); |
206 ASSERT_TRUE(resource_list); | 210 ASSERT_TRUE(resource_list); |
207 // Do some sanity check. There are 4 entries that contain "File" in their | 211 // Do some sanity check. There are 4 entries that contain "File" in their |
208 // titles. | 212 // titles. |
209 EXPECT_EQ(4U, resource_list->entries().size()); | 213 EXPECT_EQ(4U, resource_list->entries().size()); |
210 } | 214 } |
211 | 215 |
212 TEST_F(FakeDriveServiceTest, Search_WithAttribute) { | 216 TEST_F(FakeDriveServiceTest, Search_WithAttribute) { |
213 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 217 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
214 "gdata/root_feed.json")); | |
215 | 218 |
216 GDataErrorCode error = GDATA_OTHER_ERROR; | 219 GDataErrorCode error = GDATA_OTHER_ERROR; |
217 scoped_ptr<ResourceList> resource_list; | 220 scoped_ptr<ResourceList> resource_list; |
218 fake_service_.Search( | 221 fake_service_.Search( |
219 "title:1.txt", // search_query | 222 "title:1.txt", // search_query |
220 test_util::CreateCopyResultCallback(&error, &resource_list)); | 223 test_util::CreateCopyResultCallback(&error, &resource_list)); |
221 base::RunLoop().RunUntilIdle(); | 224 base::RunLoop().RunUntilIdle(); |
222 | 225 |
223 EXPECT_EQ(HTTP_SUCCESS, error); | 226 EXPECT_EQ(HTTP_SUCCESS, error); |
224 ASSERT_TRUE(resource_list); | 227 ASSERT_TRUE(resource_list); |
225 // Do some sanity check. There are 4 entries that contain "1.txt" in their | 228 // Do some sanity check. There are 4 entries that contain "1.txt" in their |
226 // titles. | 229 // titles. |
227 EXPECT_EQ(4U, resource_list->entries().size()); | 230 EXPECT_EQ(4U, resource_list->entries().size()); |
228 } | 231 } |
229 | 232 |
230 TEST_F(FakeDriveServiceTest, Search_MultipleQueries) { | 233 TEST_F(FakeDriveServiceTest, Search_MultipleQueries) { |
231 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 234 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
232 "gdata/root_feed.json")); | |
233 | 235 |
234 GDataErrorCode error = GDATA_OTHER_ERROR; | 236 GDataErrorCode error = GDATA_OTHER_ERROR; |
235 scoped_ptr<ResourceList> resource_list; | 237 scoped_ptr<ResourceList> resource_list; |
236 fake_service_.Search( | 238 fake_service_.Search( |
237 "Directory 1", // search_query | 239 "Directory 1", // search_query |
238 test_util::CreateCopyResultCallback(&error, &resource_list)); | 240 test_util::CreateCopyResultCallback(&error, &resource_list)); |
239 base::RunLoop().RunUntilIdle(); | 241 base::RunLoop().RunUntilIdle(); |
240 | 242 |
241 EXPECT_EQ(HTTP_SUCCESS, error); | 243 EXPECT_EQ(HTTP_SUCCESS, error); |
242 ASSERT_TRUE(resource_list); | 244 ASSERT_TRUE(resource_list); |
243 // There are 2 entries that contain both "Directory" and "1" in their titles. | 245 // There are 2 entries that contain both "Directory" and "1" in their titles. |
244 EXPECT_EQ(2U, resource_list->entries().size()); | 246 EXPECT_EQ(2U, resource_list->entries().size()); |
245 | 247 |
246 fake_service_.Search( | 248 fake_service_.Search( |
247 "\"Directory 1\"", // search_query | 249 "\"Directory 1\"", // search_query |
248 test_util::CreateCopyResultCallback(&error, &resource_list)); | 250 test_util::CreateCopyResultCallback(&error, &resource_list)); |
249 base::RunLoop().RunUntilIdle(); | 251 base::RunLoop().RunUntilIdle(); |
250 | 252 |
251 EXPECT_EQ(HTTP_SUCCESS, error); | 253 EXPECT_EQ(HTTP_SUCCESS, error); |
252 ASSERT_TRUE(resource_list); | 254 ASSERT_TRUE(resource_list); |
253 // There is 1 entry that contain "Directory 1" in its title. | 255 // There is 1 entry that contain "Directory 1" in its title. |
254 EXPECT_EQ(1U, resource_list->entries().size()); | 256 EXPECT_EQ(1U, resource_list->entries().size()); |
255 } | 257 } |
256 | 258 |
257 TEST_F(FakeDriveServiceTest, Search_Offline) { | 259 TEST_F(FakeDriveServiceTest, Search_Offline) { |
258 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 260 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
259 "gdata/root_feed.json")); | |
260 fake_service_.set_offline(true); | 261 fake_service_.set_offline(true); |
261 | 262 |
262 GDataErrorCode error = GDATA_OTHER_ERROR; | 263 GDataErrorCode error = GDATA_OTHER_ERROR; |
263 scoped_ptr<ResourceList> resource_list; | 264 scoped_ptr<ResourceList> resource_list; |
264 fake_service_.Search( | 265 fake_service_.Search( |
265 "Directory 1", // search_query | 266 "Directory 1", // search_query |
266 test_util::CreateCopyResultCallback(&error, &resource_list)); | 267 test_util::CreateCopyResultCallback(&error, &resource_list)); |
267 base::RunLoop().RunUntilIdle(); | 268 base::RunLoop().RunUntilIdle(); |
268 | 269 |
269 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 270 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
270 EXPECT_FALSE(resource_list); | 271 EXPECT_FALSE(resource_list); |
271 } | 272 } |
272 | 273 |
273 TEST_F(FakeDriveServiceTest, Search_Deleted) { | 274 TEST_F(FakeDriveServiceTest, Search_Deleted) { |
274 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 275 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
275 "gdata/root_feed.json")); | |
276 | 276 |
277 GDataErrorCode error = GDATA_OTHER_ERROR; | 277 GDataErrorCode error = GDATA_OTHER_ERROR; |
278 fake_service_.DeleteResource("file:2_file_resource_id", | 278 fake_service_.DeleteResource("file:2_file_resource_id", |
279 std::string(), // etag | 279 std::string(), // etag |
280 test_util::CreateCopyResultCallback(&error)); | 280 test_util::CreateCopyResultCallback(&error)); |
281 base::RunLoop().RunUntilIdle(); | 281 base::RunLoop().RunUntilIdle(); |
282 EXPECT_EQ(HTTP_NO_CONTENT, error); | 282 EXPECT_EQ(HTTP_NO_CONTENT, error); |
283 | 283 |
284 error = GDATA_OTHER_ERROR; | 284 error = GDATA_OTHER_ERROR; |
285 scoped_ptr<ResourceList> resource_list; | 285 scoped_ptr<ResourceList> resource_list; |
286 fake_service_.Search( | 286 fake_service_.Search( |
287 "File", // search_query | 287 "File", // search_query |
288 test_util::CreateCopyResultCallback(&error, &resource_list)); | 288 test_util::CreateCopyResultCallback(&error, &resource_list)); |
289 base::RunLoop().RunUntilIdle(); | 289 base::RunLoop().RunUntilIdle(); |
290 | 290 |
291 EXPECT_EQ(HTTP_SUCCESS, error); | 291 EXPECT_EQ(HTTP_SUCCESS, error); |
292 ASSERT_TRUE(resource_list); | 292 ASSERT_TRUE(resource_list); |
293 // Do some sanity check. There are 4 entries that contain "File" in their | 293 // Do some sanity check. There are 4 entries that contain "File" in their |
294 // titles and one of them is deleted. | 294 // titles and one of them is deleted. |
295 EXPECT_EQ(3U, resource_list->entries().size()); | 295 EXPECT_EQ(3U, resource_list->entries().size()); |
296 } | 296 } |
297 | 297 |
298 TEST_F(FakeDriveServiceTest, Search_Trashed) { | 298 TEST_F(FakeDriveServiceTest, Search_Trashed) { |
299 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 299 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
300 "gdata/root_feed.json")); | |
301 | 300 |
302 GDataErrorCode error = GDATA_OTHER_ERROR; | 301 GDataErrorCode error = GDATA_OTHER_ERROR; |
303 fake_service_.TrashResource("file:2_file_resource_id", | 302 fake_service_.TrashResource("file:2_file_resource_id", |
304 test_util::CreateCopyResultCallback(&error)); | 303 test_util::CreateCopyResultCallback(&error)); |
305 base::RunLoop().RunUntilIdle(); | 304 base::RunLoop().RunUntilIdle(); |
306 EXPECT_EQ(HTTP_SUCCESS, error); | 305 EXPECT_EQ(HTTP_SUCCESS, error); |
307 | 306 |
308 error = GDATA_OTHER_ERROR; | 307 error = GDATA_OTHER_ERROR; |
309 scoped_ptr<ResourceList> resource_list; | 308 scoped_ptr<ResourceList> resource_list; |
310 fake_service_.Search( | 309 fake_service_.Search( |
311 "File", // search_query | 310 "File", // search_query |
312 test_util::CreateCopyResultCallback(&error, &resource_list)); | 311 test_util::CreateCopyResultCallback(&error, &resource_list)); |
313 base::RunLoop().RunUntilIdle(); | 312 base::RunLoop().RunUntilIdle(); |
314 | 313 |
315 EXPECT_EQ(HTTP_SUCCESS, error); | 314 EXPECT_EQ(HTTP_SUCCESS, error); |
316 ASSERT_TRUE(resource_list); | 315 ASSERT_TRUE(resource_list); |
317 // Do some sanity check. There are 4 entries that contain "File" in their | 316 // Do some sanity check. There are 4 entries that contain "File" in their |
318 // titles and one of them is deleted. | 317 // titles and one of them is deleted. |
319 EXPECT_EQ(3U, resource_list->entries().size()); | 318 EXPECT_EQ(3U, resource_list->entries().size()); |
320 } | 319 } |
321 | 320 |
322 TEST_F(FakeDriveServiceTest, SearchByTitle) { | 321 TEST_F(FakeDriveServiceTest, SearchByTitle) { |
323 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 322 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
324 "gdata/root_feed.json")); | |
325 | 323 |
326 GDataErrorCode error = GDATA_OTHER_ERROR; | 324 GDataErrorCode error = GDATA_OTHER_ERROR; |
327 scoped_ptr<ResourceList> resource_list; | 325 scoped_ptr<ResourceList> resource_list; |
328 fake_service_.SearchByTitle( | 326 fake_service_.SearchByTitle( |
329 "1.txt", // title | 327 "1.txt", // title |
330 fake_service_.GetRootResourceId(), // directory_resource_id | 328 fake_service_.GetRootResourceId(), // directory_resource_id |
331 test_util::CreateCopyResultCallback(&error, &resource_list)); | 329 test_util::CreateCopyResultCallback(&error, &resource_list)); |
332 base::RunLoop().RunUntilIdle(); | 330 base::RunLoop().RunUntilIdle(); |
333 | 331 |
334 EXPECT_EQ(HTTP_SUCCESS, error); | 332 EXPECT_EQ(HTTP_SUCCESS, error); |
335 ASSERT_TRUE(resource_list); | 333 ASSERT_TRUE(resource_list); |
336 // Do some sanity check. There are 2 entries that contain "1.txt" in their | 334 // Do some sanity check. There are 2 entries that contain "1.txt" in their |
337 // titles directly under the root directory. | 335 // titles directly under the root directory. |
338 EXPECT_EQ(2U, resource_list->entries().size()); | 336 EXPECT_EQ(2U, resource_list->entries().size()); |
339 } | 337 } |
340 | 338 |
341 TEST_F(FakeDriveServiceTest, SearchByTitle_EmptyDirectoryResourceId) { | 339 TEST_F(FakeDriveServiceTest, SearchByTitle_EmptyDirectoryResourceId) { |
342 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 340 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
343 "gdata/root_feed.json")); | |
344 | 341 |
345 GDataErrorCode error = GDATA_OTHER_ERROR; | 342 GDataErrorCode error = GDATA_OTHER_ERROR; |
346 scoped_ptr<ResourceList> resource_list; | 343 scoped_ptr<ResourceList> resource_list; |
347 fake_service_.SearchByTitle( | 344 fake_service_.SearchByTitle( |
348 "1.txt", // title | 345 "1.txt", // title |
349 "", // directory resource id | 346 "", // directory resource id |
350 test_util::CreateCopyResultCallback(&error, &resource_list)); | 347 test_util::CreateCopyResultCallback(&error, &resource_list)); |
351 base::RunLoop().RunUntilIdle(); | 348 base::RunLoop().RunUntilIdle(); |
352 | 349 |
353 EXPECT_EQ(HTTP_SUCCESS, error); | 350 EXPECT_EQ(HTTP_SUCCESS, error); |
354 ASSERT_TRUE(resource_list); | 351 ASSERT_TRUE(resource_list); |
355 // Do some sanity check. There are 4 entries that contain "1.txt" in their | 352 // Do some sanity check. There are 4 entries that contain "1.txt" in their |
356 // titles. | 353 // titles. |
357 EXPECT_EQ(4U, resource_list->entries().size()); | 354 EXPECT_EQ(4U, resource_list->entries().size()); |
358 } | 355 } |
359 | 356 |
360 TEST_F(FakeDriveServiceTest, SearchByTitle_Offline) { | 357 TEST_F(FakeDriveServiceTest, SearchByTitle_Offline) { |
361 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 358 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
362 "gdata/root_feed.json")); | |
363 fake_service_.set_offline(true); | 359 fake_service_.set_offline(true); |
364 | 360 |
365 GDataErrorCode error = GDATA_OTHER_ERROR; | 361 GDataErrorCode error = GDATA_OTHER_ERROR; |
366 scoped_ptr<ResourceList> resource_list; | 362 scoped_ptr<ResourceList> resource_list; |
367 fake_service_.SearchByTitle( | 363 fake_service_.SearchByTitle( |
368 "Directory 1", // title | 364 "Directory 1", // title |
369 fake_service_.GetRootResourceId(), // directory_resource_id | 365 fake_service_.GetRootResourceId(), // directory_resource_id |
370 test_util::CreateCopyResultCallback(&error, &resource_list)); | 366 test_util::CreateCopyResultCallback(&error, &resource_list)); |
371 base::RunLoop().RunUntilIdle(); | 367 base::RunLoop().RunUntilIdle(); |
372 | 368 |
373 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 369 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
374 EXPECT_FALSE(resource_list); | 370 EXPECT_FALSE(resource_list); |
375 } | 371 } |
376 | 372 |
377 TEST_F(FakeDriveServiceTest, GetChangeList_NoNewEntries) { | 373 TEST_F(FakeDriveServiceTest, GetChangeList_NoNewEntries) { |
378 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 374 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
379 "gdata/root_feed.json")); | |
380 | 375 |
381 GDataErrorCode error = GDATA_OTHER_ERROR; | 376 GDataErrorCode error = GDATA_OTHER_ERROR; |
382 scoped_ptr<ResourceList> resource_list; | 377 scoped_ptr<ResourceList> resource_list; |
383 fake_service_.GetChangeList( | 378 fake_service_.GetChangeList( |
384 fake_service_.about_resource().largest_change_id() + 1, | 379 fake_service_.about_resource().largest_change_id() + 1, |
385 test_util::CreateCopyResultCallback(&error, &resource_list)); | 380 test_util::CreateCopyResultCallback(&error, &resource_list)); |
386 base::RunLoop().RunUntilIdle(); | 381 base::RunLoop().RunUntilIdle(); |
387 | 382 |
388 EXPECT_EQ(HTTP_SUCCESS, error); | 383 EXPECT_EQ(HTTP_SUCCESS, error); |
389 ASSERT_TRUE(resource_list); | 384 ASSERT_TRUE(resource_list); |
390 EXPECT_EQ(fake_service_.about_resource().largest_change_id(), | 385 EXPECT_EQ(fake_service_.about_resource().largest_change_id(), |
391 resource_list->largest_changestamp()); | 386 resource_list->largest_changestamp()); |
392 // This should be empty as the latest changestamp was passed to | 387 // This should be empty as the latest changestamp was passed to |
393 // GetResourceList(), hence there should be no new entries. | 388 // GetResourceList(), hence there should be no new entries. |
394 EXPECT_EQ(0U, resource_list->entries().size()); | 389 EXPECT_EQ(0U, resource_list->entries().size()); |
395 // It's considered loaded even if the result is empty. | 390 // It's considered loaded even if the result is empty. |
396 EXPECT_EQ(1, fake_service_.change_list_load_count()); | 391 EXPECT_EQ(1, fake_service_.change_list_load_count()); |
397 } | 392 } |
398 | 393 |
399 TEST_F(FakeDriveServiceTest, GetChangeList_WithNewEntry) { | 394 TEST_F(FakeDriveServiceTest, GetChangeList_WithNewEntry) { |
400 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 395 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
401 "gdata/root_feed.json")); | |
402 const int64 old_largest_change_id = | 396 const int64 old_largest_change_id = |
403 fake_service_.about_resource().largest_change_id(); | 397 fake_service_.about_resource().largest_change_id(); |
404 | 398 |
405 // Add a new directory in the root directory. | 399 // Add a new directory in the root directory. |
406 ASSERT_TRUE(AddNewDirectory( | 400 ASSERT_TRUE(AddNewDirectory( |
407 fake_service_.GetRootResourceId(), "new directory")); | 401 fake_service_.GetRootResourceId(), "new directory")); |
408 | 402 |
409 // Get the resource list newer than old_largest_change_id. | 403 // Get the resource list newer than old_largest_change_id. |
410 GDataErrorCode error = GDATA_OTHER_ERROR; | 404 GDataErrorCode error = GDATA_OTHER_ERROR; |
411 scoped_ptr<ResourceList> resource_list; | 405 scoped_ptr<ResourceList> resource_list; |
412 fake_service_.GetChangeList( | 406 fake_service_.GetChangeList( |
413 old_largest_change_id + 1, | 407 old_largest_change_id + 1, |
414 test_util::CreateCopyResultCallback(&error, &resource_list)); | 408 test_util::CreateCopyResultCallback(&error, &resource_list)); |
415 base::RunLoop().RunUntilIdle(); | 409 base::RunLoop().RunUntilIdle(); |
416 | 410 |
417 EXPECT_EQ(HTTP_SUCCESS, error); | 411 EXPECT_EQ(HTTP_SUCCESS, error); |
418 ASSERT_TRUE(resource_list); | 412 ASSERT_TRUE(resource_list); |
419 EXPECT_EQ(fake_service_.about_resource().largest_change_id(), | 413 EXPECT_EQ(fake_service_.about_resource().largest_change_id(), |
420 resource_list->largest_changestamp()); | 414 resource_list->largest_changestamp()); |
421 // The result should only contain the newly created directory. | 415 // The result should only contain the newly created directory. |
422 ASSERT_EQ(1U, resource_list->entries().size()); | 416 ASSERT_EQ(1U, resource_list->entries().size()); |
423 EXPECT_EQ("new directory", resource_list->entries()[0]->title()); | 417 EXPECT_EQ("new directory", resource_list->entries()[0]->title()); |
424 EXPECT_EQ(1, fake_service_.change_list_load_count()); | 418 EXPECT_EQ(1, fake_service_.change_list_load_count()); |
425 } | 419 } |
426 | 420 |
427 TEST_F(FakeDriveServiceTest, GetChangeList_Offline) { | 421 TEST_F(FakeDriveServiceTest, GetChangeList_Offline) { |
428 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 422 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
429 "gdata/root_feed.json")); | |
430 fake_service_.set_offline(true); | 423 fake_service_.set_offline(true); |
431 | 424 |
432 GDataErrorCode error = GDATA_OTHER_ERROR; | 425 GDataErrorCode error = GDATA_OTHER_ERROR; |
433 scoped_ptr<ResourceList> resource_list; | 426 scoped_ptr<ResourceList> resource_list; |
434 fake_service_.GetChangeList( | 427 fake_service_.GetChangeList( |
435 654321, // start_changestamp | 428 654321, // start_changestamp |
436 test_util::CreateCopyResultCallback(&error, &resource_list)); | 429 test_util::CreateCopyResultCallback(&error, &resource_list)); |
437 base::RunLoop().RunUntilIdle(); | 430 base::RunLoop().RunUntilIdle(); |
438 | 431 |
439 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 432 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
440 EXPECT_FALSE(resource_list); | 433 EXPECT_FALSE(resource_list); |
441 } | 434 } |
442 | 435 |
443 TEST_F(FakeDriveServiceTest, GetChangeList_DeletedEntry) { | 436 TEST_F(FakeDriveServiceTest, GetChangeList_DeletedEntry) { |
444 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 437 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
445 "gdata/root_feed.json")); | |
446 ASSERT_TRUE(Exists("file:2_file_resource_id")); | 438 ASSERT_TRUE(Exists("file:2_file_resource_id")); |
447 const int64 old_largest_change_id = | 439 const int64 old_largest_change_id = |
448 fake_service_.about_resource().largest_change_id(); | 440 fake_service_.about_resource().largest_change_id(); |
449 | 441 |
450 GDataErrorCode error = GDATA_OTHER_ERROR; | 442 GDataErrorCode error = GDATA_OTHER_ERROR; |
451 fake_service_.DeleteResource("file:2_file_resource_id", | 443 fake_service_.DeleteResource("file:2_file_resource_id", |
452 std::string(), // etag | 444 std::string(), // etag |
453 test_util::CreateCopyResultCallback(&error)); | 445 test_util::CreateCopyResultCallback(&error)); |
454 base::RunLoop().RunUntilIdle(); | 446 base::RunLoop().RunUntilIdle(); |
455 ASSERT_EQ(HTTP_NO_CONTENT, error); | 447 ASSERT_EQ(HTTP_NO_CONTENT, error); |
(...skipping 14 matching lines...) Expand all Loading... |
470 // The result should only contain the deleted file. | 462 // The result should only contain the deleted file. |
471 ASSERT_EQ(1U, resource_list->entries().size()); | 463 ASSERT_EQ(1U, resource_list->entries().size()); |
472 const ResourceEntry& entry = *resource_list->entries()[0]; | 464 const ResourceEntry& entry = *resource_list->entries()[0]; |
473 EXPECT_EQ("file:2_file_resource_id", entry.resource_id()); | 465 EXPECT_EQ("file:2_file_resource_id", entry.resource_id()); |
474 EXPECT_TRUE(entry.title().empty()); | 466 EXPECT_TRUE(entry.title().empty()); |
475 EXPECT_TRUE(entry.deleted()); | 467 EXPECT_TRUE(entry.deleted()); |
476 EXPECT_EQ(1, fake_service_.change_list_load_count()); | 468 EXPECT_EQ(1, fake_service_.change_list_load_count()); |
477 } | 469 } |
478 | 470 |
479 TEST_F(FakeDriveServiceTest, GetChangeList_TrashedEntry) { | 471 TEST_F(FakeDriveServiceTest, GetChangeList_TrashedEntry) { |
480 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 472 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
481 "gdata/root_feed.json")); | |
482 ASSERT_TRUE(Exists("file:2_file_resource_id")); | 473 ASSERT_TRUE(Exists("file:2_file_resource_id")); |
483 const int64 old_largest_change_id = | 474 const int64 old_largest_change_id = |
484 fake_service_.about_resource().largest_change_id(); | 475 fake_service_.about_resource().largest_change_id(); |
485 | 476 |
486 GDataErrorCode error = GDATA_OTHER_ERROR; | 477 GDataErrorCode error = GDATA_OTHER_ERROR; |
487 fake_service_.TrashResource("file:2_file_resource_id", | 478 fake_service_.TrashResource("file:2_file_resource_id", |
488 test_util::CreateCopyResultCallback(&error)); | 479 test_util::CreateCopyResultCallback(&error)); |
489 base::RunLoop().RunUntilIdle(); | 480 base::RunLoop().RunUntilIdle(); |
490 ASSERT_EQ(HTTP_SUCCESS, error); | 481 ASSERT_EQ(HTTP_SUCCESS, error); |
491 ASSERT_FALSE(Exists("file:2_file_resource_id")); | 482 ASSERT_FALSE(Exists("file:2_file_resource_id")); |
(...skipping 12 matching lines...) Expand all Loading... |
504 resource_list->largest_changestamp()); | 495 resource_list->largest_changestamp()); |
505 // The result should only contain the trashed file. | 496 // The result should only contain the trashed file. |
506 ASSERT_EQ(1U, resource_list->entries().size()); | 497 ASSERT_EQ(1U, resource_list->entries().size()); |
507 const ResourceEntry& entry = *resource_list->entries()[0]; | 498 const ResourceEntry& entry = *resource_list->entries()[0]; |
508 EXPECT_EQ("file:2_file_resource_id", entry.resource_id()); | 499 EXPECT_EQ("file:2_file_resource_id", entry.resource_id()); |
509 EXPECT_TRUE(entry.deleted()); | 500 EXPECT_TRUE(entry.deleted()); |
510 EXPECT_EQ(1, fake_service_.change_list_load_count()); | 501 EXPECT_EQ(1, fake_service_.change_list_load_count()); |
511 } | 502 } |
512 | 503 |
513 TEST_F(FakeDriveServiceTest, GetRemainingChangeList_GetAllResourceList) { | 504 TEST_F(FakeDriveServiceTest, GetRemainingChangeList_GetAllResourceList) { |
514 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 505 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
515 "gdata/root_feed.json")); | |
516 fake_service_.set_default_max_results(6); | 506 fake_service_.set_default_max_results(6); |
517 | 507 |
518 GDataErrorCode error = GDATA_OTHER_ERROR; | 508 GDataErrorCode error = GDATA_OTHER_ERROR; |
519 scoped_ptr<ResourceList> resource_list; | 509 scoped_ptr<ResourceList> resource_list; |
520 fake_service_.GetAllResourceList( | 510 fake_service_.GetAllResourceList( |
521 test_util::CreateCopyResultCallback(&error, &resource_list)); | 511 test_util::CreateCopyResultCallback(&error, &resource_list)); |
522 base::RunLoop().RunUntilIdle(); | 512 base::RunLoop().RunUntilIdle(); |
523 EXPECT_EQ(HTTP_SUCCESS, error); | 513 EXPECT_EQ(HTTP_SUCCESS, error); |
524 ASSERT_TRUE(resource_list); | 514 ASSERT_TRUE(resource_list); |
525 | 515 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 | 553 |
564 EXPECT_EQ(HTTP_SUCCESS, error); | 554 EXPECT_EQ(HTTP_SUCCESS, error); |
565 ASSERT_TRUE(resource_list); | 555 ASSERT_TRUE(resource_list); |
566 | 556 |
567 EXPECT_EQ(3U, resource_list->entries().size()); | 557 EXPECT_EQ(3U, resource_list->entries().size()); |
568 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 558 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
569 } | 559 } |
570 | 560 |
571 TEST_F(FakeDriveServiceTest, | 561 TEST_F(FakeDriveServiceTest, |
572 GetRemainingFileList_GetResourceListInDirectory) { | 562 GetRemainingFileList_GetResourceListInDirectory) { |
573 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 563 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
574 "gdata/root_feed.json")); | |
575 fake_service_.set_default_max_results(3); | 564 fake_service_.set_default_max_results(3); |
576 | 565 |
577 GDataErrorCode error = GDATA_OTHER_ERROR; | 566 GDataErrorCode error = GDATA_OTHER_ERROR; |
578 scoped_ptr<ResourceList> resource_list; | 567 scoped_ptr<ResourceList> resource_list; |
579 fake_service_.GetResourceListInDirectory( | 568 fake_service_.GetResourceListInDirectory( |
580 fake_service_.GetRootResourceId(), | 569 fake_service_.GetRootResourceId(), |
581 test_util::CreateCopyResultCallback(&error, &resource_list)); | 570 test_util::CreateCopyResultCallback(&error, &resource_list)); |
582 base::RunLoop().RunUntilIdle(); | 571 base::RunLoop().RunUntilIdle(); |
583 EXPECT_EQ(HTTP_SUCCESS, error); | 572 EXPECT_EQ(HTTP_SUCCESS, error); |
584 ASSERT_TRUE(resource_list); | 573 ASSERT_TRUE(resource_list); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 base::RunLoop().RunUntilIdle(); | 611 base::RunLoop().RunUntilIdle(); |
623 | 612 |
624 EXPECT_EQ(HTTP_SUCCESS, error); | 613 EXPECT_EQ(HTTP_SUCCESS, error); |
625 ASSERT_TRUE(resource_list); | 614 ASSERT_TRUE(resource_list); |
626 | 615 |
627 EXPECT_EQ(2U, resource_list->entries().size()); | 616 EXPECT_EQ(2U, resource_list->entries().size()); |
628 EXPECT_EQ(1, fake_service_.directory_load_count()); | 617 EXPECT_EQ(1, fake_service_.directory_load_count()); |
629 } | 618 } |
630 | 619 |
631 TEST_F(FakeDriveServiceTest, GetRemainingFileList_Search) { | 620 TEST_F(FakeDriveServiceTest, GetRemainingFileList_Search) { |
632 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 621 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
633 "gdata/root_feed.json")); | |
634 fake_service_.set_default_max_results(2); | 622 fake_service_.set_default_max_results(2); |
635 | 623 |
636 GDataErrorCode error = GDATA_OTHER_ERROR; | 624 GDataErrorCode error = GDATA_OTHER_ERROR; |
637 scoped_ptr<ResourceList> resource_list; | 625 scoped_ptr<ResourceList> resource_list; |
638 fake_service_.Search( | 626 fake_service_.Search( |
639 "File", // search_query | 627 "File", // search_query |
640 test_util::CreateCopyResultCallback(&error, &resource_list)); | 628 test_util::CreateCopyResultCallback(&error, &resource_list)); |
641 base::RunLoop().RunUntilIdle(); | 629 base::RunLoop().RunUntilIdle(); |
642 EXPECT_EQ(HTTP_SUCCESS, error); | 630 EXPECT_EQ(HTTP_SUCCESS, error); |
643 ASSERT_TRUE(resource_list); | 631 ASSERT_TRUE(resource_list); |
(...skipping 17 matching lines...) Expand all Loading... |
661 test_util::CreateCopyResultCallback(&error, &resource_list)); | 649 test_util::CreateCopyResultCallback(&error, &resource_list)); |
662 base::RunLoop().RunUntilIdle(); | 650 base::RunLoop().RunUntilIdle(); |
663 | 651 |
664 EXPECT_EQ(HTTP_SUCCESS, error); | 652 EXPECT_EQ(HTTP_SUCCESS, error); |
665 ASSERT_TRUE(resource_list); | 653 ASSERT_TRUE(resource_list); |
666 | 654 |
667 EXPECT_EQ(2U, resource_list->entries().size()); | 655 EXPECT_EQ(2U, resource_list->entries().size()); |
668 } | 656 } |
669 | 657 |
670 TEST_F(FakeDriveServiceTest, GetRemainingChangeList_GetChangeList) { | 658 TEST_F(FakeDriveServiceTest, GetRemainingChangeList_GetChangeList) { |
671 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 659 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
672 "gdata/root_feed.json")); | |
673 fake_service_.set_default_max_results(2); | 660 fake_service_.set_default_max_results(2); |
674 const int64 old_largest_change_id = | 661 const int64 old_largest_change_id = |
675 fake_service_.about_resource().largest_change_id(); | 662 fake_service_.about_resource().largest_change_id(); |
676 | 663 |
677 // Add 5 new directory in the root directory. | 664 // Add 5 new directory in the root directory. |
678 for (int i = 0; i < 5; ++i) { | 665 for (int i = 0; i < 5; ++i) { |
679 ASSERT_TRUE(AddNewDirectory( | 666 ASSERT_TRUE(AddNewDirectory( |
680 fake_service_.GetRootResourceId(), | 667 fake_service_.GetRootResourceId(), |
681 base::StringPrintf("new directory %d", i))); | 668 base::StringPrintf("new directory %d", i))); |
682 } | 669 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 scoped_ptr<AppList> app_list; | 776 scoped_ptr<AppList> app_list; |
790 fake_service_.GetAppList( | 777 fake_service_.GetAppList( |
791 test_util::CreateCopyResultCallback(&error, &app_list)); | 778 test_util::CreateCopyResultCallback(&error, &app_list)); |
792 base::RunLoop().RunUntilIdle(); | 779 base::RunLoop().RunUntilIdle(); |
793 | 780 |
794 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 781 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
795 EXPECT_FALSE(app_list); | 782 EXPECT_FALSE(app_list); |
796 } | 783 } |
797 | 784 |
798 TEST_F(FakeDriveServiceTest, GetResourceEntry_ExistingFile) { | 785 TEST_F(FakeDriveServiceTest, GetResourceEntry_ExistingFile) { |
799 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 786 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
800 "gdata/root_feed.json")); | |
801 | 787 |
802 const std::string kResourceId = "file:2_file_resource_id"; | 788 const std::string kResourceId = "file:2_file_resource_id"; |
803 GDataErrorCode error = GDATA_OTHER_ERROR; | 789 GDataErrorCode error = GDATA_OTHER_ERROR; |
804 scoped_ptr<ResourceEntry> resource_entry; | 790 scoped_ptr<ResourceEntry> resource_entry; |
805 fake_service_.GetResourceEntry( | 791 fake_service_.GetResourceEntry( |
806 kResourceId, | 792 kResourceId, |
807 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 793 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
808 base::RunLoop().RunUntilIdle(); | 794 base::RunLoop().RunUntilIdle(); |
809 | 795 |
810 EXPECT_EQ(HTTP_SUCCESS, error); | 796 EXPECT_EQ(HTTP_SUCCESS, error); |
811 ASSERT_TRUE(resource_entry); | 797 ASSERT_TRUE(resource_entry); |
812 // Do some sanity check. | 798 // Do some sanity check. |
813 EXPECT_EQ(kResourceId, resource_entry->resource_id()); | 799 EXPECT_EQ(kResourceId, resource_entry->resource_id()); |
814 } | 800 } |
815 | 801 |
816 TEST_F(FakeDriveServiceTest, GetResourceEntry_NonexistingFile) { | 802 TEST_F(FakeDriveServiceTest, GetResourceEntry_NonexistingFile) { |
817 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 803 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
818 "gdata/root_feed.json")); | |
819 | 804 |
820 const std::string kResourceId = "file:nonexisting_resource_id"; | 805 const std::string kResourceId = "file:nonexisting_resource_id"; |
821 GDataErrorCode error = GDATA_OTHER_ERROR; | 806 GDataErrorCode error = GDATA_OTHER_ERROR; |
822 scoped_ptr<ResourceEntry> resource_entry; | 807 scoped_ptr<ResourceEntry> resource_entry; |
823 fake_service_.GetResourceEntry( | 808 fake_service_.GetResourceEntry( |
824 kResourceId, | 809 kResourceId, |
825 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 810 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
826 base::RunLoop().RunUntilIdle(); | 811 base::RunLoop().RunUntilIdle(); |
827 | 812 |
828 EXPECT_EQ(HTTP_NOT_FOUND, error); | 813 EXPECT_EQ(HTTP_NOT_FOUND, error); |
829 ASSERT_FALSE(resource_entry); | 814 ASSERT_FALSE(resource_entry); |
830 } | 815 } |
831 | 816 |
832 TEST_F(FakeDriveServiceTest, GetResourceEntry_Offline) { | 817 TEST_F(FakeDriveServiceTest, GetResourceEntry_Offline) { |
833 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 818 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
834 "gdata/root_feed.json")); | |
835 fake_service_.set_offline(true); | 819 fake_service_.set_offline(true); |
836 | 820 |
837 const std::string kResourceId = "file:2_file_resource_id"; | 821 const std::string kResourceId = "file:2_file_resource_id"; |
838 GDataErrorCode error = GDATA_OTHER_ERROR; | 822 GDataErrorCode error = GDATA_OTHER_ERROR; |
839 scoped_ptr<ResourceEntry> resource_entry; | 823 scoped_ptr<ResourceEntry> resource_entry; |
840 fake_service_.GetResourceEntry( | 824 fake_service_.GetResourceEntry( |
841 kResourceId, | 825 kResourceId, |
842 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 826 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
843 base::RunLoop().RunUntilIdle(); | 827 base::RunLoop().RunUntilIdle(); |
844 | 828 |
845 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 829 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
846 EXPECT_FALSE(resource_entry); | 830 EXPECT_FALSE(resource_entry); |
847 } | 831 } |
848 | 832 |
849 TEST_F(FakeDriveServiceTest, GetShareUrl) { | 833 TEST_F(FakeDriveServiceTest, GetShareUrl) { |
850 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 834 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
851 "gdata/root_feed.json")); | |
852 | 835 |
853 const std::string kResourceId = "file:2_file_resource_id"; | 836 const std::string kResourceId = "file:2_file_resource_id"; |
854 GDataErrorCode error = GDATA_OTHER_ERROR; | 837 GDataErrorCode error = GDATA_OTHER_ERROR; |
855 GURL share_url; | 838 GURL share_url; |
856 fake_service_.GetShareUrl( | 839 fake_service_.GetShareUrl( |
857 kResourceId, | 840 kResourceId, |
858 GURL(), // embed origin | 841 GURL(), // embed origin |
859 test_util::CreateCopyResultCallback(&error, &share_url)); | 842 test_util::CreateCopyResultCallback(&error, &share_url)); |
860 base::RunLoop().RunUntilIdle(); | 843 base::RunLoop().RunUntilIdle(); |
861 | 844 |
862 EXPECT_EQ(HTTP_SUCCESS, error); | 845 EXPECT_EQ(HTTP_SUCCESS, error); |
863 EXPECT_FALSE(share_url.is_empty()); | 846 EXPECT_FALSE(share_url.is_empty()); |
864 } | 847 } |
865 | 848 |
866 TEST_F(FakeDriveServiceTest, DeleteResource_ExistingFile) { | 849 TEST_F(FakeDriveServiceTest, DeleteResource_ExistingFile) { |
867 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 850 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
868 "gdata/root_feed.json")); | |
869 | 851 |
870 // Resource "file:2_file_resource_id" should now exist. | 852 // Resource "file:2_file_resource_id" should now exist. |
871 ASSERT_TRUE(Exists("file:2_file_resource_id")); | 853 ASSERT_TRUE(Exists("file:2_file_resource_id")); |
872 | 854 |
873 GDataErrorCode error = GDATA_OTHER_ERROR; | 855 GDataErrorCode error = GDATA_OTHER_ERROR; |
874 fake_service_.DeleteResource("file:2_file_resource_id", | 856 fake_service_.DeleteResource("file:2_file_resource_id", |
875 std::string(), // etag | 857 std::string(), // etag |
876 test_util::CreateCopyResultCallback(&error)); | 858 test_util::CreateCopyResultCallback(&error)); |
877 base::RunLoop().RunUntilIdle(); | 859 base::RunLoop().RunUntilIdle(); |
878 | 860 |
879 EXPECT_EQ(HTTP_NO_CONTENT, error); | 861 EXPECT_EQ(HTTP_NO_CONTENT, error); |
880 // Resource "file:2_file_resource_id" should be gone now. | 862 // Resource "file:2_file_resource_id" should be gone now. |
881 EXPECT_FALSE(Exists("file:2_file_resource_id")); | 863 EXPECT_FALSE(Exists("file:2_file_resource_id")); |
882 | 864 |
883 error = GDATA_OTHER_ERROR; | 865 error = GDATA_OTHER_ERROR; |
884 fake_service_.DeleteResource("file:2_file_resource_id", | 866 fake_service_.DeleteResource("file:2_file_resource_id", |
885 std::string(), // etag | 867 std::string(), // etag |
886 test_util::CreateCopyResultCallback(&error)); | 868 test_util::CreateCopyResultCallback(&error)); |
887 base::RunLoop().RunUntilIdle(); | 869 base::RunLoop().RunUntilIdle(); |
888 EXPECT_EQ(HTTP_NOT_FOUND, error); | 870 EXPECT_EQ(HTTP_NOT_FOUND, error); |
889 EXPECT_FALSE(Exists("file:2_file_resource_id")); | 871 EXPECT_FALSE(Exists("file:2_file_resource_id")); |
890 } | 872 } |
891 | 873 |
892 TEST_F(FakeDriveServiceTest, DeleteResource_NonexistingFile) { | 874 TEST_F(FakeDriveServiceTest, DeleteResource_NonexistingFile) { |
893 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 875 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
894 "gdata/root_feed.json")); | |
895 | 876 |
896 GDataErrorCode error = GDATA_OTHER_ERROR; | 877 GDataErrorCode error = GDATA_OTHER_ERROR; |
897 fake_service_.DeleteResource("file:nonexisting_resource_id", | 878 fake_service_.DeleteResource("file:nonexisting_resource_id", |
898 std::string(), // etag | 879 std::string(), // etag |
899 test_util::CreateCopyResultCallback(&error)); | 880 test_util::CreateCopyResultCallback(&error)); |
900 base::RunLoop().RunUntilIdle(); | 881 base::RunLoop().RunUntilIdle(); |
901 | 882 |
902 EXPECT_EQ(HTTP_NOT_FOUND, error); | 883 EXPECT_EQ(HTTP_NOT_FOUND, error); |
903 } | 884 } |
904 | 885 |
905 TEST_F(FakeDriveServiceTest, DeleteResource_ETagMatch) { | 886 TEST_F(FakeDriveServiceTest, DeleteResource_ETagMatch) { |
906 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 887 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
907 "gdata/root_feed.json")); | |
908 | 888 |
909 // Resource "file:2_file_resource_id" should now exist. | 889 // Resource "file:2_file_resource_id" should now exist. |
910 scoped_ptr<ResourceEntry> entry = FindEntry("file:2_file_resource_id"); | 890 scoped_ptr<ResourceEntry> entry = FindEntry("file:2_file_resource_id"); |
911 ASSERT_TRUE(entry); | 891 ASSERT_TRUE(entry); |
912 ASSERT_FALSE(entry->deleted()); | 892 ASSERT_FALSE(entry->deleted()); |
913 ASSERT_FALSE(entry->etag().empty()); | 893 ASSERT_FALSE(entry->etag().empty()); |
914 | 894 |
915 GDataErrorCode error = GDATA_OTHER_ERROR; | 895 GDataErrorCode error = GDATA_OTHER_ERROR; |
916 fake_service_.DeleteResource("file:2_file_resource_id", | 896 fake_service_.DeleteResource("file:2_file_resource_id", |
917 entry->etag() + "_mismatch", | 897 entry->etag() + "_mismatch", |
918 test_util::CreateCopyResultCallback(&error)); | 898 test_util::CreateCopyResultCallback(&error)); |
919 base::RunLoop().RunUntilIdle(); | 899 base::RunLoop().RunUntilIdle(); |
920 | 900 |
921 EXPECT_EQ(HTTP_PRECONDITION, error); | 901 EXPECT_EQ(HTTP_PRECONDITION, error); |
922 // Resource "file:2_file_resource_id" should still exist. | 902 // Resource "file:2_file_resource_id" should still exist. |
923 EXPECT_TRUE(Exists("file:2_file_resource_id")); | 903 EXPECT_TRUE(Exists("file:2_file_resource_id")); |
924 | 904 |
925 error = GDATA_OTHER_ERROR; | 905 error = GDATA_OTHER_ERROR; |
926 fake_service_.DeleteResource("file:2_file_resource_id", | 906 fake_service_.DeleteResource("file:2_file_resource_id", |
927 entry->etag(), | 907 entry->etag(), |
928 test_util::CreateCopyResultCallback(&error)); | 908 test_util::CreateCopyResultCallback(&error)); |
929 base::RunLoop().RunUntilIdle(); | 909 base::RunLoop().RunUntilIdle(); |
930 EXPECT_EQ(HTTP_NO_CONTENT, error); | 910 EXPECT_EQ(HTTP_NO_CONTENT, error); |
931 // Resource "file:2_file_resource_id" should be gone now. | 911 // Resource "file:2_file_resource_id" should be gone now. |
932 EXPECT_FALSE(Exists("file:2_file_resource_id")); | 912 EXPECT_FALSE(Exists("file:2_file_resource_id")); |
933 } | 913 } |
934 | 914 |
935 TEST_F(FakeDriveServiceTest, DeleteResource_Offline) { | 915 TEST_F(FakeDriveServiceTest, DeleteResource_Offline) { |
936 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 916 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
937 "gdata/root_feed.json")); | |
938 fake_service_.set_offline(true); | 917 fake_service_.set_offline(true); |
939 | 918 |
940 GDataErrorCode error = GDATA_OTHER_ERROR; | 919 GDataErrorCode error = GDATA_OTHER_ERROR; |
941 fake_service_.DeleteResource("file:2_file_resource_id", | 920 fake_service_.DeleteResource("file:2_file_resource_id", |
942 std::string(), // etag | 921 std::string(), // etag |
943 test_util::CreateCopyResultCallback(&error)); | 922 test_util::CreateCopyResultCallback(&error)); |
944 base::RunLoop().RunUntilIdle(); | 923 base::RunLoop().RunUntilIdle(); |
945 | 924 |
946 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 925 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
947 } | 926 } |
948 | 927 |
949 TEST_F(FakeDriveServiceTest, TrashResource_ExistingFile) { | 928 TEST_F(FakeDriveServiceTest, TrashResource_ExistingFile) { |
950 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 929 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
951 "gdata/root_feed.json")); | |
952 | 930 |
953 // Resource "file:2_file_resource_id" should now exist. | 931 // Resource "file:2_file_resource_id" should now exist. |
954 ASSERT_TRUE(Exists("file:2_file_resource_id")); | 932 ASSERT_TRUE(Exists("file:2_file_resource_id")); |
955 | 933 |
956 GDataErrorCode error = GDATA_OTHER_ERROR; | 934 GDataErrorCode error = GDATA_OTHER_ERROR; |
957 fake_service_.TrashResource("file:2_file_resource_id", | 935 fake_service_.TrashResource("file:2_file_resource_id", |
958 test_util::CreateCopyResultCallback(&error)); | 936 test_util::CreateCopyResultCallback(&error)); |
959 base::RunLoop().RunUntilIdle(); | 937 base::RunLoop().RunUntilIdle(); |
960 | 938 |
961 EXPECT_EQ(HTTP_SUCCESS, error); | 939 EXPECT_EQ(HTTP_SUCCESS, error); |
962 // Resource "file:2_file_resource_id" should be gone now. | 940 // Resource "file:2_file_resource_id" should be gone now. |
963 EXPECT_FALSE(Exists("file:2_file_resource_id")); | 941 EXPECT_FALSE(Exists("file:2_file_resource_id")); |
964 | 942 |
965 error = GDATA_OTHER_ERROR; | 943 error = GDATA_OTHER_ERROR; |
966 fake_service_.TrashResource("file:2_file_resource_id", | 944 fake_service_.TrashResource("file:2_file_resource_id", |
967 test_util::CreateCopyResultCallback(&error)); | 945 test_util::CreateCopyResultCallback(&error)); |
968 base::RunLoop().RunUntilIdle(); | 946 base::RunLoop().RunUntilIdle(); |
969 EXPECT_EQ(HTTP_NOT_FOUND, error); | 947 EXPECT_EQ(HTTP_NOT_FOUND, error); |
970 EXPECT_FALSE(Exists("file:2_file_resource_id")); | 948 EXPECT_FALSE(Exists("file:2_file_resource_id")); |
971 } | 949 } |
972 | 950 |
973 TEST_F(FakeDriveServiceTest, TrashResource_NonexistingFile) { | 951 TEST_F(FakeDriveServiceTest, TrashResource_NonexistingFile) { |
974 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 952 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
975 "gdata/root_feed.json")); | |
976 | 953 |
977 GDataErrorCode error = GDATA_OTHER_ERROR; | 954 GDataErrorCode error = GDATA_OTHER_ERROR; |
978 fake_service_.TrashResource("file:nonexisting_resource_id", | 955 fake_service_.TrashResource("file:nonexisting_resource_id", |
979 test_util::CreateCopyResultCallback(&error)); | 956 test_util::CreateCopyResultCallback(&error)); |
980 base::RunLoop().RunUntilIdle(); | 957 base::RunLoop().RunUntilIdle(); |
981 | 958 |
982 EXPECT_EQ(HTTP_NOT_FOUND, error); | 959 EXPECT_EQ(HTTP_NOT_FOUND, error); |
983 } | 960 } |
984 | 961 |
985 TEST_F(FakeDriveServiceTest, TrashResource_Offline) { | 962 TEST_F(FakeDriveServiceTest, TrashResource_Offline) { |
986 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 963 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
987 "gdata/root_feed.json")); | |
988 fake_service_.set_offline(true); | 964 fake_service_.set_offline(true); |
989 | 965 |
990 GDataErrorCode error = GDATA_OTHER_ERROR; | 966 GDataErrorCode error = GDATA_OTHER_ERROR; |
991 fake_service_.TrashResource("file:2_file_resource_id", | 967 fake_service_.TrashResource("file:2_file_resource_id", |
992 test_util::CreateCopyResultCallback(&error)); | 968 test_util::CreateCopyResultCallback(&error)); |
993 base::RunLoop().RunUntilIdle(); | 969 base::RunLoop().RunUntilIdle(); |
994 | 970 |
995 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 971 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
996 } | 972 } |
997 | 973 |
998 TEST_F(FakeDriveServiceTest, DownloadFile_ExistingFile) { | 974 TEST_F(FakeDriveServiceTest, DownloadFile_ExistingFile) { |
999 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 975 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1000 "gdata/root_feed.json")); | |
1001 | 976 |
1002 base::ScopedTempDir temp_dir; | 977 base::ScopedTempDir temp_dir; |
1003 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 978 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1004 | 979 |
1005 std::vector<test_util::ProgressInfo> download_progress_values; | 980 std::vector<test_util::ProgressInfo> download_progress_values; |
1006 | 981 |
1007 const base::FilePath kOutputFilePath = | 982 const base::FilePath kOutputFilePath = |
1008 temp_dir.path().AppendASCII("whatever.txt"); | 983 temp_dir.path().AppendASCII("whatever.txt"); |
1009 GDataErrorCode error = GDATA_OTHER_ERROR; | 984 GDataErrorCode error = GDATA_OTHER_ERROR; |
1010 base::FilePath output_file_path; | 985 base::FilePath output_file_path; |
(...skipping 14 matching lines...) Expand all Loading... |
1025 // The content is "x"s of the file size specified in root_feed.json. | 1000 // The content is "x"s of the file size specified in root_feed.json. |
1026 EXPECT_EQ("This is some test content.", content); | 1001 EXPECT_EQ("This is some test content.", content); |
1027 ASSERT_TRUE(!download_progress_values.empty()); | 1002 ASSERT_TRUE(!download_progress_values.empty()); |
1028 EXPECT_TRUE(base::STLIsSorted(download_progress_values)); | 1003 EXPECT_TRUE(base::STLIsSorted(download_progress_values)); |
1029 EXPECT_LE(0, download_progress_values.front().first); | 1004 EXPECT_LE(0, download_progress_values.front().first); |
1030 EXPECT_GE(26, download_progress_values.back().first); | 1005 EXPECT_GE(26, download_progress_values.back().first); |
1031 EXPECT_EQ(content, get_content_callback.GetConcatenatedData()); | 1006 EXPECT_EQ(content, get_content_callback.GetConcatenatedData()); |
1032 } | 1007 } |
1033 | 1008 |
1034 TEST_F(FakeDriveServiceTest, DownloadFile_NonexistingFile) { | 1009 TEST_F(FakeDriveServiceTest, DownloadFile_NonexistingFile) { |
1035 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1010 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1036 "gdata/root_feed.json")); | |
1037 | 1011 |
1038 base::ScopedTempDir temp_dir; | 1012 base::ScopedTempDir temp_dir; |
1039 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1013 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1040 | 1014 |
1041 const base::FilePath kOutputFilePath = | 1015 const base::FilePath kOutputFilePath = |
1042 temp_dir.path().AppendASCII("whatever.txt"); | 1016 temp_dir.path().AppendASCII("whatever.txt"); |
1043 GDataErrorCode error = GDATA_OTHER_ERROR; | 1017 GDataErrorCode error = GDATA_OTHER_ERROR; |
1044 base::FilePath output_file_path; | 1018 base::FilePath output_file_path; |
1045 fake_service_.DownloadFile( | 1019 fake_service_.DownloadFile( |
1046 kOutputFilePath, | 1020 kOutputFilePath, |
1047 "file:non_existent_file_resource_id", | 1021 "file:non_existent_file_resource_id", |
1048 test_util::CreateCopyResultCallback(&error, &output_file_path), | 1022 test_util::CreateCopyResultCallback(&error, &output_file_path), |
1049 GetContentCallback(), | 1023 GetContentCallback(), |
1050 ProgressCallback()); | 1024 ProgressCallback()); |
1051 base::RunLoop().RunUntilIdle(); | 1025 base::RunLoop().RunUntilIdle(); |
1052 | 1026 |
1053 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1027 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1054 } | 1028 } |
1055 | 1029 |
1056 TEST_F(FakeDriveServiceTest, DownloadFile_Offline) { | 1030 TEST_F(FakeDriveServiceTest, DownloadFile_Offline) { |
1057 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1031 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1058 "gdata/root_feed.json")); | |
1059 fake_service_.set_offline(true); | 1032 fake_service_.set_offline(true); |
1060 | 1033 |
1061 base::ScopedTempDir temp_dir; | 1034 base::ScopedTempDir temp_dir; |
1062 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1035 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1063 | 1036 |
1064 const base::FilePath kOutputFilePath = | 1037 const base::FilePath kOutputFilePath = |
1065 temp_dir.path().AppendASCII("whatever.txt"); | 1038 temp_dir.path().AppendASCII("whatever.txt"); |
1066 GDataErrorCode error = GDATA_OTHER_ERROR; | 1039 GDataErrorCode error = GDATA_OTHER_ERROR; |
1067 base::FilePath output_file_path; | 1040 base::FilePath output_file_path; |
1068 fake_service_.DownloadFile( | 1041 fake_service_.DownloadFile( |
1069 kOutputFilePath, | 1042 kOutputFilePath, |
1070 "file:2_file_resource_id", | 1043 "file:2_file_resource_id", |
1071 test_util::CreateCopyResultCallback(&error, &output_file_path), | 1044 test_util::CreateCopyResultCallback(&error, &output_file_path), |
1072 GetContentCallback(), | 1045 GetContentCallback(), |
1073 ProgressCallback()); | 1046 ProgressCallback()); |
1074 base::RunLoop().RunUntilIdle(); | 1047 base::RunLoop().RunUntilIdle(); |
1075 | 1048 |
1076 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1049 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1077 } | 1050 } |
1078 | 1051 |
1079 TEST_F(FakeDriveServiceTest, CopyResource) { | 1052 TEST_F(FakeDriveServiceTest, CopyResource) { |
1080 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 1053 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
1081 | 1054 |
1082 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1055 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1083 "gdata/root_feed.json")); | |
1084 | 1056 |
1085 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1057 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1086 | 1058 |
1087 const std::string kResourceId = "file:2_file_resource_id"; | 1059 const std::string kResourceId = "file:2_file_resource_id"; |
1088 const std::string kParentResourceId = "folder:2_folder_resource_id"; | 1060 const std::string kParentResourceId = "folder:2_folder_resource_id"; |
1089 GDataErrorCode error = GDATA_OTHER_ERROR; | 1061 GDataErrorCode error = GDATA_OTHER_ERROR; |
1090 scoped_ptr<ResourceEntry> resource_entry; | 1062 scoped_ptr<ResourceEntry> resource_entry; |
1091 fake_service_.CopyResource( | 1063 fake_service_.CopyResource( |
1092 kResourceId, | 1064 kResourceId, |
1093 kParentResourceId, | 1065 kParentResourceId, |
(...skipping 10 matching lines...) Expand all Loading... |
1104 EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate), | 1076 EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate), |
1105 resource_entry->updated_time()); | 1077 resource_entry->updated_time()); |
1106 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId)); | 1078 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId)); |
1107 // Should be incremented as a new hosted document was created. | 1079 // Should be incremented as a new hosted document was created. |
1108 EXPECT_EQ(old_largest_change_id + 1, | 1080 EXPECT_EQ(old_largest_change_id + 1, |
1109 fake_service_.about_resource().largest_change_id()); | 1081 fake_service_.about_resource().largest_change_id()); |
1110 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1082 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1111 } | 1083 } |
1112 | 1084 |
1113 TEST_F(FakeDriveServiceTest, CopyResource_NonExisting) { | 1085 TEST_F(FakeDriveServiceTest, CopyResource_NonExisting) { |
1114 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1086 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1115 "gdata/root_feed.json")); | |
1116 | 1087 |
1117 const std::string kResourceId = "document:nonexisting_resource_id"; | 1088 const std::string kResourceId = "document:nonexisting_resource_id"; |
1118 GDataErrorCode error = GDATA_OTHER_ERROR; | 1089 GDataErrorCode error = GDATA_OTHER_ERROR; |
1119 scoped_ptr<ResourceEntry> resource_entry; | 1090 scoped_ptr<ResourceEntry> resource_entry; |
1120 fake_service_.CopyResource( | 1091 fake_service_.CopyResource( |
1121 kResourceId, | 1092 kResourceId, |
1122 "folder:1_folder_resource_id", | 1093 "folder:1_folder_resource_id", |
1123 "new title", | 1094 "new title", |
1124 base::Time(), | 1095 base::Time(), |
1125 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1096 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1126 base::RunLoop().RunUntilIdle(); | 1097 base::RunLoop().RunUntilIdle(); |
1127 | 1098 |
1128 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1099 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1129 } | 1100 } |
1130 | 1101 |
1131 TEST_F(FakeDriveServiceTest, CopyResource_EmptyParentResourceId) { | 1102 TEST_F(FakeDriveServiceTest, CopyResource_EmptyParentResourceId) { |
1132 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1103 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1133 "gdata/root_feed.json")); | |
1134 | 1104 |
1135 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1105 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1136 | 1106 |
1137 const std::string kResourceId = "file:2_file_resource_id"; | 1107 const std::string kResourceId = "file:2_file_resource_id"; |
1138 GDataErrorCode error = GDATA_OTHER_ERROR; | 1108 GDataErrorCode error = GDATA_OTHER_ERROR; |
1139 scoped_ptr<ResourceEntry> resource_entry; | 1109 scoped_ptr<ResourceEntry> resource_entry; |
1140 fake_service_.CopyResource( | 1110 fake_service_.CopyResource( |
1141 kResourceId, | 1111 kResourceId, |
1142 std::string(), | 1112 std::string(), |
1143 "new title", | 1113 "new title", |
1144 base::Time(), | 1114 base::Time(), |
1145 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1115 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1146 base::RunLoop().RunUntilIdle(); | 1116 base::RunLoop().RunUntilIdle(); |
1147 | 1117 |
1148 EXPECT_EQ(HTTP_SUCCESS, error); | 1118 EXPECT_EQ(HTTP_SUCCESS, error); |
1149 ASSERT_TRUE(resource_entry); | 1119 ASSERT_TRUE(resource_entry); |
1150 // The copied entry should have the new resource ID and the title. | 1120 // The copied entry should have the new resource ID and the title. |
1151 EXPECT_NE(kResourceId, resource_entry->resource_id()); | 1121 EXPECT_NE(kResourceId, resource_entry->resource_id()); |
1152 EXPECT_EQ("new title", resource_entry->title()); | 1122 EXPECT_EQ("new title", resource_entry->title()); |
1153 EXPECT_TRUE(HasParent(kResourceId, fake_service_.GetRootResourceId())); | 1123 EXPECT_TRUE(HasParent(kResourceId, fake_service_.GetRootResourceId())); |
1154 // Should be incremented as a new hosted document was created. | 1124 // Should be incremented as a new hosted document was created. |
1155 EXPECT_EQ(old_largest_change_id + 1, | 1125 EXPECT_EQ(old_largest_change_id + 1, |
1156 fake_service_.about_resource().largest_change_id()); | 1126 fake_service_.about_resource().largest_change_id()); |
1157 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1127 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1158 } | 1128 } |
1159 | 1129 |
1160 TEST_F(FakeDriveServiceTest, CopyResource_Offline) { | 1130 TEST_F(FakeDriveServiceTest, CopyResource_Offline) { |
1161 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1131 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1162 "gdata/root_feed.json")); | |
1163 fake_service_.set_offline(true); | 1132 fake_service_.set_offline(true); |
1164 | 1133 |
1165 const std::string kResourceId = "file:2_file_resource_id"; | 1134 const std::string kResourceId = "file:2_file_resource_id"; |
1166 GDataErrorCode error = GDATA_OTHER_ERROR; | 1135 GDataErrorCode error = GDATA_OTHER_ERROR; |
1167 scoped_ptr<ResourceEntry> resource_entry; | 1136 scoped_ptr<ResourceEntry> resource_entry; |
1168 fake_service_.CopyResource( | 1137 fake_service_.CopyResource( |
1169 kResourceId, | 1138 kResourceId, |
1170 "folder:1_folder_resource_id", | 1139 "folder:1_folder_resource_id", |
1171 "new title", | 1140 "new title", |
1172 base::Time(), | 1141 base::Time(), |
1173 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1142 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1174 base::RunLoop().RunUntilIdle(); | 1143 base::RunLoop().RunUntilIdle(); |
1175 | 1144 |
1176 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1145 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1177 EXPECT_FALSE(resource_entry); | 1146 EXPECT_FALSE(resource_entry); |
1178 } | 1147 } |
1179 | 1148 |
1180 TEST_F(FakeDriveServiceTest, UpdateResource) { | 1149 TEST_F(FakeDriveServiceTest, UpdateResource) { |
1181 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 1150 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
1182 const base::Time::Exploded kViewedDate = {2013, 8, 1, 20, 16, 00, 14, 234}; | 1151 const base::Time::Exploded kViewedDate = {2013, 8, 1, 20, 16, 00, 14, 234}; |
1183 | 1152 |
1184 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1153 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1185 "gdata/root_feed.json")); | |
1186 | 1154 |
1187 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1155 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1188 | 1156 |
1189 const std::string kResourceId = "file:2_file_resource_id"; | 1157 const std::string kResourceId = "file:2_file_resource_id"; |
1190 const std::string kParentResourceId = "folder:2_folder_resource_id"; | 1158 const std::string kParentResourceId = "folder:2_folder_resource_id"; |
1191 GDataErrorCode error = GDATA_OTHER_ERROR; | 1159 GDataErrorCode error = GDATA_OTHER_ERROR; |
1192 scoped_ptr<ResourceEntry> resource_entry; | 1160 scoped_ptr<ResourceEntry> resource_entry; |
1193 fake_service_.UpdateResource( | 1161 fake_service_.UpdateResource( |
1194 kResourceId, | 1162 kResourceId, |
1195 kParentResourceId, | 1163 kParentResourceId, |
(...skipping 13 matching lines...) Expand all Loading... |
1209 EXPECT_EQ(base::Time::FromUTCExploded(kViewedDate), | 1177 EXPECT_EQ(base::Time::FromUTCExploded(kViewedDate), |
1210 resource_entry->last_viewed_time()); | 1178 resource_entry->last_viewed_time()); |
1211 EXPECT_TRUE(HasParent(kResourceId, kParentResourceId)); | 1179 EXPECT_TRUE(HasParent(kResourceId, kParentResourceId)); |
1212 // Should be incremented as a new hosted document was created. | 1180 // Should be incremented as a new hosted document was created. |
1213 EXPECT_EQ(old_largest_change_id + 1, | 1181 EXPECT_EQ(old_largest_change_id + 1, |
1214 fake_service_.about_resource().largest_change_id()); | 1182 fake_service_.about_resource().largest_change_id()); |
1215 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1183 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1216 } | 1184 } |
1217 | 1185 |
1218 TEST_F(FakeDriveServiceTest, UpdateResource_NonExisting) { | 1186 TEST_F(FakeDriveServiceTest, UpdateResource_NonExisting) { |
1219 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1187 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1220 "gdata/root_feed.json")); | |
1221 | 1188 |
1222 const std::string kResourceId = "document:nonexisting_resource_id"; | 1189 const std::string kResourceId = "document:nonexisting_resource_id"; |
1223 GDataErrorCode error = GDATA_OTHER_ERROR; | 1190 GDataErrorCode error = GDATA_OTHER_ERROR; |
1224 scoped_ptr<ResourceEntry> resource_entry; | 1191 scoped_ptr<ResourceEntry> resource_entry; |
1225 fake_service_.UpdateResource( | 1192 fake_service_.UpdateResource( |
1226 kResourceId, | 1193 kResourceId, |
1227 "folder:1_folder_resource_id", | 1194 "folder:1_folder_resource_id", |
1228 "new title", | 1195 "new title", |
1229 base::Time(), | 1196 base::Time(), |
1230 base::Time(), | 1197 base::Time(), |
1231 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1198 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1232 base::RunLoop().RunUntilIdle(); | 1199 base::RunLoop().RunUntilIdle(); |
1233 | 1200 |
1234 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1201 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1235 } | 1202 } |
1236 | 1203 |
1237 TEST_F(FakeDriveServiceTest, UpdateResource_EmptyParentResourceId) { | 1204 TEST_F(FakeDriveServiceTest, UpdateResource_EmptyParentResourceId) { |
1238 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1205 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1239 "gdata/root_feed.json")); | |
1240 | 1206 |
1241 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1207 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1242 | 1208 |
1243 const std::string kResourceId = "file:2_file_resource_id"; | 1209 const std::string kResourceId = "file:2_file_resource_id"; |
1244 | 1210 |
1245 // Just make sure that the resource is under root. | 1211 // Just make sure that the resource is under root. |
1246 ASSERT_TRUE(HasParent(kResourceId, "fake_root")); | 1212 ASSERT_TRUE(HasParent(kResourceId, "fake_root")); |
1247 | 1213 |
1248 GDataErrorCode error = GDATA_OTHER_ERROR; | 1214 GDataErrorCode error = GDATA_OTHER_ERROR; |
1249 scoped_ptr<ResourceEntry> resource_entry; | 1215 scoped_ptr<ResourceEntry> resource_entry; |
(...skipping 12 matching lines...) Expand all Loading... |
1262 EXPECT_EQ(kResourceId, resource_entry->resource_id()); | 1228 EXPECT_EQ(kResourceId, resource_entry->resource_id()); |
1263 EXPECT_EQ("new title", resource_entry->title()); | 1229 EXPECT_EQ("new title", resource_entry->title()); |
1264 EXPECT_TRUE(HasParent(kResourceId, "fake_root")); | 1230 EXPECT_TRUE(HasParent(kResourceId, "fake_root")); |
1265 // Should be incremented as a new hosted document was created. | 1231 // Should be incremented as a new hosted document was created. |
1266 EXPECT_EQ(old_largest_change_id + 1, | 1232 EXPECT_EQ(old_largest_change_id + 1, |
1267 fake_service_.about_resource().largest_change_id()); | 1233 fake_service_.about_resource().largest_change_id()); |
1268 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1234 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1269 } | 1235 } |
1270 | 1236 |
1271 TEST_F(FakeDriveServiceTest, UpdateResource_Offline) { | 1237 TEST_F(FakeDriveServiceTest, UpdateResource_Offline) { |
1272 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1238 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1273 "gdata/root_feed.json")); | |
1274 fake_service_.set_offline(true); | 1239 fake_service_.set_offline(true); |
1275 | 1240 |
1276 const std::string kResourceId = "file:2_file_resource_id"; | 1241 const std::string kResourceId = "file:2_file_resource_id"; |
1277 GDataErrorCode error = GDATA_OTHER_ERROR; | 1242 GDataErrorCode error = GDATA_OTHER_ERROR; |
1278 scoped_ptr<ResourceEntry> resource_entry; | 1243 scoped_ptr<ResourceEntry> resource_entry; |
1279 fake_service_.UpdateResource( | 1244 fake_service_.UpdateResource( |
1280 kResourceId, | 1245 kResourceId, |
1281 std::string(), | 1246 std::string(), |
1282 "new title", | 1247 "new title", |
1283 base::Time(), | 1248 base::Time(), |
1284 base::Time(), | 1249 base::Time(), |
1285 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1250 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1286 base::RunLoop().RunUntilIdle(); | 1251 base::RunLoop().RunUntilIdle(); |
1287 | 1252 |
1288 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1253 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1289 EXPECT_FALSE(resource_entry); | 1254 EXPECT_FALSE(resource_entry); |
1290 } | 1255 } |
1291 | 1256 |
1292 TEST_F(FakeDriveServiceTest, RenameResource_ExistingFile) { | 1257 TEST_F(FakeDriveServiceTest, RenameResource_ExistingFile) { |
1293 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1258 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1294 "gdata/root_feed.json")); | |
1295 | 1259 |
1296 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1260 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1297 | 1261 |
1298 const std::string kResourceId = "file:2_file_resource_id"; | 1262 const std::string kResourceId = "file:2_file_resource_id"; |
1299 | 1263 |
1300 GDataErrorCode error = GDATA_OTHER_ERROR; | 1264 GDataErrorCode error = GDATA_OTHER_ERROR; |
1301 fake_service_.RenameResource(kResourceId, | 1265 fake_service_.RenameResource(kResourceId, |
1302 "new title", | 1266 "new title", |
1303 test_util::CreateCopyResultCallback(&error)); | 1267 test_util::CreateCopyResultCallback(&error)); |
1304 base::RunLoop().RunUntilIdle(); | 1268 base::RunLoop().RunUntilIdle(); |
1305 | 1269 |
1306 EXPECT_EQ(HTTP_SUCCESS, error); | 1270 EXPECT_EQ(HTTP_SUCCESS, error); |
1307 | 1271 |
1308 scoped_ptr<ResourceEntry> resource_entry = FindEntry(kResourceId); | 1272 scoped_ptr<ResourceEntry> resource_entry = FindEntry(kResourceId); |
1309 ASSERT_TRUE(resource_entry); | 1273 ASSERT_TRUE(resource_entry); |
1310 EXPECT_EQ("new title", resource_entry->title()); | 1274 EXPECT_EQ("new title", resource_entry->title()); |
1311 // Should be incremented as a file was renamed. | 1275 // Should be incremented as a file was renamed. |
1312 EXPECT_EQ(old_largest_change_id + 1, | 1276 EXPECT_EQ(old_largest_change_id + 1, |
1313 fake_service_.about_resource().largest_change_id()); | 1277 fake_service_.about_resource().largest_change_id()); |
1314 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1278 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1315 } | 1279 } |
1316 | 1280 |
1317 TEST_F(FakeDriveServiceTest, RenameResource_NonexistingFile) { | 1281 TEST_F(FakeDriveServiceTest, RenameResource_NonexistingFile) { |
1318 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1282 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1319 "gdata/root_feed.json")); | |
1320 | 1283 |
1321 const std::string kResourceId = "file:nonexisting_file"; | 1284 const std::string kResourceId = "file:nonexisting_file"; |
1322 | 1285 |
1323 GDataErrorCode error = GDATA_OTHER_ERROR; | 1286 GDataErrorCode error = GDATA_OTHER_ERROR; |
1324 fake_service_.RenameResource(kResourceId, | 1287 fake_service_.RenameResource(kResourceId, |
1325 "new title", | 1288 "new title", |
1326 test_util::CreateCopyResultCallback(&error)); | 1289 test_util::CreateCopyResultCallback(&error)); |
1327 base::RunLoop().RunUntilIdle(); | 1290 base::RunLoop().RunUntilIdle(); |
1328 | 1291 |
1329 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1292 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1330 } | 1293 } |
1331 | 1294 |
1332 TEST_F(FakeDriveServiceTest, RenameResource_Offline) { | 1295 TEST_F(FakeDriveServiceTest, RenameResource_Offline) { |
1333 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1296 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1334 "gdata/root_feed.json")); | |
1335 fake_service_.set_offline(true); | 1297 fake_service_.set_offline(true); |
1336 | 1298 |
1337 const std::string kResourceId = "file:2_file_resource_id"; | 1299 const std::string kResourceId = "file:2_file_resource_id"; |
1338 | 1300 |
1339 GDataErrorCode error = GDATA_OTHER_ERROR; | 1301 GDataErrorCode error = GDATA_OTHER_ERROR; |
1340 fake_service_.RenameResource(kResourceId, | 1302 fake_service_.RenameResource(kResourceId, |
1341 "new title", | 1303 "new title", |
1342 test_util::CreateCopyResultCallback(&error)); | 1304 test_util::CreateCopyResultCallback(&error)); |
1343 base::RunLoop().RunUntilIdle(); | 1305 base::RunLoop().RunUntilIdle(); |
1344 | 1306 |
1345 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1307 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1346 } | 1308 } |
1347 | 1309 |
1348 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInRootDirectory) { | 1310 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInRootDirectory) { |
1349 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1311 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1350 "gdata/root_feed.json")); | |
1351 | 1312 |
1352 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1313 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1353 | 1314 |
1354 const std::string kResourceId = "file:2_file_resource_id"; | 1315 const std::string kResourceId = "file:2_file_resource_id"; |
1355 const std::string kOldParentResourceId = fake_service_.GetRootResourceId(); | 1316 const std::string kOldParentResourceId = fake_service_.GetRootResourceId(); |
1356 const std::string kNewParentResourceId = "folder:1_folder_resource_id"; | 1317 const std::string kNewParentResourceId = "folder:1_folder_resource_id"; |
1357 | 1318 |
1358 // Here's the original parent link. | 1319 // Here's the original parent link. |
1359 EXPECT_TRUE(HasParent(kResourceId, kOldParentResourceId)); | 1320 EXPECT_TRUE(HasParent(kResourceId, kOldParentResourceId)); |
1360 EXPECT_FALSE(HasParent(kResourceId, kNewParentResourceId)); | 1321 EXPECT_FALSE(HasParent(kResourceId, kNewParentResourceId)); |
(...skipping 10 matching lines...) Expand all Loading... |
1371 // The parent link should now be changed. | 1332 // The parent link should now be changed. |
1372 EXPECT_TRUE(HasParent(kResourceId, kOldParentResourceId)); | 1333 EXPECT_TRUE(HasParent(kResourceId, kOldParentResourceId)); |
1373 EXPECT_TRUE(HasParent(kResourceId, kNewParentResourceId)); | 1334 EXPECT_TRUE(HasParent(kResourceId, kNewParentResourceId)); |
1374 // Should be incremented as a file was moved. | 1335 // Should be incremented as a file was moved. |
1375 EXPECT_EQ(old_largest_change_id + 1, | 1336 EXPECT_EQ(old_largest_change_id + 1, |
1376 fake_service_.about_resource().largest_change_id()); | 1337 fake_service_.about_resource().largest_change_id()); |
1377 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1338 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1378 } | 1339 } |
1379 | 1340 |
1380 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInNonRootDirectory) { | 1341 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInNonRootDirectory) { |
1381 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1342 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1382 "gdata/root_feed.json")); | |
1383 | 1343 |
1384 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1344 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1385 | 1345 |
1386 const std::string kResourceId = "file:subdirectory_file_1_id"; | 1346 const std::string kResourceId = "file:subdirectory_file_1_id"; |
1387 const std::string kOldParentResourceId = "folder:1_folder_resource_id"; | 1347 const std::string kOldParentResourceId = "folder:1_folder_resource_id"; |
1388 const std::string kNewParentResourceId = "folder:2_folder_resource_id"; | 1348 const std::string kNewParentResourceId = "folder:2_folder_resource_id"; |
1389 | 1349 |
1390 // Here's the original parent link. | 1350 // Here's the original parent link. |
1391 EXPECT_TRUE(HasParent(kResourceId, kOldParentResourceId)); | 1351 EXPECT_TRUE(HasParent(kResourceId, kOldParentResourceId)); |
1392 EXPECT_FALSE(HasParent(kResourceId, kNewParentResourceId)); | 1352 EXPECT_FALSE(HasParent(kResourceId, kNewParentResourceId)); |
(...skipping 10 matching lines...) Expand all Loading... |
1403 // The parent link should now be changed. | 1363 // The parent link should now be changed. |
1404 EXPECT_TRUE(HasParent(kResourceId, kOldParentResourceId)); | 1364 EXPECT_TRUE(HasParent(kResourceId, kOldParentResourceId)); |
1405 EXPECT_TRUE(HasParent(kResourceId, kNewParentResourceId)); | 1365 EXPECT_TRUE(HasParent(kResourceId, kNewParentResourceId)); |
1406 // Should be incremented as a file was moved. | 1366 // Should be incremented as a file was moved. |
1407 EXPECT_EQ(old_largest_change_id + 1, | 1367 EXPECT_EQ(old_largest_change_id + 1, |
1408 fake_service_.about_resource().largest_change_id()); | 1368 fake_service_.about_resource().largest_change_id()); |
1409 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1369 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1410 } | 1370 } |
1411 | 1371 |
1412 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_NonexistingFile) { | 1372 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_NonexistingFile) { |
1413 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1373 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1414 "gdata/root_feed.json")); | |
1415 | 1374 |
1416 const std::string kResourceId = "file:nonexisting_file"; | 1375 const std::string kResourceId = "file:nonexisting_file"; |
1417 const std::string kNewParentResourceId = "folder:1_folder_resource_id"; | 1376 const std::string kNewParentResourceId = "folder:1_folder_resource_id"; |
1418 | 1377 |
1419 GDataErrorCode error = GDATA_OTHER_ERROR; | 1378 GDataErrorCode error = GDATA_OTHER_ERROR; |
1420 fake_service_.AddResourceToDirectory( | 1379 fake_service_.AddResourceToDirectory( |
1421 kNewParentResourceId, | 1380 kNewParentResourceId, |
1422 kResourceId, | 1381 kResourceId, |
1423 test_util::CreateCopyResultCallback(&error)); | 1382 test_util::CreateCopyResultCallback(&error)); |
1424 base::RunLoop().RunUntilIdle(); | 1383 base::RunLoop().RunUntilIdle(); |
1425 | 1384 |
1426 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1385 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1427 } | 1386 } |
1428 | 1387 |
1429 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_OrphanFile) { | 1388 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_OrphanFile) { |
1430 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1389 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1431 "gdata/root_feed.json")); | |
1432 | 1390 |
1433 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1391 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1434 | 1392 |
1435 const std::string kResourceId = "file:1_orphanfile_resource_id"; | 1393 const std::string kResourceId = "file:1_orphanfile_resource_id"; |
1436 const std::string kNewParentResourceId = "folder:1_folder_resource_id"; | 1394 const std::string kNewParentResourceId = "folder:1_folder_resource_id"; |
1437 | 1395 |
1438 // The file does not belong to any directory, even to the root. | 1396 // The file does not belong to any directory, even to the root. |
1439 EXPECT_FALSE(HasParent(kResourceId, kNewParentResourceId)); | 1397 EXPECT_FALSE(HasParent(kResourceId, kNewParentResourceId)); |
1440 EXPECT_FALSE(HasParent(kResourceId, fake_service_.GetRootResourceId())); | 1398 EXPECT_FALSE(HasParent(kResourceId, fake_service_.GetRootResourceId())); |
1441 | 1399 |
1442 GDataErrorCode error = GDATA_OTHER_ERROR; | 1400 GDataErrorCode error = GDATA_OTHER_ERROR; |
1443 fake_service_.AddResourceToDirectory( | 1401 fake_service_.AddResourceToDirectory( |
1444 kNewParentResourceId, | 1402 kNewParentResourceId, |
1445 kResourceId, | 1403 kResourceId, |
1446 test_util::CreateCopyResultCallback(&error)); | 1404 test_util::CreateCopyResultCallback(&error)); |
1447 base::RunLoop().RunUntilIdle(); | 1405 base::RunLoop().RunUntilIdle(); |
1448 | 1406 |
1449 EXPECT_EQ(HTTP_SUCCESS, error); | 1407 EXPECT_EQ(HTTP_SUCCESS, error); |
1450 | 1408 |
1451 // The parent link should now be changed. | 1409 // The parent link should now be changed. |
1452 EXPECT_TRUE(HasParent(kResourceId, kNewParentResourceId)); | 1410 EXPECT_TRUE(HasParent(kResourceId, kNewParentResourceId)); |
1453 EXPECT_FALSE(HasParent(kResourceId, fake_service_.GetRootResourceId())); | 1411 EXPECT_FALSE(HasParent(kResourceId, fake_service_.GetRootResourceId())); |
1454 // Should be incremented as a file was moved. | 1412 // Should be incremented as a file was moved. |
1455 EXPECT_EQ(old_largest_change_id + 1, | 1413 EXPECT_EQ(old_largest_change_id + 1, |
1456 fake_service_.about_resource().largest_change_id()); | 1414 fake_service_.about_resource().largest_change_id()); |
1457 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1415 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1458 } | 1416 } |
1459 | 1417 |
1460 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_Offline) { | 1418 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_Offline) { |
1461 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1419 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1462 "gdata/root_feed.json")); | |
1463 fake_service_.set_offline(true); | 1420 fake_service_.set_offline(true); |
1464 | 1421 |
1465 const std::string kResourceId = "file:2_file_resource_id"; | 1422 const std::string kResourceId = "file:2_file_resource_id"; |
1466 const std::string kNewParentResourceId = "folder:1_folder_resource_id"; | 1423 const std::string kNewParentResourceId = "folder:1_folder_resource_id"; |
1467 | 1424 |
1468 GDataErrorCode error = GDATA_OTHER_ERROR; | 1425 GDataErrorCode error = GDATA_OTHER_ERROR; |
1469 fake_service_.AddResourceToDirectory( | 1426 fake_service_.AddResourceToDirectory( |
1470 kNewParentResourceId, | 1427 kNewParentResourceId, |
1471 kResourceId, | 1428 kResourceId, |
1472 test_util::CreateCopyResultCallback(&error)); | 1429 test_util::CreateCopyResultCallback(&error)); |
1473 base::RunLoop().RunUntilIdle(); | 1430 base::RunLoop().RunUntilIdle(); |
1474 | 1431 |
1475 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1432 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1476 } | 1433 } |
1477 | 1434 |
1478 TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_ExistingFile) { | 1435 TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_ExistingFile) { |
1479 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1436 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1480 "gdata/root_feed.json")); | |
1481 | 1437 |
1482 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1438 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1483 | 1439 |
1484 const std::string kResourceId = "file:subdirectory_file_1_id"; | 1440 const std::string kResourceId = "file:subdirectory_file_1_id"; |
1485 const std::string kParentResourceId = "folder:1_folder_resource_id"; | 1441 const std::string kParentResourceId = "folder:1_folder_resource_id"; |
1486 | 1442 |
1487 scoped_ptr<ResourceEntry> resource_entry = FindEntry(kResourceId); | 1443 scoped_ptr<ResourceEntry> resource_entry = FindEntry(kResourceId); |
1488 ASSERT_TRUE(resource_entry); | 1444 ASSERT_TRUE(resource_entry); |
1489 // The parent link should exist now. | 1445 // The parent link should exist now. |
1490 const google_apis::Link* parent_link = | 1446 const google_apis::Link* parent_link = |
(...skipping 14 matching lines...) Expand all Loading... |
1505 // The parent link should be gone now. | 1461 // The parent link should be gone now. |
1506 parent_link = resource_entry->GetLinkByType(Link::LINK_PARENT); | 1462 parent_link = resource_entry->GetLinkByType(Link::LINK_PARENT); |
1507 ASSERT_FALSE(parent_link); | 1463 ASSERT_FALSE(parent_link); |
1508 // Should be incremented as a file was moved to the root directory. | 1464 // Should be incremented as a file was moved to the root directory. |
1509 EXPECT_EQ(old_largest_change_id + 1, | 1465 EXPECT_EQ(old_largest_change_id + 1, |
1510 fake_service_.about_resource().largest_change_id()); | 1466 fake_service_.about_resource().largest_change_id()); |
1511 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1467 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1512 } | 1468 } |
1513 | 1469 |
1514 TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_NonexistingFile) { | 1470 TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_NonexistingFile) { |
1515 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1471 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1516 "gdata/root_feed.json")); | |
1517 | 1472 |
1518 const std::string kResourceId = "file:nonexisting_file"; | 1473 const std::string kResourceId = "file:nonexisting_file"; |
1519 const std::string kParentResourceId = "folder:1_folder_resource_id"; | 1474 const std::string kParentResourceId = "folder:1_folder_resource_id"; |
1520 | 1475 |
1521 GDataErrorCode error = GDATA_OTHER_ERROR; | 1476 GDataErrorCode error = GDATA_OTHER_ERROR; |
1522 fake_service_.RemoveResourceFromDirectory( | 1477 fake_service_.RemoveResourceFromDirectory( |
1523 kParentResourceId, | 1478 kParentResourceId, |
1524 kResourceId, | 1479 kResourceId, |
1525 test_util::CreateCopyResultCallback(&error)); | 1480 test_util::CreateCopyResultCallback(&error)); |
1526 base::RunLoop().RunUntilIdle(); | 1481 base::RunLoop().RunUntilIdle(); |
1527 | 1482 |
1528 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1483 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1529 } | 1484 } |
1530 | 1485 |
1531 TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_OrphanFile) { | 1486 TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_OrphanFile) { |
1532 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1487 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1533 "gdata/root_feed.json")); | |
1534 | 1488 |
1535 const std::string kResourceId = "file:1_orphanfile_resource_id"; | 1489 const std::string kResourceId = "file:1_orphanfile_resource_id"; |
1536 const std::string kParentResourceId = fake_service_.GetRootResourceId(); | 1490 const std::string kParentResourceId = fake_service_.GetRootResourceId(); |
1537 | 1491 |
1538 GDataErrorCode error = GDATA_OTHER_ERROR; | 1492 GDataErrorCode error = GDATA_OTHER_ERROR; |
1539 fake_service_.RemoveResourceFromDirectory( | 1493 fake_service_.RemoveResourceFromDirectory( |
1540 kParentResourceId, | 1494 kParentResourceId, |
1541 kResourceId, | 1495 kResourceId, |
1542 test_util::CreateCopyResultCallback(&error)); | 1496 test_util::CreateCopyResultCallback(&error)); |
1543 base::RunLoop().RunUntilIdle(); | 1497 base::RunLoop().RunUntilIdle(); |
1544 | 1498 |
1545 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1499 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1546 } | 1500 } |
1547 | 1501 |
1548 TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_Offline) { | 1502 TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_Offline) { |
1549 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1503 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1550 "gdata/root_feed.json")); | |
1551 fake_service_.set_offline(true); | 1504 fake_service_.set_offline(true); |
1552 | 1505 |
1553 const std::string kResourceId = "file:subdirectory_file_1_id"; | 1506 const std::string kResourceId = "file:subdirectory_file_1_id"; |
1554 const std::string kParentResourceId = "folder:1_folder_resource_id"; | 1507 const std::string kParentResourceId = "folder:1_folder_resource_id"; |
1555 | 1508 |
1556 GDataErrorCode error = GDATA_OTHER_ERROR; | 1509 GDataErrorCode error = GDATA_OTHER_ERROR; |
1557 fake_service_.RemoveResourceFromDirectory( | 1510 fake_service_.RemoveResourceFromDirectory( |
1558 kParentResourceId, | 1511 kParentResourceId, |
1559 kResourceId, | 1512 kResourceId, |
1560 test_util::CreateCopyResultCallback(&error)); | 1513 test_util::CreateCopyResultCallback(&error)); |
1561 base::RunLoop().RunUntilIdle(); | 1514 base::RunLoop().RunUntilIdle(); |
1562 | 1515 |
1563 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1516 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1564 } | 1517 } |
1565 | 1518 |
1566 TEST_F(FakeDriveServiceTest, AddNewDirectory_EmptyParent) { | 1519 TEST_F(FakeDriveServiceTest, AddNewDirectory_EmptyParent) { |
1567 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1520 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1568 "gdata/root_feed.json")); | |
1569 | 1521 |
1570 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1522 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1571 | 1523 |
1572 GDataErrorCode error = GDATA_OTHER_ERROR; | 1524 GDataErrorCode error = GDATA_OTHER_ERROR; |
1573 scoped_ptr<ResourceEntry> resource_entry; | 1525 scoped_ptr<ResourceEntry> resource_entry; |
1574 fake_service_.AddNewDirectory( | 1526 fake_service_.AddNewDirectory( |
1575 std::string(), | 1527 std::string(), |
1576 "new directory", | 1528 "new directory", |
1577 DriveServiceInterface::AddNewDirectoryOptions(), | 1529 DriveServiceInterface::AddNewDirectoryOptions(), |
1578 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1530 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1579 base::RunLoop().RunUntilIdle(); | 1531 base::RunLoop().RunUntilIdle(); |
1580 | 1532 |
1581 EXPECT_EQ(HTTP_CREATED, error); | 1533 EXPECT_EQ(HTTP_CREATED, error); |
1582 ASSERT_TRUE(resource_entry); | 1534 ASSERT_TRUE(resource_entry); |
1583 EXPECT_TRUE(resource_entry->is_folder()); | 1535 EXPECT_TRUE(resource_entry->is_folder()); |
1584 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); | 1536 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); |
1585 EXPECT_EQ("new directory", resource_entry->title()); | 1537 EXPECT_EQ("new directory", resource_entry->title()); |
1586 EXPECT_TRUE(HasParent(resource_entry->resource_id(), | 1538 EXPECT_TRUE(HasParent(resource_entry->resource_id(), |
1587 fake_service_.GetRootResourceId())); | 1539 fake_service_.GetRootResourceId())); |
1588 // Should be incremented as a new directory was created. | 1540 // Should be incremented as a new directory was created. |
1589 EXPECT_EQ(old_largest_change_id + 1, | 1541 EXPECT_EQ(old_largest_change_id + 1, |
1590 fake_service_.about_resource().largest_change_id()); | 1542 fake_service_.about_resource().largest_change_id()); |
1591 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1543 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1592 } | 1544 } |
1593 | 1545 |
1594 TEST_F(FakeDriveServiceTest, AddNewDirectory_ToRootDirectory) { | 1546 TEST_F(FakeDriveServiceTest, AddNewDirectory_ToRootDirectory) { |
1595 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1547 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1596 "gdata/root_feed.json")); | |
1597 | 1548 |
1598 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1549 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1599 | 1550 |
1600 GDataErrorCode error = GDATA_OTHER_ERROR; | 1551 GDataErrorCode error = GDATA_OTHER_ERROR; |
1601 scoped_ptr<ResourceEntry> resource_entry; | 1552 scoped_ptr<ResourceEntry> resource_entry; |
1602 fake_service_.AddNewDirectory( | 1553 fake_service_.AddNewDirectory( |
1603 fake_service_.GetRootResourceId(), | 1554 fake_service_.GetRootResourceId(), |
1604 "new directory", | 1555 "new directory", |
1605 DriveServiceInterface::AddNewDirectoryOptions(), | 1556 DriveServiceInterface::AddNewDirectoryOptions(), |
1606 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1557 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 EXPECT_EQ("new directory", resource_entry->title()); | 1589 EXPECT_EQ("new directory", resource_entry->title()); |
1639 EXPECT_TRUE(HasParent(resource_entry->resource_id(), | 1590 EXPECT_TRUE(HasParent(resource_entry->resource_id(), |
1640 fake_service_.GetRootResourceId())); | 1591 fake_service_.GetRootResourceId())); |
1641 // Should be incremented as a new directory was created. | 1592 // Should be incremented as a new directory was created. |
1642 EXPECT_EQ(old_largest_change_id + 1, | 1593 EXPECT_EQ(old_largest_change_id + 1, |
1643 fake_service_.about_resource().largest_change_id()); | 1594 fake_service_.about_resource().largest_change_id()); |
1644 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1595 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1645 } | 1596 } |
1646 | 1597 |
1647 TEST_F(FakeDriveServiceTest, AddNewDirectory_ToNonRootDirectory) { | 1598 TEST_F(FakeDriveServiceTest, AddNewDirectory_ToNonRootDirectory) { |
1648 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1599 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1649 "gdata/root_feed.json")); | |
1650 | 1600 |
1651 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1601 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1652 | 1602 |
1653 const std::string kParentResourceId = "folder:1_folder_resource_id"; | 1603 const std::string kParentResourceId = "folder:1_folder_resource_id"; |
1654 | 1604 |
1655 GDataErrorCode error = GDATA_OTHER_ERROR; | 1605 GDataErrorCode error = GDATA_OTHER_ERROR; |
1656 scoped_ptr<ResourceEntry> resource_entry; | 1606 scoped_ptr<ResourceEntry> resource_entry; |
1657 fake_service_.AddNewDirectory( | 1607 fake_service_.AddNewDirectory( |
1658 kParentResourceId, | 1608 kParentResourceId, |
1659 "new directory", | 1609 "new directory", |
1660 DriveServiceInterface::AddNewDirectoryOptions(), | 1610 DriveServiceInterface::AddNewDirectoryOptions(), |
1661 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1611 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1662 base::RunLoop().RunUntilIdle(); | 1612 base::RunLoop().RunUntilIdle(); |
1663 | 1613 |
1664 EXPECT_EQ(HTTP_CREATED, error); | 1614 EXPECT_EQ(HTTP_CREATED, error); |
1665 ASSERT_TRUE(resource_entry); | 1615 ASSERT_TRUE(resource_entry); |
1666 EXPECT_TRUE(resource_entry->is_folder()); | 1616 EXPECT_TRUE(resource_entry->is_folder()); |
1667 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); | 1617 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); |
1668 EXPECT_EQ("new directory", resource_entry->title()); | 1618 EXPECT_EQ("new directory", resource_entry->title()); |
1669 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId)); | 1619 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId)); |
1670 // Should be incremented as a new directory was created. | 1620 // Should be incremented as a new directory was created. |
1671 EXPECT_EQ(old_largest_change_id + 1, | 1621 EXPECT_EQ(old_largest_change_id + 1, |
1672 fake_service_.about_resource().largest_change_id()); | 1622 fake_service_.about_resource().largest_change_id()); |
1673 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 1623 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
1674 } | 1624 } |
1675 | 1625 |
1676 TEST_F(FakeDriveServiceTest, AddNewDirectory_ToNonexistingDirectory) { | 1626 TEST_F(FakeDriveServiceTest, AddNewDirectory_ToNonexistingDirectory) { |
1677 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1627 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1678 "gdata/root_feed.json")); | |
1679 | 1628 |
1680 const std::string kParentResourceId = "folder:nonexisting_resource_id"; | 1629 const std::string kParentResourceId = "folder:nonexisting_resource_id"; |
1681 | 1630 |
1682 GDataErrorCode error = GDATA_OTHER_ERROR; | 1631 GDataErrorCode error = GDATA_OTHER_ERROR; |
1683 scoped_ptr<ResourceEntry> resource_entry; | 1632 scoped_ptr<ResourceEntry> resource_entry; |
1684 fake_service_.AddNewDirectory( | 1633 fake_service_.AddNewDirectory( |
1685 kParentResourceId, | 1634 kParentResourceId, |
1686 "new directory", | 1635 "new directory", |
1687 DriveServiceInterface::AddNewDirectoryOptions(), | 1636 DriveServiceInterface::AddNewDirectoryOptions(), |
1688 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1637 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1689 base::RunLoop().RunUntilIdle(); | 1638 base::RunLoop().RunUntilIdle(); |
1690 | 1639 |
1691 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1640 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1692 EXPECT_FALSE(resource_entry); | 1641 EXPECT_FALSE(resource_entry); |
1693 } | 1642 } |
1694 | 1643 |
1695 TEST_F(FakeDriveServiceTest, AddNewDirectory_Offline) { | 1644 TEST_F(FakeDriveServiceTest, AddNewDirectory_Offline) { |
1696 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1645 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1697 "gdata/root_feed.json")); | |
1698 fake_service_.set_offline(true); | 1646 fake_service_.set_offline(true); |
1699 | 1647 |
1700 GDataErrorCode error = GDATA_OTHER_ERROR; | 1648 GDataErrorCode error = GDATA_OTHER_ERROR; |
1701 scoped_ptr<ResourceEntry> resource_entry; | 1649 scoped_ptr<ResourceEntry> resource_entry; |
1702 fake_service_.AddNewDirectory( | 1650 fake_service_.AddNewDirectory( |
1703 fake_service_.GetRootResourceId(), | 1651 fake_service_.GetRootResourceId(), |
1704 "new directory", | 1652 "new directory", |
1705 DriveServiceInterface::AddNewDirectoryOptions(), | 1653 DriveServiceInterface::AddNewDirectoryOptions(), |
1706 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1654 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1707 base::RunLoop().RunUntilIdle(); | 1655 base::RunLoop().RunUntilIdle(); |
1708 | 1656 |
1709 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1657 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1710 EXPECT_FALSE(resource_entry); | 1658 EXPECT_FALSE(resource_entry); |
1711 } | 1659 } |
1712 | 1660 |
1713 TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_Offline) { | 1661 TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_Offline) { |
1714 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1662 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1715 "gdata/root_feed.json")); | |
1716 fake_service_.set_offline(true); | 1663 fake_service_.set_offline(true); |
1717 | 1664 |
1718 GDataErrorCode error = GDATA_OTHER_ERROR; | 1665 GDataErrorCode error = GDATA_OTHER_ERROR; |
1719 GURL upload_location; | 1666 GURL upload_location; |
1720 fake_service_.InitiateUploadNewFile( | 1667 fake_service_.InitiateUploadNewFile( |
1721 "test/foo", | 1668 "test/foo", |
1722 13, | 1669 13, |
1723 "folder:1_folder_resource_id", | 1670 "folder:1_folder_resource_id", |
1724 "new file.foo", | 1671 "new file.foo", |
1725 FakeDriveService::InitiateUploadNewFileOptions(), | 1672 FakeDriveService::InitiateUploadNewFileOptions(), |
1726 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1673 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1727 base::RunLoop().RunUntilIdle(); | 1674 base::RunLoop().RunUntilIdle(); |
1728 | 1675 |
1729 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1676 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1730 EXPECT_TRUE(upload_location.is_empty()); | 1677 EXPECT_TRUE(upload_location.is_empty()); |
1731 } | 1678 } |
1732 | 1679 |
1733 TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_NotFound) { | 1680 TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_NotFound) { |
1734 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1681 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1735 "gdata/root_feed.json")); | |
1736 | 1682 |
1737 GDataErrorCode error = GDATA_OTHER_ERROR; | 1683 GDataErrorCode error = GDATA_OTHER_ERROR; |
1738 GURL upload_location; | 1684 GURL upload_location; |
1739 fake_service_.InitiateUploadNewFile( | 1685 fake_service_.InitiateUploadNewFile( |
1740 "test/foo", | 1686 "test/foo", |
1741 13, | 1687 13, |
1742 "non_existent", | 1688 "non_existent", |
1743 "new file.foo", | 1689 "new file.foo", |
1744 FakeDriveService::InitiateUploadNewFileOptions(), | 1690 FakeDriveService::InitiateUploadNewFileOptions(), |
1745 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1691 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1746 base::RunLoop().RunUntilIdle(); | 1692 base::RunLoop().RunUntilIdle(); |
1747 | 1693 |
1748 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1694 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1749 EXPECT_TRUE(upload_location.is_empty()); | 1695 EXPECT_TRUE(upload_location.is_empty()); |
1750 } | 1696 } |
1751 | 1697 |
1752 TEST_F(FakeDriveServiceTest, InitiateUploadNewFile) { | 1698 TEST_F(FakeDriveServiceTest, InitiateUploadNewFile) { |
1753 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1699 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1754 "gdata/root_feed.json")); | |
1755 | 1700 |
1756 GDataErrorCode error = GDATA_OTHER_ERROR; | 1701 GDataErrorCode error = GDATA_OTHER_ERROR; |
1757 GURL upload_location; | 1702 GURL upload_location; |
1758 fake_service_.InitiateUploadNewFile( | 1703 fake_service_.InitiateUploadNewFile( |
1759 "test/foo", | 1704 "test/foo", |
1760 13, | 1705 13, |
1761 "folder:1_folder_resource_id", | 1706 "folder:1_folder_resource_id", |
1762 "new file.foo", | 1707 "new file.foo", |
1763 FakeDriveService::InitiateUploadNewFileOptions(), | 1708 FakeDriveService::InitiateUploadNewFileOptions(), |
1764 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1709 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1765 base::RunLoop().RunUntilIdle(); | 1710 base::RunLoop().RunUntilIdle(); |
1766 | 1711 |
1767 EXPECT_EQ(HTTP_SUCCESS, error); | 1712 EXPECT_EQ(HTTP_SUCCESS, error); |
1768 EXPECT_FALSE(upload_location.is_empty()); | 1713 EXPECT_FALSE(upload_location.is_empty()); |
1769 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link?mode=newfile"), | 1714 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link?mode=newfile"), |
1770 upload_location); | 1715 upload_location); |
1771 } | 1716 } |
1772 | 1717 |
1773 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_Offline) { | 1718 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_Offline) { |
1774 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1719 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1775 "gdata/root_feed.json")); | |
1776 fake_service_.set_offline(true); | 1720 fake_service_.set_offline(true); |
1777 | 1721 |
1778 GDataErrorCode error = GDATA_OTHER_ERROR; | 1722 GDataErrorCode error = GDATA_OTHER_ERROR; |
1779 GURL upload_location; | 1723 GURL upload_location; |
1780 fake_service_.InitiateUploadExistingFile( | 1724 fake_service_.InitiateUploadExistingFile( |
1781 "test/foo", | 1725 "test/foo", |
1782 13, | 1726 13, |
1783 "file:2_file_resource_id", | 1727 "file:2_file_resource_id", |
1784 FakeDriveService::InitiateUploadExistingFileOptions(), | 1728 FakeDriveService::InitiateUploadExistingFileOptions(), |
1785 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1729 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1786 base::RunLoop().RunUntilIdle(); | 1730 base::RunLoop().RunUntilIdle(); |
1787 | 1731 |
1788 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1732 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1789 EXPECT_TRUE(upload_location.is_empty()); | 1733 EXPECT_TRUE(upload_location.is_empty()); |
1790 } | 1734 } |
1791 | 1735 |
1792 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_NotFound) { | 1736 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_NotFound) { |
1793 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1737 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1794 "gdata/root_feed.json")); | |
1795 | 1738 |
1796 GDataErrorCode error = GDATA_OTHER_ERROR; | 1739 GDataErrorCode error = GDATA_OTHER_ERROR; |
1797 GURL upload_location; | 1740 GURL upload_location; |
1798 fake_service_.InitiateUploadExistingFile( | 1741 fake_service_.InitiateUploadExistingFile( |
1799 "test/foo", | 1742 "test/foo", |
1800 13, | 1743 13, |
1801 "non_existent", | 1744 "non_existent", |
1802 FakeDriveService::InitiateUploadExistingFileOptions(), | 1745 FakeDriveService::InitiateUploadExistingFileOptions(), |
1803 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1746 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1804 base::RunLoop().RunUntilIdle(); | 1747 base::RunLoop().RunUntilIdle(); |
1805 | 1748 |
1806 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1749 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1807 EXPECT_TRUE(upload_location.is_empty()); | 1750 EXPECT_TRUE(upload_location.is_empty()); |
1808 } | 1751 } |
1809 | 1752 |
1810 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_WrongETag) { | 1753 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_WrongETag) { |
1811 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1754 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1812 "gdata/root_feed.json")); | |
1813 | 1755 |
1814 FakeDriveService::InitiateUploadExistingFileOptions options; | 1756 FakeDriveService::InitiateUploadExistingFileOptions options; |
1815 options.etag = "invalid_etag"; | 1757 options.etag = "invalid_etag"; |
1816 | 1758 |
1817 GDataErrorCode error = GDATA_OTHER_ERROR; | 1759 GDataErrorCode error = GDATA_OTHER_ERROR; |
1818 GURL upload_location; | 1760 GURL upload_location; |
1819 fake_service_.InitiateUploadExistingFile( | 1761 fake_service_.InitiateUploadExistingFile( |
1820 "text/plain", | 1762 "text/plain", |
1821 13, | 1763 13, |
1822 "file:2_file_resource_id", | 1764 "file:2_file_resource_id", |
1823 options, | 1765 options, |
1824 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1766 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1825 base::RunLoop().RunUntilIdle(); | 1767 base::RunLoop().RunUntilIdle(); |
1826 | 1768 |
1827 EXPECT_EQ(HTTP_PRECONDITION, error); | 1769 EXPECT_EQ(HTTP_PRECONDITION, error); |
1828 EXPECT_TRUE(upload_location.is_empty()); | 1770 EXPECT_TRUE(upload_location.is_empty()); |
1829 } | 1771 } |
1830 | 1772 |
1831 TEST_F(FakeDriveServiceTest, InitiateUpload_ExistingFile) { | 1773 TEST_F(FakeDriveServiceTest, InitiateUpload_ExistingFile) { |
1832 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1774 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1833 "gdata/root_feed.json")); | 1775 |
| 1776 scoped_ptr<ResourceEntry> entry = FindEntry("file:2_file_resource_id"); |
| 1777 ASSERT_TRUE(entry); |
1834 | 1778 |
1835 FakeDriveService::InitiateUploadExistingFileOptions options; | 1779 FakeDriveService::InitiateUploadExistingFileOptions options; |
1836 options.etag = "\"HhMOFgxXHit7ImBr\""; | 1780 options.etag = entry->etag(); |
1837 | 1781 |
1838 GDataErrorCode error = GDATA_OTHER_ERROR; | 1782 GDataErrorCode error = GDATA_OTHER_ERROR; |
1839 GURL upload_location; | 1783 GURL upload_location; |
1840 fake_service_.InitiateUploadExistingFile( | 1784 fake_service_.InitiateUploadExistingFile( |
1841 "text/plain", | 1785 "text/plain", |
1842 13, | 1786 13, |
1843 "file:2_file_resource_id", | 1787 "file:2_file_resource_id", |
1844 options, | 1788 options, |
1845 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1789 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1846 base::RunLoop().RunUntilIdle(); | 1790 base::RunLoop().RunUntilIdle(); |
1847 | 1791 |
1848 EXPECT_EQ(HTTP_SUCCESS, error); | 1792 EXPECT_EQ(HTTP_SUCCESS, error); |
1849 EXPECT_TRUE(upload_location.is_valid()); | 1793 EXPECT_TRUE(upload_location.is_valid()); |
1850 } | 1794 } |
1851 | 1795 |
1852 TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) { | 1796 TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) { |
1853 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1797 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1854 "gdata/root_feed.json")); | |
1855 | 1798 |
1856 GDataErrorCode error = GDATA_OTHER_ERROR; | 1799 GDataErrorCode error = GDATA_OTHER_ERROR; |
1857 GURL upload_location; | 1800 GURL upload_location; |
1858 fake_service_.InitiateUploadNewFile( | 1801 fake_service_.InitiateUploadNewFile( |
1859 "test/foo", | 1802 "test/foo", |
1860 15, | 1803 15, |
1861 "folder:1_folder_resource_id", | 1804 "folder:1_folder_resource_id", |
1862 "new file.foo", | 1805 "new file.foo", |
1863 FakeDriveService::InitiateUploadNewFileOptions(), | 1806 FakeDriveService::InitiateUploadNewFileOptions(), |
1864 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1807 test_util::CreateCopyResultCallback(&error, &upload_location)); |
(...skipping 14 matching lines...) Expand all Loading... |
1879 base::FilePath(), | 1822 base::FilePath(), |
1880 test_util::CreateCopyResultCallback(&response, &entry), | 1823 test_util::CreateCopyResultCallback(&response, &entry), |
1881 ProgressCallback()); | 1824 ProgressCallback()); |
1882 base::RunLoop().RunUntilIdle(); | 1825 base::RunLoop().RunUntilIdle(); |
1883 | 1826 |
1884 EXPECT_EQ(GDATA_NO_CONNECTION, response.code); | 1827 EXPECT_EQ(GDATA_NO_CONNECTION, response.code); |
1885 EXPECT_FALSE(entry.get()); | 1828 EXPECT_FALSE(entry.get()); |
1886 } | 1829 } |
1887 | 1830 |
1888 TEST_F(FakeDriveServiceTest, ResumeUpload_NotFound) { | 1831 TEST_F(FakeDriveServiceTest, ResumeUpload_NotFound) { |
1889 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1832 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1890 "gdata/root_feed.json")); | |
1891 | 1833 |
1892 GDataErrorCode error = GDATA_OTHER_ERROR; | 1834 GDataErrorCode error = GDATA_OTHER_ERROR; |
1893 GURL upload_location; | 1835 GURL upload_location; |
1894 fake_service_.InitiateUploadNewFile( | 1836 fake_service_.InitiateUploadNewFile( |
1895 "test/foo", | 1837 "test/foo", |
1896 15, | 1838 15, |
1897 "folder:1_folder_resource_id", | 1839 "folder:1_folder_resource_id", |
1898 "new file.foo", | 1840 "new file.foo", |
1899 FakeDriveService::InitiateUploadNewFileOptions(), | 1841 FakeDriveService::InitiateUploadNewFileOptions(), |
1900 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1842 test_util::CreateCopyResultCallback(&error, &upload_location)); |
(...skipping 16 matching lines...) Expand all Loading... |
1917 } | 1859 } |
1918 | 1860 |
1919 TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) { | 1861 TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) { |
1920 base::ScopedTempDir temp_dir; | 1862 base::ScopedTempDir temp_dir; |
1921 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1863 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1922 base::FilePath local_file_path = | 1864 base::FilePath local_file_path = |
1923 temp_dir.path().Append(FILE_PATH_LITERAL("File 1.txt")); | 1865 temp_dir.path().Append(FILE_PATH_LITERAL("File 1.txt")); |
1924 std::string contents("hogefugapiyo"); | 1866 std::string contents("hogefugapiyo"); |
1925 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents)); | 1867 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents)); |
1926 | 1868 |
1927 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1869 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1928 "gdata/root_feed.json")); | 1870 |
| 1871 scoped_ptr<ResourceEntry> entry = FindEntry("file:2_file_resource_id"); |
| 1872 ASSERT_TRUE(entry); |
1929 | 1873 |
1930 FakeDriveService::InitiateUploadExistingFileOptions options; | 1874 FakeDriveService::InitiateUploadExistingFileOptions options; |
1931 options.etag = "\"HhMOFgxXHit7ImBr\""; | 1875 options.etag = entry->etag(); |
1932 | 1876 |
1933 GDataErrorCode error = GDATA_OTHER_ERROR; | 1877 GDataErrorCode error = GDATA_OTHER_ERROR; |
1934 GURL upload_location; | 1878 GURL upload_location; |
1935 fake_service_.InitiateUploadExistingFile( | 1879 fake_service_.InitiateUploadExistingFile( |
1936 "text/plain", | 1880 "text/plain", |
1937 contents.size(), | 1881 contents.size(), |
1938 "file:2_file_resource_id", | 1882 "file:2_file_resource_id", |
1939 options, | 1883 options, |
1940 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1884 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1941 base::RunLoop().RunUntilIdle(); | 1885 base::RunLoop().RunUntilIdle(); |
1942 | 1886 |
1943 ASSERT_EQ(HTTP_SUCCESS, error); | 1887 ASSERT_EQ(HTTP_SUCCESS, error); |
1944 | 1888 |
1945 UploadRangeResponse response; | 1889 UploadRangeResponse response; |
1946 scoped_ptr<ResourceEntry> entry; | 1890 entry.reset(); |
1947 std::vector<test_util::ProgressInfo> upload_progress_values; | 1891 std::vector<test_util::ProgressInfo> upload_progress_values; |
1948 fake_service_.ResumeUpload( | 1892 fake_service_.ResumeUpload( |
1949 upload_location, | 1893 upload_location, |
1950 0, contents.size() / 2, contents.size(), "text/plain", | 1894 0, contents.size() / 2, contents.size(), "text/plain", |
1951 local_file_path, | 1895 local_file_path, |
1952 test_util::CreateCopyResultCallback(&response, &entry), | 1896 test_util::CreateCopyResultCallback(&response, &entry), |
1953 base::Bind(&test_util::AppendProgressCallbackResult, | 1897 base::Bind(&test_util::AppendProgressCallbackResult, |
1954 &upload_progress_values)); | 1898 &upload_progress_values)); |
1955 base::RunLoop().RunUntilIdle(); | 1899 base::RunLoop().RunUntilIdle(); |
1956 | 1900 |
(...skipping 29 matching lines...) Expand all Loading... |
1986 } | 1930 } |
1987 | 1931 |
1988 TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) { | 1932 TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) { |
1989 base::ScopedTempDir temp_dir; | 1933 base::ScopedTempDir temp_dir; |
1990 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1934 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1991 base::FilePath local_file_path = | 1935 base::FilePath local_file_path = |
1992 temp_dir.path().Append(FILE_PATH_LITERAL("new file.foo")); | 1936 temp_dir.path().Append(FILE_PATH_LITERAL("new file.foo")); |
1993 std::string contents("hogefugapiyo"); | 1937 std::string contents("hogefugapiyo"); |
1994 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents)); | 1938 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents)); |
1995 | 1939 |
1996 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1940 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
1997 "gdata/root_feed.json")); | |
1998 | 1941 |
1999 GDataErrorCode error = GDATA_OTHER_ERROR; | 1942 GDataErrorCode error = GDATA_OTHER_ERROR; |
2000 GURL upload_location; | 1943 GURL upload_location; |
2001 fake_service_.InitiateUploadNewFile( | 1944 fake_service_.InitiateUploadNewFile( |
2002 "test/foo", | 1945 "test/foo", |
2003 contents.size(), | 1946 contents.size(), |
2004 "folder:1_folder_resource_id", | 1947 "folder:1_folder_resource_id", |
2005 "new file.foo", | 1948 "new file.foo", |
2006 FakeDriveService::InitiateUploadNewFileOptions(), | 1949 FakeDriveService::InitiateUploadNewFileOptions(), |
2007 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1950 test_util::CreateCopyResultCallback(&error, &upload_location)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 EXPECT_TRUE(Exists(entry->resource_id())); | 1991 EXPECT_TRUE(Exists(entry->resource_id())); |
2049 ASSERT_TRUE(!upload_progress_values.empty()); | 1992 ASSERT_TRUE(!upload_progress_values.empty()); |
2050 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); | 1993 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); |
2051 EXPECT_LE(0, upload_progress_values.front().first); | 1994 EXPECT_LE(0, upload_progress_values.front().first); |
2052 EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2), | 1995 EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2), |
2053 upload_progress_values.back().first); | 1996 upload_progress_values.back().first); |
2054 EXPECT_EQ(base::MD5String(contents), entry->file_md5()); | 1997 EXPECT_EQ(base::MD5String(contents), entry->file_md5()); |
2055 } | 1998 } |
2056 | 1999 |
2057 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) { | 2000 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) { |
2058 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 2001 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
2059 "gdata/root_feed.json")); | |
2060 | 2002 |
2061 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 2003 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
2062 | 2004 |
2063 const std::string kContentType = "text/plain"; | 2005 const std::string kContentType = "text/plain"; |
2064 const std::string kContentData = "This is some test content."; | 2006 const std::string kContentData = "This is some test content."; |
2065 const std::string kTitle = "new file"; | 2007 const std::string kTitle = "new file"; |
2066 | 2008 |
2067 GDataErrorCode error = GDATA_OTHER_ERROR; | 2009 GDataErrorCode error = GDATA_OTHER_ERROR; |
2068 scoped_ptr<ResourceEntry> resource_entry; | 2010 scoped_ptr<ResourceEntry> resource_entry; |
2069 fake_service_.AddNewFile( | 2011 fake_service_.AddNewFile( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2121 EXPECT_TRUE(HasParent(resource_entry->resource_id(), | 2063 EXPECT_TRUE(HasParent(resource_entry->resource_id(), |
2122 fake_service_.GetRootResourceId())); | 2064 fake_service_.GetRootResourceId())); |
2123 // Should be incremented as a new directory was created. | 2065 // Should be incremented as a new directory was created. |
2124 EXPECT_EQ(old_largest_change_id + 1, | 2066 EXPECT_EQ(old_largest_change_id + 1, |
2125 fake_service_.about_resource().largest_change_id()); | 2067 fake_service_.about_resource().largest_change_id()); |
2126 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 2068 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
2127 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5()); | 2069 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5()); |
2128 } | 2070 } |
2129 | 2071 |
2130 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) { | 2072 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) { |
2131 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 2073 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
2132 "gdata/root_feed.json")); | |
2133 | 2074 |
2134 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 2075 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
2135 | 2076 |
2136 const std::string kContentType = "text/plain"; | 2077 const std::string kContentType = "text/plain"; |
2137 const std::string kContentData = "This is some test content."; | 2078 const std::string kContentData = "This is some test content."; |
2138 const std::string kTitle = "new file"; | 2079 const std::string kTitle = "new file"; |
2139 const std::string kParentResourceId = "folder:1_folder_resource_id"; | 2080 const std::string kParentResourceId = "folder:1_folder_resource_id"; |
2140 | 2081 |
2141 GDataErrorCode error = GDATA_OTHER_ERROR; | 2082 GDataErrorCode error = GDATA_OTHER_ERROR; |
2142 scoped_ptr<ResourceEntry> resource_entry; | 2083 scoped_ptr<ResourceEntry> resource_entry; |
(...skipping 16 matching lines...) Expand all Loading... |
2159 EXPECT_EQ(kTitle, resource_entry->title()); | 2100 EXPECT_EQ(kTitle, resource_entry->title()); |
2160 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId)); | 2101 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId)); |
2161 // Should be incremented as a new directory was created. | 2102 // Should be incremented as a new directory was created. |
2162 EXPECT_EQ(old_largest_change_id + 1, | 2103 EXPECT_EQ(old_largest_change_id + 1, |
2163 fake_service_.about_resource().largest_change_id()); | 2104 fake_service_.about_resource().largest_change_id()); |
2164 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 2105 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
2165 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5()); | 2106 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5()); |
2166 } | 2107 } |
2167 | 2108 |
2168 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) { | 2109 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) { |
2169 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 2110 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
2170 "gdata/root_feed.json")); | |
2171 | 2111 |
2172 const std::string kContentType = "text/plain"; | 2112 const std::string kContentType = "text/plain"; |
2173 const std::string kContentData = "This is some test content."; | 2113 const std::string kContentData = "This is some test content."; |
2174 const std::string kTitle = "new file"; | 2114 const std::string kTitle = "new file"; |
2175 const std::string kParentResourceId = "folder:nonexisting_resource_id"; | 2115 const std::string kParentResourceId = "folder:nonexisting_resource_id"; |
2176 | 2116 |
2177 GDataErrorCode error = GDATA_OTHER_ERROR; | 2117 GDataErrorCode error = GDATA_OTHER_ERROR; |
2178 scoped_ptr<ResourceEntry> resource_entry; | 2118 scoped_ptr<ResourceEntry> resource_entry; |
2179 fake_service_.AddNewFile( | 2119 fake_service_.AddNewFile( |
2180 kContentType, | 2120 kContentType, |
2181 kContentData, | 2121 kContentData, |
2182 kParentResourceId, | 2122 kParentResourceId, |
2183 kTitle, | 2123 kTitle, |
2184 false, // shared_with_me | 2124 false, // shared_with_me |
2185 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 2125 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
2186 base::RunLoop().RunUntilIdle(); | 2126 base::RunLoop().RunUntilIdle(); |
2187 | 2127 |
2188 EXPECT_EQ(HTTP_NOT_FOUND, error); | 2128 EXPECT_EQ(HTTP_NOT_FOUND, error); |
2189 EXPECT_FALSE(resource_entry); | 2129 EXPECT_FALSE(resource_entry); |
2190 } | 2130 } |
2191 | 2131 |
2192 TEST_F(FakeDriveServiceTest, AddNewFile_Offline) { | 2132 TEST_F(FakeDriveServiceTest, AddNewFile_Offline) { |
2193 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 2133 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
2194 "gdata/root_feed.json")); | |
2195 fake_service_.set_offline(true); | 2134 fake_service_.set_offline(true); |
2196 | 2135 |
2197 const std::string kContentType = "text/plain"; | 2136 const std::string kContentType = "text/plain"; |
2198 const std::string kContentData = "This is some test content."; | 2137 const std::string kContentData = "This is some test content."; |
2199 const std::string kTitle = "new file"; | 2138 const std::string kTitle = "new file"; |
2200 | 2139 |
2201 GDataErrorCode error = GDATA_OTHER_ERROR; | 2140 GDataErrorCode error = GDATA_OTHER_ERROR; |
2202 scoped_ptr<ResourceEntry> resource_entry; | 2141 scoped_ptr<ResourceEntry> resource_entry; |
2203 fake_service_.AddNewFile( | 2142 fake_service_.AddNewFile( |
2204 kContentType, | 2143 kContentType, |
2205 kContentData, | 2144 kContentData, |
2206 fake_service_.GetRootResourceId(), | 2145 fake_service_.GetRootResourceId(), |
2207 kTitle, | 2146 kTitle, |
2208 false, // shared_with_me | 2147 false, // shared_with_me |
2209 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 2148 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
2210 base::RunLoop().RunUntilIdle(); | 2149 base::RunLoop().RunUntilIdle(); |
2211 | 2150 |
2212 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 2151 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
2213 EXPECT_FALSE(resource_entry); | 2152 EXPECT_FALSE(resource_entry); |
2214 } | 2153 } |
2215 | 2154 |
2216 TEST_F(FakeDriveServiceTest, AddNewFile_SharedWithMeLabel) { | 2155 TEST_F(FakeDriveServiceTest, AddNewFile_SharedWithMeLabel) { |
2217 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 2156 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
2218 "gdata/root_feed.json")); | |
2219 | 2157 |
2220 const std::string kContentType = "text/plain"; | 2158 const std::string kContentType = "text/plain"; |
2221 const std::string kContentData = "This is some test content."; | 2159 const std::string kContentData = "This is some test content."; |
2222 const std::string kTitle = "new file"; | 2160 const std::string kTitle = "new file"; |
2223 | 2161 |
2224 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 2162 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
2225 | 2163 |
2226 GDataErrorCode error = GDATA_OTHER_ERROR; | 2164 GDataErrorCode error = GDATA_OTHER_ERROR; |
2227 scoped_ptr<ResourceEntry> resource_entry; | 2165 scoped_ptr<ResourceEntry> resource_entry; |
2228 fake_service_.AddNewFile( | 2166 fake_service_.AddNewFile( |
(...skipping 18 matching lines...) Expand all Loading... |
2247 ASSERT_EQ(1U, resource_entry->labels().size()); | 2185 ASSERT_EQ(1U, resource_entry->labels().size()); |
2248 EXPECT_EQ("shared-with-me", resource_entry->labels()[0]); | 2186 EXPECT_EQ("shared-with-me", resource_entry->labels()[0]); |
2249 // Should be incremented as a new directory was created. | 2187 // Should be incremented as a new directory was created. |
2250 EXPECT_EQ(old_largest_change_id + 1, | 2188 EXPECT_EQ(old_largest_change_id + 1, |
2251 fake_service_.about_resource().largest_change_id()); | 2189 fake_service_.about_resource().largest_change_id()); |
2252 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | 2190 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); |
2253 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5()); | 2191 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5()); |
2254 } | 2192 } |
2255 | 2193 |
2256 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) { | 2194 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) { |
2257 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 2195 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
2258 "gdata/root_feed.json")); | |
2259 | 2196 |
2260 const std::string kResourceId = "file:2_file_resource_id"; | 2197 const std::string kResourceId = "file:2_file_resource_id"; |
2261 base::Time time; | 2198 base::Time time; |
2262 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time)); | 2199 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time)); |
2263 | 2200 |
2264 GDataErrorCode error = GDATA_OTHER_ERROR; | 2201 GDataErrorCode error = GDATA_OTHER_ERROR; |
2265 scoped_ptr<ResourceEntry> resource_entry; | 2202 scoped_ptr<ResourceEntry> resource_entry; |
2266 fake_service_.SetLastModifiedTime( | 2203 fake_service_.SetLastModifiedTime( |
2267 kResourceId, | 2204 kResourceId, |
2268 time, | 2205 time, |
2269 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 2206 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
2270 base::RunLoop().RunUntilIdle(); | 2207 base::RunLoop().RunUntilIdle(); |
2271 | 2208 |
2272 EXPECT_EQ(HTTP_SUCCESS, error); | 2209 EXPECT_EQ(HTTP_SUCCESS, error); |
2273 ASSERT_TRUE(resource_entry); | 2210 ASSERT_TRUE(resource_entry); |
2274 EXPECT_EQ(time, resource_entry->updated_time()); | 2211 EXPECT_EQ(time, resource_entry->updated_time()); |
2275 } | 2212 } |
2276 | 2213 |
2277 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_NonexistingFile) { | 2214 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_NonexistingFile) { |
2278 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 2215 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
2279 "gdata/root_feed.json")); | |
2280 | 2216 |
2281 const std::string kResourceId = "file:nonexisting_resource_id"; | 2217 const std::string kResourceId = "file:nonexisting_resource_id"; |
2282 base::Time time; | 2218 base::Time time; |
2283 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time)); | 2219 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time)); |
2284 | 2220 |
2285 GDataErrorCode error = GDATA_OTHER_ERROR; | 2221 GDataErrorCode error = GDATA_OTHER_ERROR; |
2286 scoped_ptr<ResourceEntry> resource_entry; | 2222 scoped_ptr<ResourceEntry> resource_entry; |
2287 fake_service_.SetLastModifiedTime( | 2223 fake_service_.SetLastModifiedTime( |
2288 kResourceId, | 2224 kResourceId, |
2289 time, | 2225 time, |
2290 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 2226 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
2291 base::RunLoop().RunUntilIdle(); | 2227 base::RunLoop().RunUntilIdle(); |
2292 | 2228 |
2293 EXPECT_EQ(HTTP_NOT_FOUND, error); | 2229 EXPECT_EQ(HTTP_NOT_FOUND, error); |
2294 EXPECT_FALSE(resource_entry); | 2230 EXPECT_FALSE(resource_entry); |
2295 } | 2231 } |
2296 | 2232 |
2297 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_Offline) { | 2233 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_Offline) { |
2298 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 2234 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); |
2299 "gdata/root_feed.json")); | |
2300 fake_service_.set_offline(true); | 2235 fake_service_.set_offline(true); |
2301 | 2236 |
2302 const std::string kResourceId = "file:2_file_resource_id"; | 2237 const std::string kResourceId = "file:2_file_resource_id"; |
2303 base::Time time; | 2238 base::Time time; |
2304 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time)); | 2239 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time)); |
2305 | 2240 |
2306 GDataErrorCode error = GDATA_OTHER_ERROR; | 2241 GDataErrorCode error = GDATA_OTHER_ERROR; |
2307 scoped_ptr<ResourceEntry> resource_entry; | 2242 scoped_ptr<ResourceEntry> resource_entry; |
2308 fake_service_.SetLastModifiedTime( | 2243 fake_service_.SetLastModifiedTime( |
2309 kResourceId, | 2244 kResourceId, |
2310 time, | 2245 time, |
2311 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 2246 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
2312 base::RunLoop().RunUntilIdle(); | 2247 base::RunLoop().RunUntilIdle(); |
2313 | 2248 |
2314 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 2249 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
2315 EXPECT_FALSE(resource_entry); | 2250 EXPECT_FALSE(resource_entry); |
2316 } | 2251 } |
2317 | 2252 |
2318 } // namespace | 2253 } // namespace |
2319 | 2254 |
2320 } // namespace drive | 2255 } // namespace drive |
OLD | NEW |