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/chromeos/gdata/gdata_directory_service.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 317 |
318 TEST(GDataDirectoryServiceTest, GetEntryInfoByResourceId) { | 318 TEST(GDataDirectoryServiceTest, GetEntryInfoByResourceId) { |
319 MessageLoopForUI message_loop; | 319 MessageLoopForUI message_loop; |
320 content::TestBrowserThread ui_thread(content::BrowserThread::UI, | 320 content::TestBrowserThread ui_thread(content::BrowserThread::UI, |
321 &message_loop); | 321 &message_loop); |
322 GDataDirectoryService directory_service; | 322 GDataDirectoryService directory_service; |
323 InitDirectoryService(&directory_service); | 323 InitDirectoryService(&directory_service); |
324 | 324 |
325 // Confirm that an existing file is found. | 325 // Confirm that an existing file is found. |
326 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 326 GDataFileError error = GDATA_FILE_ERROR_FAILED; |
| 327 FilePath drive_file_path; |
327 scoped_ptr<GDataEntryProto> entry_proto; | 328 scoped_ptr<GDataEntryProto> entry_proto; |
328 directory_service.GetEntryInfoByResourceId( | 329 directory_service.GetEntryInfoByResourceId( |
329 "file_resource_id:file4", | 330 "file_resource_id:file4", |
330 base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback, | 331 base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback, |
331 &error, &entry_proto)); | 332 &error, &drive_file_path, &entry_proto)); |
332 test_util::RunBlockingPoolTask(); | 333 test_util::RunBlockingPoolTask(); |
333 EXPECT_EQ(GDATA_FILE_OK, error); | 334 EXPECT_EQ(GDATA_FILE_OK, error); |
| 335 EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/dir1/file4"), drive_file_path); |
334 ASSERT_TRUE(entry_proto.get()); | 336 ASSERT_TRUE(entry_proto.get()); |
335 EXPECT_EQ("file4", entry_proto->base_name()); | 337 EXPECT_EQ("file4", entry_proto->base_name()); |
336 | 338 |
337 // Confirm that a non existing file is not found. | 339 // Confirm that a non existing file is not found. |
338 error = GDATA_FILE_ERROR_FAILED; | 340 error = GDATA_FILE_ERROR_FAILED; |
339 entry_proto.reset(); | 341 entry_proto.reset(); |
340 directory_service.GetEntryInfoByResourceId( | 342 directory_service.GetEntryInfoByResourceId( |
341 "file:non_existing", | 343 "file:non_existing", |
342 base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback, | 344 base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback, |
343 &error, &entry_proto)); | 345 &error, &drive_file_path, &entry_proto)); |
344 test_util::RunBlockingPoolTask(); | 346 test_util::RunBlockingPoolTask(); |
345 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, error); | 347 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, error); |
346 EXPECT_FALSE(entry_proto.get()); | 348 EXPECT_FALSE(entry_proto.get()); |
347 } | 349 } |
348 | 350 |
349 TEST(GDataDirectoryServiceTest, GetEntryInfoByPath) { | 351 TEST(GDataDirectoryServiceTest, GetEntryInfoByPath) { |
350 MessageLoopForUI message_loop; | 352 MessageLoopForUI message_loop; |
351 content::TestBrowserThread ui_thread(content::BrowserThread::UI, | 353 content::TestBrowserThread ui_thread(content::BrowserThread::UI, |
352 &message_loop); | 354 &message_loop); |
353 GDataDirectoryService directory_service; | 355 GDataDirectoryService directory_service; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 GDataDirectoryService directory_service2; | 526 GDataDirectoryService directory_service2; |
525 // InitFromDB should succeed with GDATA_FILE_OK as the db now exists. | 527 // InitFromDB should succeed with GDATA_FILE_OK as the db now exists. |
526 directory_service2.InitFromDB(db_path, blocking_task_runner, | 528 directory_service2.InitFromDB(db_path, blocking_task_runner, |
527 base::Bind(&InitFromDBCallback, GDATA_FILE_OK)); | 529 base::Bind(&InitFromDBCallback, GDATA_FILE_OK)); |
528 test_util::RunBlockingPoolTask(); | 530 test_util::RunBlockingPoolTask(); |
529 | 531 |
530 VerifyDirectoryService(&directory_service2); | 532 VerifyDirectoryService(&directory_service2); |
531 } | 533 } |
532 | 534 |
533 } // namespace gdata | 535 } // namespace gdata |
OLD | NEW |