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

Unified Diff: chrome/browser/google_apis/fake_drive_service_unittest.cc

Issue 12017026: drive: Add support for pagenation to FakeDriveService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/google_apis/fake_drive_service.cc ('k') | chrome/browser/google_apis/gdata_wapi_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/fake_drive_service_unittest.cc
diff --git a/chrome/browser/google_apis/fake_drive_service_unittest.cc b/chrome/browser/google_apis/fake_drive_service_unittest.cc
index ffbe6bc58a3530b6fe83c519db5ae4118f8e5cf4..61252f6101d719fa61baf9b3ddd664d700f4094a 100644
--- a/chrome/browser/google_apis/fake_drive_service_unittest.cc
+++ b/chrome/browser/google_apis/fake_drive_service_unittest.cc
@@ -86,6 +86,91 @@ TEST_F(FakeDriveServiceTest, GetResourceList_All) {
EXPECT_EQ(1, fake_service_.resource_list_load_count());
}
+TEST_F(FakeDriveServiceTest, GetResourceList_WithStartIndex) {
+ ASSERT_TRUE(fake_service_.LoadResourceListForWapi("gdata/root_feed.json"));
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ scoped_ptr<ResourceList> resource_list;
+ fake_service_.GetResourceList(
+ GURL("http://dummyurl/?start-offset=2"),
+ 0, // start_changestamp
+ "", // search_query
+ false, // shared_with_me
+ "", // directory_resource_id
+ base::Bind(&test_util::CopyResultsFromGetResourceListCallback,
+ &error,
+ &resource_list));
+ message_loop_.RunUntilIdle();
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ ASSERT_TRUE(resource_list);
+ // Because the start-offset was set to 2, the size should be 10 instead of
+ // 12 (the total number).
+ EXPECT_EQ(10U, resource_list->entries().size());
+ EXPECT_EQ(1, fake_service_.resource_list_load_count());
+}
+
+TEST_F(FakeDriveServiceTest, GetResourceList_WithStartIndexAndMaxResults) {
+ ASSERT_TRUE(fake_service_.LoadResourceListForWapi("gdata/root_feed.json"));
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ scoped_ptr<ResourceList> resource_list;
+ fake_service_.GetResourceList(
+ GURL("http://localhost/?start-offset=2&max-results=5"),
+ 0, // start_changestamp
+ "", // search_query
+ false, // shared_with_me
+ "", // directory_resource_id
+ base::Bind(&test_util::CopyResultsFromGetResourceListCallback,
+ &error,
+ &resource_list));
+ message_loop_.RunUntilIdle();
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ ASSERT_TRUE(resource_list);
+ // Because the max-results was set to 5, the size should be 5 instead of 10.
+ EXPECT_EQ(5U, resource_list->entries().size());
+ EXPECT_EQ(1, fake_service_.resource_list_load_count());
+ // The next link should be provided. The new start-offset should be
+ // 2 (original start index) + 5 (max results).
+ const google_apis::Link* next_link =
+ resource_list->GetLinkByType(Link::LINK_NEXT);
+ ASSERT_TRUE(next_link);
+ EXPECT_EQ(GURL("http://localhost/?start-offset=7&max-results=5"),
+ next_link->href());
+}
+
+TEST_F(FakeDriveServiceTest, GetResourceList_WithDefaultMaxResultsChanged) {
+ ASSERT_TRUE(fake_service_.LoadResourceListForWapi("gdata/root_feed.json"));
+ fake_service_.set_default_max_results(3);
+
+ GDataErrorCode error = GDATA_OTHER_ERROR;
+ scoped_ptr<ResourceList> resource_list;
+ fake_service_.GetResourceList(
+ GURL(),
+ 0, // start_changestamp
+ "", // search_query
+ false, // shared_with_me
+ "", // directory_resource_id
+ base::Bind(&test_util::CopyResultsFromGetResourceListCallback,
+ &error,
+ &resource_list));
+ message_loop_.RunUntilIdle();
+
+ EXPECT_EQ(HTTP_SUCCESS, error);
+ ASSERT_TRUE(resource_list);
+ // Because the default max results was changed to 3, the size should be 3
+ // instead of 12 (the total number).
+ EXPECT_EQ(3U, resource_list->entries().size());
+ EXPECT_EQ(1, fake_service_.resource_list_load_count());
+ // The next link should be provided.
+ const google_apis::Link* next_link =
+ resource_list->GetLinkByType(Link::LINK_NEXT);
+ ASSERT_TRUE(next_link);
+ EXPECT_EQ(GURL("http://localhost/?start-offset=3&max-results=3"),
+ next_link->href());
+}
+
TEST_F(FakeDriveServiceTest, GetResourceList_InRootDirectory) {
ASSERT_TRUE(fake_service_.LoadResourceListForWapi("gdata/root_feed.json"));
« no previous file with comments | « chrome/browser/google_apis/fake_drive_service.cc ('k') | chrome/browser/google_apis/gdata_wapi_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698