| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/printing/print_dialog_cloud.h" | 5 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" | 6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" |
| 7 | 7 |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 return test_data_.c_str(); | 48 return test_data_.c_str(); |
| 49 } | 49 } |
| 50 private: | 50 private: |
| 51 std::string test_data_; | 51 std::string test_data_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // A simple test URLRequestJob. We don't care what it does, only that | 54 // A simple test URLRequestJob. We don't care what it does, only that |
| 55 // whether it starts and finishes. | 55 // whether it starts and finishes. |
| 56 class SimpleTestJob : public URLRequestTestJob { | 56 class SimpleTestJob : public URLRequestTestJob { |
| 57 public: | 57 public: |
| 58 explicit SimpleTestJob(URLRequest* request) | 58 explicit SimpleTestJob(net::URLRequest* request) |
| 59 : URLRequestTestJob(request, test_headers(), | 59 : URLRequestTestJob(request, test_headers(), |
| 60 Singleton<TestData>()->GetTestData(), true) {} | 60 Singleton<TestData>()->GetTestData(), true) {} |
| 61 | 61 |
| 62 virtual void GetResponseInfo(net::HttpResponseInfo* info) { | 62 virtual void GetResponseInfo(net::HttpResponseInfo* info) { |
| 63 URLRequestTestJob::GetResponseInfo(info); | 63 URLRequestTestJob::GetResponseInfo(info); |
| 64 if (request_->url().SchemeIsSecure()) { | 64 if (request_->url().SchemeIsSecure()) { |
| 65 // Make up a fake certificate for this response since we don't have | 65 // Make up a fake certificate for this response since we don't have |
| 66 // access to the real SSL info. | 66 // access to the real SSL info. |
| 67 const char* kCertIssuer = "Chrome Internal"; | 67 const char* kCertIssuer = "Chrome Internal"; |
| 68 const int kLifetimeDays = 100; | 68 const int kLifetimeDays = 100; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 | 123 |
| 124 class PrintDialogCloudTest : public InProcessBrowserTest { | 124 class PrintDialogCloudTest : public InProcessBrowserTest { |
| 125 public: | 125 public: |
| 126 PrintDialogCloudTest() : handler_added_(false) { | 126 PrintDialogCloudTest() : handler_added_(false) { |
| 127 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); | 127 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Must be static for handing into AddHostnameHandler. | 130 // Must be static for handing into AddHostnameHandler. |
| 131 static URLRequest::ProtocolFactory Factory; | 131 static net::URLRequest::ProtocolFactory Factory; |
| 132 | 132 |
| 133 class AutoQuitDelegate : public TestDelegate { | 133 class AutoQuitDelegate : public TestDelegate { |
| 134 public: | 134 public: |
| 135 AutoQuitDelegate() {} | 135 AutoQuitDelegate() {} |
| 136 | 136 |
| 137 virtual void OnResponseCompleted(URLRequest* request) { | 137 virtual void OnResponseCompleted(net::URLRequest* request) { |
| 138 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 138 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 139 new MessageLoop::QuitTask()); | 139 new MessageLoop::QuitTask()); |
| 140 } | 140 } |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 virtual void SetUp() { | 143 virtual void SetUp() { |
| 144 Singleton<TestController>()->set_result(false); | 144 Singleton<TestController>()->set_result(false); |
| 145 InProcessBrowserTest::SetUp(); | 145 InProcessBrowserTest::SetUp(); |
| 146 } | 146 } |
| 147 | 147 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 NewRunnableFunction(&PrintDialogCloud::CreateDialogImpl, path_to_pdf)); | 189 NewRunnableFunction(&PrintDialogCloud::CreateDialogImpl, path_to_pdf)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool handler_added_; | 192 bool handler_added_; |
| 193 std::string scheme_; | 193 std::string scheme_; |
| 194 std::string host_name_; | 194 std::string host_name_; |
| 195 FilePath test_data_directory_; | 195 FilePath test_data_directory_; |
| 196 AutoQuitDelegate delegate_; | 196 AutoQuitDelegate delegate_; |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 URLRequestJob* PrintDialogCloudTest::Factory(URLRequest* request, | 199 URLRequestJob* PrintDialogCloudTest::Factory(net::URLRequest* request, |
| 200 const std::string& scheme) { | 200 const std::string& scheme) { |
| 201 if (Singleton<TestController>()->use_delegate()) | 201 if (Singleton<TestController>()->use_delegate()) |
| 202 request->set_delegate(Singleton<TestController>()->delegate()); | 202 request->set_delegate(Singleton<TestController>()->delegate()); |
| 203 if (request && | 203 if (request && |
| 204 (request->url() == Singleton<TestController>()->expected_url())) { | 204 (request->url() == Singleton<TestController>()->expected_url())) { |
| 205 Singleton<TestController>()->set_result(true); | 205 Singleton<TestController>()->set_result(true); |
| 206 } | 206 } |
| 207 return new SimpleTestJob(request); | 207 return new SimpleTestJob(request); |
| 208 } | 208 } |
| 209 | 209 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 236 | 236 |
| 237 std::wstring window_print(L"window.print()"); | 237 std::wstring window_print(L"window.print()"); |
| 238 browser()->GetSelectedTabContents()->render_view_host()-> | 238 browser()->GetSelectedTabContents()->render_view_host()-> |
| 239 ExecuteJavascriptInWebFrame(std::wstring(), window_print); | 239 ExecuteJavascriptInWebFrame(std::wstring(), window_print); |
| 240 | 240 |
| 241 ui_test_utils::RunMessageLoop(); | 241 ui_test_utils::RunMessageLoop(); |
| 242 | 242 |
| 243 ASSERT_TRUE(Singleton<TestController>()->result()); | 243 ASSERT_TRUE(Singleton<TestController>()->result()); |
| 244 } | 244 } |
| 245 #endif | 245 #endif |
| OLD | NEW |