Roll src/third_party/skia 0a24297:ceadfef
[chromium-blink-merge.git] / components / cloud_devices / common / cloud_devices_urls_unittest.cc
blobbd4da91522236c47f2c3ed7b98cd29155cb3c3ea
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/cloud_devices/common/cloud_devices_urls.h"
7 #include <string>
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 using testing::HasSubstr;
14 namespace cloud_devices {
16 TEST(CloudPrintURLTest, GetCloudPrintURL) {
17 std::string service_url = GetCloudPrintURL().spec();
18 EXPECT_THAT(service_url, HasSubstr("www.google.com"));
19 EXPECT_THAT(service_url, HasSubstr("cloudprint"));
22 TEST(CloudPrintURLTest, GetCloudPrintRelativeURL) {
23 EXPECT_THAT(GetCloudPrintRelativeURL("///a/b/c///").spec(),
24 HasSubstr("/cloudprint/a/b/c"));
26 EXPECT_THAT(GetCloudPrintRelativeURL("a/b/c").spec(),
27 HasSubstr("/cloudprint/a/b/c"));
30 TEST(CloudPrintURLTest, GetCloudPrintDialogUrl) {
31 std::string dialog_url =
32 GetCloudPrintRelativeURL("client/dialog.html").spec();
33 EXPECT_THAT(dialog_url, HasSubstr("www.google.com"));
34 EXPECT_THAT(dialog_url, HasSubstr("/cloudprint/"));
35 EXPECT_THAT(dialog_url, HasSubstr("/client/"));
36 EXPECT_THAT(dialog_url, Not(HasSubstr("cloudprint/cloudprint")));
37 EXPECT_THAT(dialog_url, HasSubstr("/dialog.html"));
40 TEST(CloudPrintURLTest, GetCloudPrintManageUrl) {
41 std::string manage_url = GetCloudPrintRelativeURL("manage.html").spec();
42 EXPECT_THAT(manage_url, HasSubstr("www.google.com"));
43 EXPECT_THAT(manage_url, HasSubstr("/cloudprint/"));
44 EXPECT_THAT(manage_url, Not(HasSubstr("/client/")));
45 EXPECT_THAT(manage_url, Not(HasSubstr("cloudprint/cloudprint")));
46 EXPECT_THAT(manage_url, HasSubstr("/manage.html"));
49 TEST(CloudPrintURLTest, GetCloudPrintEnableURL) {
50 std::string enable_url = GetCloudPrintEnableURL("123123").spec();
51 EXPECT_THAT(enable_url, HasSubstr("proxy=123123"));
52 EXPECT_THAT(enable_url, HasSubstr("/enable_chrome_connector/enable.html"));
53 EXPECT_THAT(enable_url, HasSubstr("/cloudprint/"));
56 TEST(CloudPrintURLTest, GetCloudPrintEnableWithSigninURL) {
57 std::string enable_url = GetCloudPrintEnableWithSigninURL("123123").spec();
58 EXPECT_THAT(enable_url, HasSubstr("accounts.google.com"));
59 EXPECT_THAT(enable_url, HasSubstr("/ServiceLogin"));
60 EXPECT_THAT(enable_url, HasSubstr("service=cloudprint"));
61 EXPECT_THAT(enable_url, HasSubstr("continue="));
62 EXPECT_THAT(enable_url, HasSubstr("proxy%3D123123"));
63 EXPECT_THAT(enable_url, HasSubstr("%2Fenable_chrome_connector%2Fenable"));
64 EXPECT_THAT(enable_url, HasSubstr("%2Fcloudprint%2F"));
67 TEST(CloudPrintURLTest, GetCloudPrintManageDeviceURL) {
68 std::string manage_url = GetCloudPrintManageDeviceURL("123").spec();
69 EXPECT_THAT(manage_url, HasSubstr("www.google.com"));
70 EXPECT_THAT(manage_url, HasSubstr("/cloudprint"));
71 EXPECT_THAT(manage_url, HasSubstr("#printers/123"));
74 TEST(CloudPrintURLTest, GetCloudPrintSigninURL) {
75 std::string signin_url = GetCloudPrintSigninURL().spec();
76 EXPECT_THAT(signin_url, HasSubstr("accounts.google.com"));
77 EXPECT_THAT(signin_url, HasSubstr("/ServiceLogin"));
78 EXPECT_THAT(signin_url, HasSubstr("service=cloudprint"));
79 EXPECT_THAT(signin_url, HasSubstr("continue="));
80 EXPECT_THAT(signin_url, HasSubstr("%2Fcloudprint"));
81 EXPECT_THAT(signin_url, Not(HasSubstr("/cloudprint")));
84 TEST(CloudPrintURLTest, GetCloudPrintAddAccountURL) {
85 std::string add_url = GetCloudPrintAddAccountURL().spec();
86 EXPECT_THAT(add_url, HasSubstr("accounts.google.com"));
87 EXPECT_THAT(add_url, HasSubstr("/AddSession"));
88 EXPECT_THAT(add_url, HasSubstr("service=cloudprint"));
89 EXPECT_THAT(add_url, HasSubstr("continue="));
90 EXPECT_THAT(add_url, HasSubstr("%2Fcloudprint"));
91 EXPECT_THAT(add_url, Not(HasSubstr("/cloudprint")));
94 } // namespace cloud_devices