OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/service/cloud_print/cloud_print_helpers.h" | 5 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "chrome/common/cloud_print/cloud_print_helpers.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace { | 11 namespace { |
11 | 12 |
12 void CheckURLs(const GURL& server_base_url) { | 13 void CheckURLs(const GURL& server_base_url) { |
13 GURL url = CloudPrintHelpers::GetUrlForPrinterRegistration(server_base_url); | 14 GURL url = CloudPrintHelpers::GetUrlForPrinterRegistration(server_base_url); |
14 std::string expected_url_base = server_base_url.spec(); | 15 std::string expected_url_base = server_base_url.spec(); |
15 if (expected_url_base[expected_url_base.length() - 1] != '/') { | 16 if (expected_url_base[expected_url_base.length() - 1] != '/') { |
16 expected_url_base += "/"; | 17 expected_url_base += "/"; |
17 } | 18 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 "&message=Out%%20of%%20Paper&numpages=345&pagesprinted=47", | 76 "&message=Out%%20of%%20Paper&numpages=345&pagesprinted=47", |
76 expected_url_base.c_str()); | 77 expected_url_base.c_str()); |
77 EXPECT_EQ(expected_url, url.spec()); | 78 EXPECT_EQ(expected_url, url.spec()); |
78 | 79 |
79 url = CloudPrintHelpers::GetUrlForUserMessage(server_base_url, | 80 url = CloudPrintHelpers::GetUrlForUserMessage(server_base_url, |
80 "blahmessageid"); | 81 "blahmessageid"); |
81 expected_url = base::StringPrintf("%smessage?code=blahmessageid", | 82 expected_url = base::StringPrintf("%smessage?code=blahmessageid", |
82 expected_url_base.c_str()); | 83 expected_url_base.c_str()); |
83 EXPECT_EQ(expected_url, url.spec()); | 84 EXPECT_EQ(expected_url, url.spec()); |
84 | 85 |
85 url = CloudPrintHelpers::GetUrlForGetAuthCode( | 86 url = cloud_print::GetUrlForGetAuthCode(server_base_url, |
86 server_base_url, | 87 "fooclientid.apps.googleusercontent.com", "test_proxy"); |
87 "fooclientid.apps.googleusercontent.com", | |
88 "test_proxy"); | |
89 expected_url = base::StringPrintf( | 88 expected_url = base::StringPrintf( |
90 "%screaterobot?oauth_client_id=fooclientid.apps.googleusercontent.com&" | 89 "%screaterobot?oauth_client_id=fooclientid.apps.googleusercontent.com&" |
91 "proxy=test_proxy", expected_url_base.c_str()); | 90 "proxy=test_proxy", expected_url_base.c_str()); |
92 EXPECT_EQ(expected_url, url.spec()); | 91 EXPECT_EQ(expected_url, url.spec()); |
93 } | 92 } |
94 | 93 |
95 } // namespace | 94 } // namespace |
96 | 95 |
97 TEST(CloudPrintHelpersTest, URLGetters) { | 96 TEST(CloudPrintHelpersTest, URLGetters) { |
98 CheckURLs(GURL("https://www.google.com/cloudprint")); | 97 CheckURLs(GURL("https://www.google.com/cloudprint")); |
99 CheckURLs(GURL("https://www.google.com/cloudprint/")); | 98 CheckURLs(GURL("https://www.google.com/cloudprint/")); |
100 CheckURLs(GURL("http://www.myprinterserver.com")); | 99 CheckURLs(GURL("http://www.myprinterserver.com")); |
101 CheckURLs(GURL("http://www.myprinterserver.com/")); | 100 CheckURLs(GURL("http://www.myprinterserver.com/")); |
102 } | 101 } |
103 | 102 |
OLD | NEW |