| 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_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 Loading... |
| 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, GenerateGetDocumentsURL) { | 53 TEST(GDataWapiUrlUtilTest, GenerateDocumentListUrl) { |
| 54 // This is the very basic URL for the GetDocuments operation. | 54 // This is the very basic URL for the GetDocuments operation. |
| 55 EXPECT_EQ( | 55 EXPECT_EQ( |
| 56 "https://docs.google.com/feeds/default/private/full/-/mine" | 56 "https://docs.google.com/feeds/default/private/full/-/mine" |
| 57 "?v=3&alt=json&showfolders=true&max-results=500" | 57 "?v=3&alt=json&showfolders=true&max-results=500" |
| 58 "&include-installed-apps=true", | 58 "&include-installed-apps=true", |
| 59 GenerateGetDocumentsURL(GURL(), // override_url, | 59 GenerateDocumentListUrl(GURL(), // override_url, |
| 60 0, // start_changestamp, | 60 0, // start_changestamp, |
| 61 "", // search_string, | 61 "", // search_string, |
| 62 false, // shared_with_me, | 62 false, // shared_with_me, |
| 63 "" // directory resource ID | 63 "" // directory resource ID |
| 64 ).spec()); | 64 ).spec()); |
| 65 | 65 |
| 66 // With an override URL provided, the base URL is changed, but the default | 66 // With an override URL provided, the base URL is changed, but the default |
| 67 // parameters remain as-is. | 67 // parameters remain as-is. |
| 68 EXPECT_EQ( | 68 EXPECT_EQ( |
| 69 "http://localhost/" | 69 "http://localhost/" |
| 70 "?v=3&alt=json&showfolders=true&max-results=500" | 70 "?v=3&alt=json&showfolders=true&max-results=500" |
| 71 "&include-installed-apps=true", | 71 "&include-installed-apps=true", |
| 72 GenerateGetDocumentsURL(GURL("http://localhost/"), // override_url, | 72 GenerateDocumentListUrl(GURL("http://localhost/"), // override_url, |
| 73 0, // start_changestamp, | 73 0, // start_changestamp, |
| 74 "", // search_string, | 74 "", // search_string, |
| 75 false, // shared_with_me, | 75 false, // shared_with_me, |
| 76 "" // directory resource ID | 76 "" // directory resource ID |
| 77 ).spec()); | 77 ).spec()); |
| 78 | 78 |
| 79 // With a non-zero start_changestamp provided, the base URL is changed from | 79 // With a non-zero start_changestamp provided, the base URL is changed from |
| 80 // "full/-/mine" to "changes", and "start-index" parameter is added. | 80 // "full/-/mine" to "changes", and "start-index" parameter is added. |
| 81 EXPECT_EQ( | 81 EXPECT_EQ( |
| 82 "https://docs.google.com/feeds/default/private/changes" | 82 "https://docs.google.com/feeds/default/private/changes" |
| 83 "?v=3&alt=json&showfolders=true&max-results=500" | 83 "?v=3&alt=json&showfolders=true&max-results=500" |
| 84 "&include-installed-apps=true" | 84 "&include-installed-apps=true" |
| 85 "&start-index=100", | 85 "&start-index=100", |
| 86 GenerateGetDocumentsURL(GURL(), // override_url, | 86 GenerateDocumentListUrl(GURL(), // override_url, |
| 87 100, // start_changestamp, | 87 100, // start_changestamp, |
| 88 "", // search_string, | 88 "", // search_string, |
| 89 false, // shared_with_me, | 89 false, // shared_with_me, |
| 90 "" // directory resource ID | 90 "" // directory resource ID |
| 91 ).spec()); | 91 ).spec()); |
| 92 | 92 |
| 93 // With a non-empty search string provided, "max-results" value is changed, | 93 // With a non-empty search string provided, "max-results" value is changed, |
| 94 // and "q" parameter is added. | 94 // and "q" parameter is added. |
| 95 EXPECT_EQ( | 95 EXPECT_EQ( |
| 96 "https://docs.google.com/feeds/default/private/full/-/mine" | 96 "https://docs.google.com/feeds/default/private/full/-/mine" |
| 97 "?v=3&alt=json&showfolders=true&max-results=50" | 97 "?v=3&alt=json&showfolders=true&max-results=50" |
| 98 "&include-installed-apps=true&q=foo", | 98 "&include-installed-apps=true&q=foo", |
| 99 GenerateGetDocumentsURL(GURL(), // override_url, | 99 GenerateDocumentListUrl(GURL(), // override_url, |
| 100 0, // start_changestamp, | 100 0, // start_changestamp, |
| 101 "foo", // search_string, | 101 "foo", // search_string, |
| 102 false, // shared_with_me, | 102 false, // shared_with_me, |
| 103 "" // directory resource ID | 103 "" // directory resource ID |
| 104 ).spec()); | 104 ).spec()); |
| 105 | 105 |
| 106 // With shared_with_me parameter set to true, the base URL is changed, but | 106 // With shared_with_me parameter set to true, the base URL is changed, but |
| 107 // the default parameters remain. | 107 // the default parameters remain. |
| 108 EXPECT_EQ( | 108 EXPECT_EQ( |
| 109 "https://docs.google.com/feeds/default/private/full/-/shared-with-me" | 109 "https://docs.google.com/feeds/default/private/full/-/shared-with-me" |
| 110 "?v=3&alt=json&showfolders=true&max-results=500" | 110 "?v=3&alt=json&showfolders=true&max-results=500" |
| 111 "&include-installed-apps=true", | 111 "&include-installed-apps=true", |
| 112 GenerateGetDocumentsURL(GURL(), // override_url, | 112 GenerateDocumentListUrl(GURL(), // override_url, |
| 113 0, // start_changestamp, | 113 0, // start_changestamp, |
| 114 "", // search_string, | 114 "", // search_string, |
| 115 true, // shared_with_me, | 115 true, // shared_with_me, |
| 116 "" // directory resource ID | 116 "" // directory resource ID |
| 117 ).spec()); | 117 ).spec()); |
| 118 | 118 |
| 119 // With a non-empty directory resource ID provided, the base URL is | 119 // With a non-empty directory resource ID provided, the base URL is |
| 120 // changed, but the default parameters remain. | 120 // changed, but the default parameters remain. |
| 121 EXPECT_EQ( | 121 EXPECT_EQ( |
| 122 "https://docs.google.com/feeds/default/private/full/XXX/contents/-/mine" | 122 "https://docs.google.com/feeds/default/private/full/XXX/contents/-/mine" |
| 123 "?v=3&alt=json&showfolders=true&max-results=500" | 123 "?v=3&alt=json&showfolders=true&max-results=500" |
| 124 "&include-installed-apps=true", | 124 "&include-installed-apps=true", |
| 125 GenerateGetDocumentsURL(GURL(), // override_url, | 125 GenerateDocumentListUrl(GURL(), // override_url, |
| 126 0, // start_changestamp, | 126 0, // start_changestamp, |
| 127 "", // search_string, | 127 "", // search_string, |
| 128 false, // shared_with_me, | 128 false, // shared_with_me, |
| 129 "XXX" // directory resource ID | 129 "XXX" // directory resource ID |
| 130 ).spec()); | 130 ).spec()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace gdata_wapi_url_util | 133 } // namespace gdata_wapi_url_util |
| 134 } // namespace google_apis | 134 } // namespace google_apis |
| OLD | NEW |