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

Side by Side Diff: components/drive/service/fake_drive_service_unittest.cc

Issue 2910913002: WIP.
Patch Set: rebase Created 3 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
« no previous file with comments | « components/drive/service/fake_drive_service.cc ('k') | google_apis/drive/drive_api_requests.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/drive/service/fake_drive_service.h" 5 #include "components/drive/service/fake_drive_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 EXPECT_EQ(DRIVE_NO_CONNECTION, error); 151 EXPECT_EQ(DRIVE_NO_CONNECTION, error);
152 EXPECT_FALSE(file_list); 152 EXPECT_FALSE(file_list);
153 } 153 }
154 154
155 TEST_F(FakeDriveServiceTest, GetFileListInDirectory_InRootDirectory) { 155 TEST_F(FakeDriveServiceTest, GetFileListInDirectory_InRootDirectory) {
156 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); 156 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
157 157
158 DriveApiErrorCode error = DRIVE_OTHER_ERROR; 158 DriveApiErrorCode error = DRIVE_OTHER_ERROR;
159 std::unique_ptr<FileList> file_list; 159 std::unique_ptr<FileList> file_list;
160 fake_service_.GetFileListInDirectory( 160 fake_service_.GetFileListInDirectory(
161 fake_service_.GetRootResourceId(), 161 fake_service_.GetRootResourceId(), "" /* team_drive_id */,
162 test_util::CreateCopyResultCallback(&error, &file_list)); 162 test_util::CreateCopyResultCallback(&error, &file_list));
163 base::RunLoop().RunUntilIdle(); 163 base::RunLoop().RunUntilIdle();
164 164
165 EXPECT_EQ(HTTP_SUCCESS, error); 165 EXPECT_EQ(HTTP_SUCCESS, error);
166 ASSERT_TRUE(file_list); 166 ASSERT_TRUE(file_list);
167 // Do some sanity check. There are 8 entries in the root directory. 167 // Do some sanity check. There are 8 entries in the root directory.
168 EXPECT_EQ(8U, file_list->items().size()); 168 EXPECT_EQ(8U, file_list->items().size());
169 EXPECT_EQ(1, fake_service_.directory_load_count()); 169 EXPECT_EQ(1, fake_service_.directory_load_count());
170 } 170 }
171 171
172 TEST_F(FakeDriveServiceTest, GetFileListInDirectory_InNonRootDirectory) { 172 TEST_F(FakeDriveServiceTest, GetFileListInDirectory_InNonRootDirectory) {
173 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); 173 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
174 174
175 DriveApiErrorCode error = DRIVE_OTHER_ERROR; 175 DriveApiErrorCode error = DRIVE_OTHER_ERROR;
176 std::unique_ptr<FileList> file_list; 176 std::unique_ptr<FileList> file_list;
177 fake_service_.GetFileListInDirectory( 177 fake_service_.GetFileListInDirectory(
178 "1_folder_resource_id", 178 "1_folder_resource_id", "" /* team_drive_id */,
179 test_util::CreateCopyResultCallback(&error, &file_list)); 179 test_util::CreateCopyResultCallback(&error, &file_list));
180 base::RunLoop().RunUntilIdle(); 180 base::RunLoop().RunUntilIdle();
181 181
182 EXPECT_EQ(HTTP_SUCCESS, error); 182 EXPECT_EQ(HTTP_SUCCESS, error);
183 ASSERT_TRUE(file_list); 183 ASSERT_TRUE(file_list);
184 // Do some sanity check. There is three entries in 1_folder_resource_id 184 // Do some sanity check. There is three entries in 1_folder_resource_id
185 // directory. 185 // directory.
186 EXPECT_EQ(3U, file_list->items().size()); 186 EXPECT_EQ(3U, file_list->items().size());
187 EXPECT_EQ(1, fake_service_.directory_load_count()); 187 EXPECT_EQ(1, fake_service_.directory_load_count());
188 } 188 }
189 189
190 TEST_F(FakeDriveServiceTest, GetFileListInDirectory_Offline) { 190 TEST_F(FakeDriveServiceTest, GetFileListInDirectory_Offline) {
191 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); 191 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
192 fake_service_.set_offline(true); 192 fake_service_.set_offline(true);
193 193
194 DriveApiErrorCode error = DRIVE_OTHER_ERROR; 194 DriveApiErrorCode error = DRIVE_OTHER_ERROR;
195 std::unique_ptr<FileList> file_list; 195 std::unique_ptr<FileList> file_list;
196 fake_service_.GetFileListInDirectory( 196 fake_service_.GetFileListInDirectory(
197 fake_service_.GetRootResourceId(), 197 fake_service_.GetRootResourceId(), "" /* team_drive_id */,
198 test_util::CreateCopyResultCallback(&error, &file_list)); 198 test_util::CreateCopyResultCallback(&error, &file_list));
199 base::RunLoop().RunUntilIdle(); 199 base::RunLoop().RunUntilIdle();
200 200
201 EXPECT_EQ(DRIVE_NO_CONNECTION, error); 201 EXPECT_EQ(DRIVE_NO_CONNECTION, error);
202 EXPECT_FALSE(file_list); 202 EXPECT_FALSE(file_list);
203 } 203 }
204 204
205 TEST_F(FakeDriveServiceTest, Search) { 205 TEST_F(FakeDriveServiceTest, Search) {
206 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); 206 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
207 207
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 EXPECT_EQ(1, fake_service_.file_list_load_count()); 599 EXPECT_EQ(1, fake_service_.file_list_load_count());
600 } 600 }
601 601
602 TEST_F(FakeDriveServiceTest, GetRemainingFileList_GetFileListInDirectory) { 602 TEST_F(FakeDriveServiceTest, GetRemainingFileList_GetFileListInDirectory) {
603 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_)); 603 ASSERT_TRUE(test_util::SetUpTestEntries(&fake_service_));
604 fake_service_.set_default_max_results(3); 604 fake_service_.set_default_max_results(3);
605 605
606 DriveApiErrorCode error = DRIVE_OTHER_ERROR; 606 DriveApiErrorCode error = DRIVE_OTHER_ERROR;
607 std::unique_ptr<FileList> file_list; 607 std::unique_ptr<FileList> file_list;
608 fake_service_.GetFileListInDirectory( 608 fake_service_.GetFileListInDirectory(
609 fake_service_.GetRootResourceId(), 609 fake_service_.GetRootResourceId(), "" /* team_drive_id */,
610 test_util::CreateCopyResultCallback(&error, &file_list)); 610 test_util::CreateCopyResultCallback(&error, &file_list));
611 base::RunLoop().RunUntilIdle(); 611 base::RunLoop().RunUntilIdle();
612 EXPECT_EQ(HTTP_SUCCESS, error); 612 EXPECT_EQ(HTTP_SUCCESS, error);
613 ASSERT_TRUE(file_list); 613 ASSERT_TRUE(file_list);
614 614
615 // Do some sanity check. 615 // Do some sanity check.
616 // The number of results is 8 entries. Thus, it should split into three 616 // The number of results is 8 entries. Thus, it should split into three
617 // chunks: 3, 3, and then 2. 617 // chunks: 3, 3, and then 2.
618 EXPECT_EQ(3U, file_list->items().size()); 618 EXPECT_EQ(3U, file_list->items().size());
619 EXPECT_EQ(1, fake_service_.directory_load_count()); 619 EXPECT_EQ(1, fake_service_.directory_load_count());
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 test_util::CreateCopyResultCallback(&error, &entry)); 2217 test_util::CreateCopyResultCallback(&error, &entry));
2218 base::RunLoop().RunUntilIdle(); 2218 base::RunLoop().RunUntilIdle();
2219 2219
2220 EXPECT_EQ(DRIVE_NO_CONNECTION, error); 2220 EXPECT_EQ(DRIVE_NO_CONNECTION, error);
2221 EXPECT_FALSE(entry); 2221 EXPECT_FALSE(entry);
2222 } 2222 }
2223 2223
2224 } // namespace 2224 } // namespace
2225 2225
2226 } // namespace drive 2226 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/service/fake_drive_service.cc ('k') | google_apis/drive/drive_api_requests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698