| 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_generator.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 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 GURL("http://www.example.com"), | 63 GURL("http://www.example.com"), |
| 64 100, // num_items_to_fetch | 64 100, // num_items_to_fetch |
| 65 123, // changestamp | 65 123, // changestamp |
| 66 "\"foo bar\"" // search_string | 66 "\"foo bar\"" // search_string |
| 67 ).spec()); | 67 ).spec()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { | 70 TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { |
| 71 // This is the very basic URL for the GetResourceList operation. | 71 // This is the very basic URL for the GetResourceList operation. |
| 72 EXPECT_EQ( | 72 EXPECT_EQ( |
| 73 "https://docs.google.com/feeds/default/private/full/-/mine" | 73 "https://docs.google.com/feeds/default/private/full" |
| 74 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" | 74 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" |
| 75 "&include-installed-apps=true", | 75 "&include-installed-apps=true", |
| 76 url_generator_.GenerateResourceListUrl(GURL(), // override_url, | 76 url_generator_.GenerateResourceListUrl(GURL(), // override_url, |
| 77 0, // start_changestamp, | 77 0, // start_changestamp, |
| 78 "", // search_string, | 78 "", // search_string, |
| 79 false, // shared_with_me, | 79 false, // shared_with_me, |
| 80 "" // directory resource ID | 80 "" // directory resource ID |
| 81 ).spec()); | 81 ).spec()); |
| 82 | 82 |
| 83 // With an override URL provided, the base URL is changed, but the default | 83 // With an override URL provided, the base URL is changed, but the default |
| 84 // parameters remain as-is. | 84 // parameters remain as-is. |
| 85 EXPECT_EQ( | 85 EXPECT_EQ( |
| 86 "http://localhost/" | 86 "http://localhost/" |
| 87 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" | 87 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" |
| 88 "&include-installed-apps=true", | 88 "&include-installed-apps=true", |
| 89 url_generator_.GenerateResourceListUrl( | 89 url_generator_.GenerateResourceListUrl( |
| 90 GURL("http://localhost/"), // override_url, | 90 GURL("http://localhost/"), // override_url, |
| 91 0, // start_changestamp, | 91 0, // start_changestamp, |
| 92 "", // search_string, | 92 "", // search_string, |
| 93 false, // shared_with_me, | 93 false, // shared_with_me, |
| 94 "" // directory resource ID | 94 "" // directory resource ID |
| 95 ).spec()); | 95 ).spec()); |
| 96 | 96 |
| 97 // With a non-zero start_changestamp provided, the base URL is changed from | 97 // With a non-zero start_changestamp provided, the base URL is changed from |
| 98 // "full/-/mine" to "changes", and "start-index" parameter is added. | 98 // "full" to "changes", and "start-index" parameter is added. |
| 99 EXPECT_EQ( | 99 EXPECT_EQ( |
| 100 "https://docs.google.com/feeds/default/private/changes" | 100 "https://docs.google.com/feeds/default/private/changes" |
| 101 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" | 101 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" |
| 102 "&include-installed-apps=true" | 102 "&include-installed-apps=true" |
| 103 "&start-index=100", | 103 "&start-index=100", |
| 104 url_generator_.GenerateResourceListUrl(GURL(), // override_url, | 104 url_generator_.GenerateResourceListUrl(GURL(), // override_url, |
| 105 100, // start_changestamp, | 105 100, // start_changestamp, |
| 106 "", // search_string, | 106 "", // search_string, |
| 107 false, // shared_with_me, | 107 false, // shared_with_me, |
| 108 "" // directory resource ID | 108 "" // directory resource ID |
| 109 ).spec()); | 109 ).spec()); |
| 110 | 110 |
| 111 // With a non-empty search string provided, "max-results" value is changed, | 111 // With a non-empty search string provided, "max-results" value is changed, |
| 112 // and "q" parameter is added. | 112 // and "q" parameter is added. |
| 113 EXPECT_EQ( | 113 EXPECT_EQ( |
| 114 "https://docs.google.com/feeds/default/private/full/-/mine" | 114 "https://docs.google.com/feeds/default/private/full" |
| 115 "?v=3&alt=json&showroot=true&showfolders=true&max-results=50" | 115 "?v=3&alt=json&showroot=true&showfolders=true&max-results=50" |
| 116 "&include-installed-apps=true&q=foo", | 116 "&include-installed-apps=true&q=foo", |
| 117 url_generator_.GenerateResourceListUrl(GURL(), // override_url, | 117 url_generator_.GenerateResourceListUrl(GURL(), // override_url, |
| 118 0, // start_changestamp, | 118 0, // start_changestamp, |
| 119 "foo", // search_string, | 119 "foo", // search_string, |
| 120 false, // shared_with_me, | 120 false, // shared_with_me, |
| 121 "" // directory resource ID | 121 "" // directory resource ID |
| 122 ).spec()); | 122 ).spec()); |
| 123 | 123 |
| 124 // With shared_with_me parameter set to true, the base URL is changed, but | 124 // With shared_with_me parameter set to true, the base URL is changed, but |
| 125 // the default parameters remain. | 125 // the default parameters remain. |
| 126 EXPECT_EQ( | 126 EXPECT_EQ( |
| 127 "https://docs.google.com/feeds/default/private/full/-/shared-with-me" | 127 "https://docs.google.com/feeds/default/private/full/-/shared-with-me" |
| 128 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" | 128 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" |
| 129 "&include-installed-apps=true", | 129 "&include-installed-apps=true", |
| 130 url_generator_.GenerateResourceListUrl(GURL(), // override_url, | 130 url_generator_.GenerateResourceListUrl(GURL(), // override_url, |
| 131 0, // start_changestamp, | 131 0, // start_changestamp, |
| 132 "", // search_string, | 132 "", // search_string, |
| 133 true, // shared_with_me, | 133 true, // shared_with_me, |
| 134 "" // directory resource ID | 134 "" // directory resource ID |
| 135 ).spec()); | 135 ).spec()); |
| 136 | 136 |
| 137 // With a non-empty directory resource ID provided, the base URL is | 137 // With a non-empty directory resource ID provided, the base URL is |
| 138 // changed, but the default parameters remain. | 138 // changed, but the default parameters remain. |
| 139 EXPECT_EQ( | 139 EXPECT_EQ( |
| 140 "https://docs.google.com/feeds/default/private/full/XXX/contents/-/mine" | 140 "https://docs.google.com/feeds/default/private/full/XXX/contents" |
| 141 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" | 141 "?v=3&alt=json&showroot=true&showfolders=true&max-results=500" |
| 142 "&include-installed-apps=true", | 142 "&include-installed-apps=true", |
| 143 url_generator_.GenerateResourceListUrl(GURL(), // override_url, | 143 url_generator_.GenerateResourceListUrl(GURL(), // override_url, |
| 144 0, // start_changestamp, | 144 0, // start_changestamp, |
| 145 "", // search_string, | 145 "", // search_string, |
| 146 false, // shared_with_me, | 146 false, // shared_with_me, |
| 147 "XXX" // directory resource ID | 147 "XXX" // directory resource ID |
| 148 ).spec()); | 148 ).spec()); |
| 149 | 149 |
| 150 // With a non-empty override_url provided, the base URL is changed, but | 150 // With a non-empty override_url provided, the base URL is changed, but |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 url_generator_.GenerateAccountMetadataUrl(true).spec()); | 221 url_generator_.GenerateAccountMetadataUrl(true).spec()); |
| 222 | 222 |
| 223 // Exclude installed apps. | 223 // Exclude installed apps. |
| 224 EXPECT_EQ( | 224 EXPECT_EQ( |
| 225 "https://docs.google.com/feeds/metadata/default?v=3&alt=json" | 225 "https://docs.google.com/feeds/metadata/default?v=3&alt=json" |
| 226 "&showroot=true", | 226 "&showroot=true", |
| 227 url_generator_.GenerateAccountMetadataUrl(false).spec()); | 227 url_generator_.GenerateAccountMetadataUrl(false).spec()); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace google_apis | 230 } // namespace google_apis |
| OLD | NEW |