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

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_url_util_unittest.cc

Issue 11418084: google_apis: Introduce GDataWapiUrlGenerator class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years 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
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_url_util.cc ('k') | no next file » | 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 "chrome/browser/google_apis/gdata_wapi_url_util.h" 5 #include "chrome/browser/google_apis/gdata_wapi_url_util.h"
6 6
7 #include "googleurl/src/gurl.h" 7 #include "googleurl/src/gurl.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace google_apis { 10 namespace google_apis {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 "&include-installed-apps=true" 43 "&include-installed-apps=true"
44 "&start-index=123" 44 "&start-index=123"
45 "&q=%22foo+bar%22", 45 "&q=%22foo+bar%22",
46 AddFeedUrlParams(GURL("http://www.example.com"), 46 AddFeedUrlParams(GURL("http://www.example.com"),
47 100, // num_items_to_fetch 47 100, // num_items_to_fetch
48 123, // changestamp 48 123, // changestamp
49 "\"foo bar\"" // search_string 49 "\"foo bar\"" // search_string
50 ).spec()); 50 ).spec());
51 } 51 }
52 52
53 TEST(GDataWapiUrlUtilTest, GenerateDocumentListUrl) { 53 } // namespace gdata_wapi_url_util
54
55 // TODO(satorux): Move the following test code to a separate file
56 // gdata_wapi_url_generator_unittest.cc.
57 class GDataWapiUrlGeneratorTest : public testing::Test {
58 public:
59 GDataWapiUrlGeneratorTest()
60 : url_generator_(GURL(gdata_wapi_url_util::kBaseUrlForProduction)) {
61 }
62
63 protected:
64 GDataWapiUrlGenerator url_generator_;
65 };
66
67 TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) {
54 // This is the very basic URL for the GetDocuments operation. 68 // This is the very basic URL for the GetDocuments operation.
55 EXPECT_EQ( 69 EXPECT_EQ(
56 "https://docs.google.com/feeds/default/private/full/-/mine" 70 "https://docs.google.com/feeds/default/private/full/-/mine"
57 "?v=3&alt=json&showfolders=true&max-results=500" 71 "?v=3&alt=json&showfolders=true&max-results=500"
58 "&include-installed-apps=true", 72 "&include-installed-apps=true",
59 GenerateDocumentListUrl(GURL(), // override_url, 73 url_generator_.GenerateDocumentListUrl(GURL(), // override_url,
60 0, // start_changestamp, 74 0, // start_changestamp,
61 "", // search_string, 75 "", // search_string,
62 false, // shared_with_me, 76 false, // shared_with_me,
63 "" // directory resource ID 77 "" // directory resource ID
64 ).spec()); 78 ).spec());
65 79
66 // With an override URL provided, the base URL is changed, but the default 80 // With an override URL provided, the base URL is changed, but the default
67 // parameters remain as-is. 81 // parameters remain as-is.
68 EXPECT_EQ( 82 EXPECT_EQ(
69 "http://localhost/" 83 "http://localhost/"
70 "?v=3&alt=json&showfolders=true&max-results=500" 84 "?v=3&alt=json&showfolders=true&max-results=500"
71 "&include-installed-apps=true", 85 "&include-installed-apps=true",
72 GenerateDocumentListUrl(GURL("http://localhost/"), // override_url, 86 url_generator_.GenerateDocumentListUrl(
73 0, // start_changestamp, 87 GURL("http://localhost/"), // override_url,
74 "", // search_string, 88 0, // start_changestamp,
75 false, // shared_with_me, 89 "", // search_string,
76 "" // directory resource ID 90 false, // shared_with_me,
77 ).spec()); 91 "" // directory resource ID
92 ).spec());
78 93
79 // With a non-zero start_changestamp provided, the base URL is changed from 94 // With a non-zero start_changestamp provided, the base URL is changed from
80 // "full/-/mine" to "changes", and "start-index" parameter is added. 95 // "full/-/mine" to "changes", and "start-index" parameter is added.
81 EXPECT_EQ( 96 EXPECT_EQ(
82 "https://docs.google.com/feeds/default/private/changes" 97 "https://docs.google.com/feeds/default/private/changes"
83 "?v=3&alt=json&showfolders=true&max-results=500" 98 "?v=3&alt=json&showfolders=true&max-results=500"
84 "&include-installed-apps=true" 99 "&include-installed-apps=true"
85 "&start-index=100", 100 "&start-index=100",
86 GenerateDocumentListUrl(GURL(), // override_url, 101 url_generator_.GenerateDocumentListUrl(GURL(), // override_url,
87 100, // start_changestamp, 102 100, // start_changestamp,
88 "", // search_string, 103 "", // search_string,
89 false, // shared_with_me, 104 false, // shared_with_me,
90 "" // directory resource ID 105 "" // directory resource ID
91 ).spec()); 106 ).spec());
92 107
93 // With a non-empty search string provided, "max-results" value is changed, 108 // With a non-empty search string provided, "max-results" value is changed,
94 // and "q" parameter is added. 109 // and "q" parameter is added.
95 EXPECT_EQ( 110 EXPECT_EQ(
96 "https://docs.google.com/feeds/default/private/full/-/mine" 111 "https://docs.google.com/feeds/default/private/full/-/mine"
97 "?v=3&alt=json&showfolders=true&max-results=50" 112 "?v=3&alt=json&showfolders=true&max-results=50"
98 "&include-installed-apps=true&q=foo", 113 "&include-installed-apps=true&q=foo",
99 GenerateDocumentListUrl(GURL(), // override_url, 114 url_generator_.GenerateDocumentListUrl(GURL(), // override_url,
100 0, // start_changestamp, 115 0, // start_changestamp,
101 "foo", // search_string, 116 "foo", // search_string,
102 false, // shared_with_me, 117 false, // shared_with_me,
103 "" // directory resource ID 118 "" // directory resource ID
104 ).spec()); 119 ).spec());
105 120
106 // With shared_with_me parameter set to true, the base URL is changed, but 121 // With shared_with_me parameter set to true, the base URL is changed, but
107 // the default parameters remain. 122 // the default parameters remain.
108 EXPECT_EQ( 123 EXPECT_EQ(
109 "https://docs.google.com/feeds/default/private/full/-/shared-with-me" 124 "https://docs.google.com/feeds/default/private/full/-/shared-with-me"
110 "?v=3&alt=json&showfolders=true&max-results=500" 125 "?v=3&alt=json&showfolders=true&max-results=500"
111 "&include-installed-apps=true", 126 "&include-installed-apps=true",
112 GenerateDocumentListUrl(GURL(), // override_url, 127 url_generator_.GenerateDocumentListUrl(GURL(), // override_url,
113 0, // start_changestamp, 128 0, // start_changestamp,
114 "", // search_string, 129 "", // search_string,
115 true, // shared_with_me, 130 true, // shared_with_me,
116 "" // directory resource ID 131 "" // directory resource ID
117 ).spec()); 132 ).spec());
118 133
119 // With a non-empty directory resource ID provided, the base URL is 134 // With a non-empty directory resource ID provided, the base URL is
120 // changed, but the default parameters remain. 135 // changed, but the default parameters remain.
121 EXPECT_EQ( 136 EXPECT_EQ(
122 "https://docs.google.com/feeds/default/private/full/XXX/contents/-/mine" 137 "https://docs.google.com/feeds/default/private/full/XXX/contents/-/mine"
123 "?v=3&alt=json&showfolders=true&max-results=500" 138 "?v=3&alt=json&showfolders=true&max-results=500"
124 "&include-installed-apps=true", 139 "&include-installed-apps=true",
125 GenerateDocumentListUrl(GURL(), // override_url, 140 url_generator_.GenerateDocumentListUrl(GURL(), // override_url,
126 0, // start_changestamp, 141 0, // start_changestamp,
127 "", // search_string, 142 "", // search_string,
128 false, // shared_with_me, 143 false, // shared_with_me,
129 "XXX" // directory resource ID 144 "XXX" // directory resource ID
130 ).spec()); 145 ).spec());
131 } 146 }
132 147
133 TEST(GDataWapiUrlUtilTest, GenerateDocumentEntryUrl) { 148 TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentEntryUrl) {
134 EXPECT_EQ( 149 EXPECT_EQ(
135 "https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json", 150 "https://docs.google.com/feeds/default/private/full/XXX?v=3&alt=json",
136 GenerateDocumentEntryUrl("XXX").spec()); 151 url_generator_.GenerateDocumentEntryUrl("XXX").spec());
137 } 152 }
138 153
139 TEST(GDataWapiUrlUtilTest, GenerateDocumentListRootUrl) { 154 TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListRootUrl) {
140 EXPECT_EQ( 155 EXPECT_EQ(
141 "https://docs.google.com/feeds/default/private/full?v=3&alt=json", 156 "https://docs.google.com/feeds/default/private/full?v=3&alt=json",
142 GenerateDocumentListRootUrl().spec()); 157 url_generator_.GenerateDocumentListRootUrl().spec());
143 } 158 }
144 159
145 TEST(GDataWapiUrlUtilTest, GenerateAccountMetadataUrl) { 160 TEST_F(GDataWapiUrlGeneratorTest, GenerateAccountMetadataUrl) {
146 EXPECT_EQ( 161 EXPECT_EQ(
147 "https://docs.google.com/feeds/metadata/default" 162 "https://docs.google.com/feeds/metadata/default"
148 "?v=3&alt=json&include-installed-apps=true", 163 "?v=3&alt=json&include-installed-apps=true",
149 GenerateAccountMetadataUrl().spec()); 164 url_generator_.GenerateAccountMetadataUrl().spec());
150 } 165 }
151 166
152
153 } // namespace gdata_wapi_url_util
154 } // namespace google_apis 167 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_url_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698