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/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/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 22 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
25 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
26 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
29 #include "content/public/browser/render_view_host.h" | 29 #include "content/public/browser/render_view_host.h" |
30 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
31 #include "content/public/test/test_browser_thread.h" | 31 #include "content/public/test/test_browser_thread.h" |
| 32 #include "net/url_request/url_request.h" |
32 #include "net/url_request/url_request_filter.h" | 33 #include "net/url_request/url_request_filter.h" |
33 #include "net/url_request/url_request_test_job.h" | 34 #include "net/url_request/url_request_test_job.h" |
34 #include "net/url_request/url_request_test_util.h" | 35 #include "net/url_request/url_request_test_util.h" |
35 #include "ui/ui_controls/ui_controls.h" | 36 #include "ui/ui_controls/ui_controls.h" |
36 | 37 |
37 using content::BrowserThread; | 38 using content::BrowserThread; |
38 | 39 |
39 namespace { | 40 namespace { |
40 | 41 |
41 class TestData { | 42 class TestData { |
(...skipping 21 matching lines...) Expand all Loading... |
63 | 64 |
64 std::string test_data_; | 65 std::string test_data_; |
65 | 66 |
66 friend struct DefaultSingletonTraits<TestData>; | 67 friend struct DefaultSingletonTraits<TestData>; |
67 }; | 68 }; |
68 | 69 |
69 // A simple test net::URLRequestJob. We don't care what it does, only that | 70 // A simple test net::URLRequestJob. We don't care what it does, only that |
70 // whether it starts and finishes. | 71 // whether it starts and finishes. |
71 class SimpleTestJob : public net::URLRequestTestJob { | 72 class SimpleTestJob : public net::URLRequestTestJob { |
72 public: | 73 public: |
73 explicit SimpleTestJob(net::URLRequest* request) | 74 SimpleTestJob(net::URLRequest* request, |
74 : net::URLRequestTestJob(request, test_headers(), | 75 net::NetworkDelegate* network_delegate) |
75 TestData::GetInstance()->GetTestData(), true) {} | 76 : net::URLRequestTestJob(request, |
| 77 network_delegate, |
| 78 test_headers(), |
| 79 TestData::GetInstance()->GetTestData(), |
| 80 true) {} |
76 | 81 |
77 virtual void GetResponseInfo(net::HttpResponseInfo* info) { | 82 virtual void GetResponseInfo(net::HttpResponseInfo* info) { |
78 net::URLRequestTestJob::GetResponseInfo(info); | 83 net::URLRequestTestJob::GetResponseInfo(info); |
79 if (request_->url().SchemeIsSecure()) { | 84 if (request_->url().SchemeIsSecure()) { |
80 // Make up a fake certificate for this response since we don't have | 85 // Make up a fake certificate for this response since we don't have |
81 // access to the real SSL info. | 86 // access to the real SSL info. |
82 const char* kCertIssuer = "Chrome Internal"; | 87 const char* kCertIssuer = "Chrome Internal"; |
83 const int kLifetimeDays = 100; | 88 const int kLifetimeDays = 100; |
84 | 89 |
85 info->ssl_info.cert = | 90 info->ssl_info.cert = |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 std::string("application/pdf"), false)); | 218 std::string("application/pdf"), false)); |
214 } | 219 } |
215 | 220 |
216 bool handler_added_; | 221 bool handler_added_; |
217 std::string scheme_; | 222 std::string scheme_; |
218 std::string host_name_; | 223 std::string host_name_; |
219 FilePath test_data_directory_; | 224 FilePath test_data_directory_; |
220 AutoQuitDelegate delegate_; | 225 AutoQuitDelegate delegate_; |
221 }; | 226 }; |
222 | 227 |
223 net::URLRequestJob* PrintDialogCloudTest::Factory(net::URLRequest* request, | 228 net::URLRequestJob* PrintDialogCloudTest::Factory( |
224 const std::string& scheme) { | 229 net::URLRequest* request, |
| 230 net::NetworkDelegate* network_delegate, |
| 231 const std::string& scheme) { |
225 if (request && | 232 if (request && |
226 (request->url() == TestController::GetInstance()->expected_url())) { | 233 (request->url() == TestController::GetInstance()->expected_url())) { |
227 if (TestController::GetInstance()->use_delegate()) | 234 if (TestController::GetInstance()->use_delegate()) |
228 request->set_delegate(TestController::GetInstance()->delegate()); | 235 request->set_delegate(TestController::GetInstance()->delegate()); |
229 TestController::GetInstance()->set_result(true); | 236 TestController::GetInstance()->set_result(true); |
230 return new SimpleTestJob(request); | 237 return new SimpleTestJob(request, network_delegate); |
231 } | 238 } |
232 return new net::URLRequestTestJob(request, | 239 return new net::URLRequestTestJob(request, |
| 240 network_delegate, |
233 net::URLRequestTestJob::test_headers(), | 241 net::URLRequestTestJob::test_headers(), |
234 "", true); | 242 "", |
| 243 true); |
235 } | 244 } |
236 | 245 |
237 #if defined(OS_WIN) | 246 #if defined(OS_WIN) |
238 #define MAYBE_HandlersRegistered FLAKY_HandlersRegistered | 247 #define MAYBE_HandlersRegistered FLAKY_HandlersRegistered |
239 #else | 248 #else |
240 #define MAYBE_HandlersRegistered HandlersRegistered | 249 #define MAYBE_HandlersRegistered HandlersRegistered |
241 #endif | 250 #endif |
242 IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, MAYBE_HandlersRegistered) { | 251 IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, MAYBE_HandlersRegistered) { |
243 AddTestHandlers(); | 252 AddTestHandlers(); |
244 | 253 |
(...skipping 14 matching lines...) Expand all Loading... |
259 BrowserWindow* window = browser()->window(); | 268 BrowserWindow* window = browser()->window(); |
260 ASSERT_TRUE(window); | 269 ASSERT_TRUE(window); |
261 gfx::NativeWindow native_window = window->GetNativeWindow(); | 270 gfx::NativeWindow native_window = window->GetNativeWindow(); |
262 ASSERT_TRUE(native_window); | 271 ASSERT_TRUE(native_window); |
263 bool key_sent = ui_controls::SendKeyPress(native_window, ui::VKEY_ESCAPE, | 272 bool key_sent = ui_controls::SendKeyPress(native_window, ui::VKEY_ESCAPE, |
264 false, false, false, false); | 273 false, false, false, false); |
265 EXPECT_TRUE(key_sent); | 274 EXPECT_TRUE(key_sent); |
266 if (key_sent) | 275 if (key_sent) |
267 tab_closed_observer.Wait(); | 276 tab_closed_observer.Wait(); |
268 } | 277 } |
OLD | NEW |