| 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/extensions/api/cloud_print_private/cloud_print_private_
api.h" | 5 #include "chrome/browser/extensions/api/cloud_print_private/cloud_print_private_
api.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 void SetUpInProcessBrowserTestFixture() override { | 36 void SetUpInProcessBrowserTestFixture() override { |
| 37 // Start up the test server and get us ready for calling the install | 37 // Start up the test server and get us ready for calling the install |
| 38 // API functions. | 38 // API functions. |
| 39 host_resolver()->AddRule("www.cloudprintapp.com", "127.0.0.1"); | 39 host_resolver()->AddRule("www.cloudprintapp.com", "127.0.0.1"); |
| 40 ASSERT_TRUE(embedded_test_server()->Start()); | 40 ASSERT_TRUE(embedded_test_server()->Start()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 // Returns a test server URL, but with host 'www.cloudprintapp.com' so it | 44 // Returns a test server URL, but with host 'www.cloudprintapp.com' so it |
| 45 // matches the cloud print app's extent that we set up via command line | 45 // matches the cloud print app's extent that we set up via command line flags. |
| 46 // flags. | |
| 47 GURL GetTestServerURL(const std::string& path) { | 46 GURL GetTestServerURL(const std::string& path) { |
| 48 GURL url = embedded_test_server()->GetURL( | 47 GURL url = embedded_test_server()->GetURL( |
| 49 "/extensions/api_test/cloud_print_private/" + path); | 48 "/extensions/api_test/cloud_print_private/" + path); |
| 50 | 49 |
| 51 // Replace the host with 'www.cloudprintapp.com' so it matches the cloud | 50 // Replace the host with 'www.cloudprintapp.com' so it matches the cloud |
| 52 // print app's extent. | 51 // print app's extent. |
| 53 GURL::Replacements replace_host; | 52 GURL::Replacements replace_host; |
| 54 replace_host.SetHostStr("www.cloudprintapp.com"); | 53 replace_host.SetHostStr("www.cloudprintapp.com"); |
| 55 return url.ReplaceComponents(replace_host); | 54 return url.ReplaceComponents(replace_host); |
| 56 } | 55 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 const UserSettings& settings = arg; | 80 const UserSettings& settings = arg; |
| 82 return settings.connect_new_printers && settings.printers.size() == 2 && | 81 return settings.connect_new_printers && settings.printers.size() == 2 && |
| 83 settings.printers[0].name == "printer1" && | 82 settings.printers[0].name == "printer1" && |
| 84 !settings.printers[0].connect && | 83 !settings.printers[0].connect && |
| 85 settings.printers[1].name == "printer2" && | 84 settings.printers[1].name == "printer2" && |
| 86 settings.printers[1].connect; | 85 settings.printers[1].connect; |
| 87 } | 86 } |
| 88 | 87 |
| 89 // http://crbug.com/177163 | 88 // http://crbug.com/177163 |
| 90 #if defined(OS_WIN) && !defined(NDEBUG) | 89 #if defined(OS_WIN) && !defined(NDEBUG) |
| 91 #define MAYBE_CloudPrintHosted DISABLED_CloudPrintHosted | 90 #define MAYBE_CloudPrintHostedWithMock DISABLED_CloudPrintHostedWithMock |
| 92 #else | 91 #else |
| 93 #define MAYBE_CloudPrintHosted CloudPrintHosted | 92 #define MAYBE_CloudPrintHostedWithMock CloudPrintHostedWithMock |
| 94 #endif | 93 #endif |
| 95 IN_PROC_BROWSER_TEST_F(ExtensionCloudPrintPrivateApiTest, | 94 IN_PROC_BROWSER_TEST_F(ExtensionCloudPrintPrivateApiTest, |
| 96 MAYBE_CloudPrintHosted) { | 95 MAYBE_CloudPrintHostedWithMock) { |
| 97 CloudPrintTestsDelegateMock cloud_print_mock; | 96 CloudPrintTestsDelegateMock cloud_print_mock; |
| 98 | 97 |
| 99 EXPECT_CALL(cloud_print_mock, | 98 EXPECT_CALL(cloud_print_mock, |
| 100 SetupConnector("foo@gmail.com", | 99 SetupConnector("foo@gmail.com", |
| 101 "foorobot@googleusercontent.com", | 100 "foorobot@googleusercontent.com", |
| 102 "1/23546efa54", | 101 "1/23546efa54", |
| 103 IsExpectedUserSettings())); | 102 IsExpectedUserSettings())); |
| 104 EXPECT_CALL(cloud_print_mock, GetHostName()) | 103 EXPECT_CALL(cloud_print_mock, GetHostName()) |
| 105 .WillRepeatedly(Return("TestHostName")); | 104 .WillRepeatedly(Return("TestHostName")); |
| 106 | 105 |
| 107 std::vector<std::string> printers; | 106 std::vector<std::string> printers; |
| 108 printers.push_back("printer1"); | 107 printers.push_back("printer1"); |
| 109 printers.push_back("printer2"); | 108 printers.push_back("printer2"); |
| 110 EXPECT_CALL(cloud_print_mock, GetPrinters()) | 109 EXPECT_CALL(cloud_print_mock, GetPrinters()) |
| 111 .WillRepeatedly(Return(printers)); | 110 .WillRepeatedly(Return(printers)); |
| 112 | 111 |
| 113 EXPECT_CALL(cloud_print_mock, GetClientId()) | 112 EXPECT_CALL(cloud_print_mock, GetClientId()) |
| 114 .WillRepeatedly(Return("TestAPIClient")); | 113 .WillRepeatedly(Return("TestAPIClient")); |
| 115 | 114 |
| 116 // Run this as a hosted app. Since we have overridden the cloud print service | 115 // Run this as a hosted app. Since we have overridden the cloud print service |
| 117 // URL in the command line, this URL should match the web extent for our | 116 // URL in the command line, this URL should match the web extent for our |
| 118 // cloud print component app and it should work. | 117 // cloud print component app and it should work. |
| 119 GURL page_url = GetTestServerURL( | 118 GURL page_url = GetTestServerURL( |
| 120 "enable_chrome_connector/cloud_print_success_tests.html"); | 119 "enable_chrome_connector/cloud_print_success_tests.html"); |
| 121 ASSERT_TRUE(RunPageTest(page_url.spec())); | 120 ASSERT_TRUE(RunPageTest(page_url.spec())); |
| 122 } | 121 } |
| 123 | 122 |
| 123 IN_PROC_BROWSER_TEST_F(ExtensionCloudPrintPrivateApiTest, |
| 124 CloudPrintHostedIncognito) { |
| 125 GURL page_url = GetTestServerURL( |
| 126 "enable_chrome_connector/cloud_print_incognito_failure_tests.html"); |
| 127 ASSERT_TRUE(RunPageTest(page_url.spec(), kFlagUseIncognito)); |
| 128 } |
| 129 |
| 124 #endif // !defined(OS_CHROMEOS) | 130 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |