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

Side by Side Diff: chrome/browser/chromeos/drive/fake_file_system_unittest.cc

Issue 16107004: drive: Stop returning FilePath from GetResourceEntryById (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/drive/fake_file_system.h" 5 #include "chrome/browser/chromeos/drive/fake_file_system.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/chromeos/drive/file_system_util.h" 9 #include "chrome/browser/chromeos/drive/file_system_util.h"
10 #include "chrome/browser/google_apis/fake_drive_service.h" 10 #include "chrome/browser/google_apis/fake_drive_service.h"
(...skipping 28 matching lines...) Expand all
39 base::MessageLoopForUI message_loop_; 39 base::MessageLoopForUI message_loop_;
40 content::TestBrowserThread ui_thread_; 40 content::TestBrowserThread ui_thread_;
41 41
42 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; 42 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_;
43 scoped_ptr<FakeFileSystem> fake_file_system_; 43 scoped_ptr<FakeFileSystem> fake_file_system_;
44 }; 44 };
45 45
46 TEST_F(FakeFileSystemTest, GetResourceEntryById) { 46 TEST_F(FakeFileSystemTest, GetResourceEntryById) {
47 FileError error = FILE_ERROR_FAILED; 47 FileError error = FILE_ERROR_FAILED;
48 scoped_ptr<ResourceEntry> entry; 48 scoped_ptr<ResourceEntry> entry;
49 base::FilePath file_path; 49 const std::string resource_id = "folder:sub_dir_folder_resource_id";
50 50
51 fake_file_system_->GetResourceEntryById( 51 fake_file_system_->GetResourceEntryById(
52 "folder:sub_dir_folder_resource_id", 52 resource_id,
53 google_apis::test_util::CreateCopyResultCallback(
54 &error, &file_path, &entry));
55 google_apis::test_util::RunBlockingPoolTask();
56
57 ASSERT_EQ(FILE_ERROR_OK, error);
58 EXPECT_EQ(
59 util::GetDriveMyDriveRootPath().AppendASCII(
60 "Directory 1/Sub Directory Folder"),
61 file_path);
62 EXPECT_TRUE(entry); // Just make sure something is returned.
63 }
64
65 TEST_F(FakeFileSystemTest,
66 GetResourceEntryById_PathCompatibleWithGetResourceEntryByPath) {
67 const std::string document_resource_id = "document:5_document_resource_id";
68
69 FileError error = FILE_ERROR_FAILED;
70 scoped_ptr<ResourceEntry> entry;
71 base::FilePath file_path;
72
73 // Get resource entry by resource id.
74 fake_file_system_->GetResourceEntryById(
75 document_resource_id,
76 google_apis::test_util::CreateCopyResultCallback(
77 &error, &file_path, &entry));
78 google_apis::test_util::RunBlockingPoolTask();
79
80 ASSERT_EQ(FILE_ERROR_OK, error);
81 ASSERT_TRUE(entry);
82 EXPECT_TRUE(entry->file_specific_info().is_hosted_document());
83
84 // Get resource entry by path given by GetResourceEntryById.
85 error = FILE_ERROR_FAILED;
86 entry.reset();
87 fake_file_system_->GetResourceEntryByPath(
88 file_path,
89 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 53 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
90 google_apis::test_util::RunBlockingPoolTask(); 54 google_apis::test_util::RunBlockingPoolTask();
91 55
92 ASSERT_EQ(FILE_ERROR_OK, error); 56 ASSERT_EQ(FILE_ERROR_OK, error);
93 ASSERT_TRUE(entry); 57 EXPECT_EQ(resource_id, entry->resource_id());
94 EXPECT_EQ(document_resource_id, entry->resource_id());
95 } 58 }
96 59
97 TEST_F(FakeFileSystemTest, GetFileContentByPath) { 60 TEST_F(FakeFileSystemTest, GetFileContentByPath) {
98 FileError initialize_error = FILE_ERROR_FAILED; 61 FileError initialize_error = FILE_ERROR_FAILED;
99 scoped_ptr<ResourceEntry> entry; 62 scoped_ptr<ResourceEntry> entry;
100 base::FilePath cache_file_path; 63 base::FilePath cache_file_path;
101 base::Closure cancel_download; 64 base::Closure cancel_download;
102 google_apis::test_util::TestGetContentCallback get_content_callback; 65 google_apis::test_util::TestGetContentCallback get_content_callback;
103 FileError completion_error = FILE_ERROR_FAILED; 66 FileError completion_error = FILE_ERROR_FAILED;
104 67
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 util::GetDriveMyDriveRootPath().AppendASCII("Invalid File Name"), 175 util::GetDriveMyDriveRootPath().AppendASCII("Invalid File Name"),
213 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 176 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
214 google_apis::test_util::RunBlockingPoolTask(); 177 google_apis::test_util::RunBlockingPoolTask();
215 178
216 ASSERT_EQ(FILE_ERROR_NOT_FOUND, error); 179 ASSERT_EQ(FILE_ERROR_NOT_FOUND, error);
217 ASSERT_FALSE(entry); 180 ASSERT_FALSE(entry);
218 } 181 }
219 182
220 } // namespace test_util 183 } // namespace test_util
221 } // namespace drive 184 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/fake_file_system.cc ('k') | chrome/browser/chromeos/drive/file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698