| 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" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/singleton.h" | 13 #include "base/singleton.h" |
| 14 #include "base/thread_restrictions.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/browser/browser_list.h" | 16 #include "chrome/browser/browser_list.h" |
| 16 #include "chrome/browser/browser_thread.h" | 17 #include "chrome/browser/browser_thread.h" |
| 17 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 18 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 18 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 19 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 19 #include "chrome/browser/renderer_host/render_view_host.h" | 20 #include "chrome/browser/renderer_host/render_view_host.h" |
| 20 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
| 21 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/test/in_process_browser_test.h" | 24 #include "chrome/test/in_process_browser_test.h" |
| 24 #include "chrome/test/ui_test_utils.h" | 25 #include "chrome/test/ui_test_utils.h" |
| 25 #include "net/url_request/url_request_filter.h" | 26 #include "net/url_request/url_request_filter.h" |
| 26 #include "net/url_request/url_request_test_job.h" | 27 #include "net/url_request/url_request_test_job.h" |
| 27 #include "net/url_request/url_request_unittest.h" | 28 #include "net/url_request/url_request_unittest.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 class TestData { | 32 class TestData { |
| 32 public: | 33 public: |
| 33 TestData() {} | 34 TestData() {} |
| 34 | 35 |
| 35 char* GetTestData() { | 36 const char* GetTestData() { |
| 37 // Fetching this data blocks the IO thread, but we don't really care because |
| 38 // this is a test. |
| 39 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 40 |
| 36 if (test_data_.empty()) { | 41 if (test_data_.empty()) { |
| 37 FilePath test_data_directory; | 42 FilePath test_data_directory; |
| 38 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory); | 43 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory); |
| 39 FilePath test_file = | 44 FilePath test_file = |
| 40 test_data_directory.AppendASCII("printing/cloud_print_uitest.html"); | 45 test_data_directory.AppendASCII("printing/cloud_print_uitest.html"); |
| 41 file_util::ReadFileToString(test_file, &test_data_); | 46 file_util::ReadFileToString(test_file, &test_data_); |
| 42 } | 47 } |
| 43 return &test_data_[0]; | 48 return test_data_.c_str(); |
| 44 } | 49 } |
| 45 private: | 50 private: |
| 46 std::string test_data_; | 51 std::string test_data_; |
| 47 }; | 52 }; |
| 48 | 53 |
| 49 // 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 |
| 50 // whether it starts and finishes. | 55 // whether it starts and finishes. |
| 51 class SimpleTestJob : public URLRequestTestJob { | 56 class SimpleTestJob : public URLRequestTestJob { |
| 52 public: | 57 public: |
| 53 explicit SimpleTestJob(URLRequest* request) | 58 explicit SimpleTestJob(URLRequest* request) |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 236 |
| 232 std::wstring window_print(L"window.print()"); | 237 std::wstring window_print(L"window.print()"); |
| 233 browser()->GetSelectedTabContents()->render_view_host()-> | 238 browser()->GetSelectedTabContents()->render_view_host()-> |
| 234 ExecuteJavascriptInWebFrame(std::wstring(), window_print); | 239 ExecuteJavascriptInWebFrame(std::wstring(), window_print); |
| 235 | 240 |
| 236 ui_test_utils::RunMessageLoop(); | 241 ui_test_utils::RunMessageLoop(); |
| 237 | 242 |
| 238 ASSERT_TRUE(Singleton<TestController>()->result()); | 243 ASSERT_TRUE(Singleton<TestController>()->result()); |
| 239 } | 244 } |
| 240 #endif | 245 #endif |
| OLD | NEW |