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/google_apis/gdata_wapi_url_util.h" | 5 #include "chrome/browser/google_apis/gdata_wapi_url_generator.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 { |
11 namespace gdata_wapi_url_util { | |
12 | 11 |
13 TEST(GDataWapiUrlUtilTest, AddStandardUrlParams) { | |
14 EXPECT_EQ("http://www.example.com/?v=3&alt=json", | |
15 AddStandardUrlParams(GURL("http://www.example.com")).spec()); | |
16 } | |
17 | |
18 TEST(GDataWapiUrlUtilTest, AddMetadataUrlParams) { | |
19 EXPECT_EQ("http://www.example.com/?v=3&alt=json&include-installed-apps=true", | |
20 AddMetadataUrlParams(GURL("http://www.example.com")).spec()); | |
21 } | |
22 | |
23 TEST(GDataWapiUrlUtilTest, AddFeedUrlParams) { | |
24 EXPECT_EQ("http://www.example.com/?v=3&alt=json&showfolders=true" | |
25 "&max-results=100" | |
26 "&include-installed-apps=true", | |
27 AddFeedUrlParams(GURL("http://www.example.com"), | |
28 100, // num_items_to_fetch | |
29 0, // changestamp | |
30 "" // search_string | |
31 ).spec()); | |
32 EXPECT_EQ("http://www.example.com/?v=3&alt=json&showfolders=true" | |
33 "&max-results=100" | |
34 "&include-installed-apps=true" | |
35 "&start-index=123", | |
36 AddFeedUrlParams(GURL("http://www.example.com"), | |
37 100, // num_items_to_fetch | |
38 123, // changestamp | |
39 "" // search_string | |
40 ).spec()); | |
41 EXPECT_EQ("http://www.example.com/?v=3&alt=json&showfolders=true" | |
42 "&max-results=100" | |
43 "&include-installed-apps=true" | |
44 "&start-index=123" | |
45 "&q=%22foo+bar%22", | |
46 AddFeedUrlParams(GURL("http://www.example.com"), | |
47 100, // num_items_to_fetch | |
48 123, // changestamp | |
49 "\"foo bar\"" // search_string | |
50 ).spec()); | |
51 } | |
52 | |
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 { | 12 class GDataWapiUrlGeneratorTest : public testing::Test { |
58 public: | 13 public: |
59 GDataWapiUrlGeneratorTest() | 14 GDataWapiUrlGeneratorTest() |
60 : url_generator_(GURL(gdata_wapi_url_util::kBaseUrlForProduction)) { | 15 : url_generator_(GURL(GDataWapiUrlGenerator::kBaseUrlForProduction)) { |
61 } | 16 } |
62 | 17 |
63 protected: | 18 protected: |
64 GDataWapiUrlGenerator url_generator_; | 19 GDataWapiUrlGenerator url_generator_; |
65 }; | 20 }; |
66 | 21 |
| 22 TEST_F(GDataWapiUrlGeneratorTest, AddStandardUrlParams) { |
| 23 EXPECT_EQ("http://www.example.com/?v=3&alt=json", |
| 24 GDataWapiUrlGenerator::AddStandardUrlParams( |
| 25 GURL("http://www.example.com")).spec()); |
| 26 } |
| 27 |
| 28 TEST_F(GDataWapiUrlGeneratorTest, AddMetadataUrlParams) { |
| 29 EXPECT_EQ("http://www.example.com/?v=3&alt=json&include-installed-apps=true", |
| 30 GDataWapiUrlGenerator::AddMetadataUrlParams( |
| 31 GURL("http://www.example.com")).spec()); |
| 32 } |
| 33 |
| 34 TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) { |
| 35 EXPECT_EQ("http://www.example.com/?v=3&alt=json&showfolders=true" |
| 36 "&max-results=100" |
| 37 "&include-installed-apps=true", |
| 38 GDataWapiUrlGenerator::AddFeedUrlParams( |
| 39 GURL("http://www.example.com"), |
| 40 100, // num_items_to_fetch |
| 41 0, // changestamp |
| 42 "" // search_string |
| 43 ).spec()); |
| 44 EXPECT_EQ("http://www.example.com/?v=3&alt=json&showfolders=true" |
| 45 "&max-results=100" |
| 46 "&include-installed-apps=true" |
| 47 "&start-index=123", |
| 48 GDataWapiUrlGenerator::AddFeedUrlParams( |
| 49 GURL("http://www.example.com"), |
| 50 100, // num_items_to_fetch |
| 51 123, // changestamp |
| 52 "" // search_string |
| 53 ).spec()); |
| 54 EXPECT_EQ("http://www.example.com/?v=3&alt=json&showfolders=true" |
| 55 "&max-results=100" |
| 56 "&include-installed-apps=true" |
| 57 "&start-index=123" |
| 58 "&q=%22foo+bar%22", |
| 59 GDataWapiUrlGenerator::AddFeedUrlParams( |
| 60 GURL("http://www.example.com"), |
| 61 100, // num_items_to_fetch |
| 62 123, // changestamp |
| 63 "\"foo bar\"" // search_string |
| 64 ).spec()); |
| 65 } |
| 66 |
67 TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { | 67 TEST_F(GDataWapiUrlGeneratorTest, GenerateDocumentListUrl) { |
68 // This is the very basic URL for the GetDocuments operation. | 68 // This is the very basic URL for the GetDocuments operation. |
69 EXPECT_EQ( | 69 EXPECT_EQ( |
70 "https://docs.google.com/feeds/default/private/full/-/mine" | 70 "https://docs.google.com/feeds/default/private/full/-/mine" |
71 "?v=3&alt=json&showfolders=true&max-results=500" | 71 "?v=3&alt=json&showfolders=true&max-results=500" |
72 "&include-installed-apps=true", | 72 "&include-installed-apps=true", |
73 url_generator_.GenerateDocumentListUrl(GURL(), // override_url, | 73 url_generator_.GenerateDocumentListUrl(GURL(), // override_url, |
74 0, // start_changestamp, | 74 0, // start_changestamp, |
75 "", // search_string, | 75 "", // search_string, |
76 false, // shared_with_me, | 76 false, // shared_with_me, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 | 159 |
160 TEST_F(GDataWapiUrlGeneratorTest, GenerateAccountMetadataUrl) { | 160 TEST_F(GDataWapiUrlGeneratorTest, GenerateAccountMetadataUrl) { |
161 EXPECT_EQ( | 161 EXPECT_EQ( |
162 "https://docs.google.com/feeds/metadata/default" | 162 "https://docs.google.com/feeds/metadata/default" |
163 "?v=3&alt=json&include-installed-apps=true", | 163 "?v=3&alt=json&include-installed-apps=true", |
164 url_generator_.GenerateAccountMetadataUrl().spec()); | 164 url_generator_.GenerateAccountMetadataUrl().spec()); |
165 } | 165 } |
166 | 166 |
167 } // namespace google_apis | 167 } // namespace google_apis |
OLD | NEW |