| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/strings/string_util.h" | |
| 19 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/values.h" | 19 #include "base/values.h" |
| 21 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 20 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 22 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 24 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 25 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
| 26 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 27 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
| 28 #include "content/public/test/test_browser_thread.h" | 27 #include "content/public/test/test_browser_thread.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 MOCK_METHOD1(RenderViewCreated, | 129 MOCK_METHOD1(RenderViewCreated, |
| 131 void(content::RenderViewHost* render_view_host)); | 130 void(content::RenderViewHost* render_view_host)); |
| 132 }; | 131 }; |
| 133 | 132 |
| 134 class MockCloudPrintDataSenderHelper : public CloudPrintDataSenderHelper { | 133 class MockCloudPrintDataSenderHelper : public CloudPrintDataSenderHelper { |
| 135 public: | 134 public: |
| 136 // TODO(scottbyer): At some point this probably wants to use a | 135 // TODO(scottbyer): At some point this probably wants to use a |
| 137 // MockTabContents instead of NULL, and to pre-load it with a bunch | 136 // MockTabContents instead of NULL, and to pre-load it with a bunch |
| 138 // of expects/results. | 137 // of expects/results. |
| 139 MockCloudPrintDataSenderHelper() : CloudPrintDataSenderHelper(NULL) {} | 138 MockCloudPrintDataSenderHelper() : CloudPrintDataSenderHelper(NULL) {} |
| 140 MOCK_METHOD1(CallJavascriptFunction, void(const std::wstring&)); | 139 MOCK_METHOD3(CallJavascriptFunction, void(const std::string&, |
| 141 MOCK_METHOD2(CallJavascriptFunction, void(const std::wstring&, | |
| 142 const Value& arg1)); | |
| 143 MOCK_METHOD3(CallJavascriptFunction, void(const std::wstring&, | |
| 144 const Value& arg1, | 140 const Value& arg1, |
| 145 const Value& arg2)); | 141 const Value& arg2)); |
| 146 }; | 142 }; |
| 147 | 143 |
| 148 class CloudPrintURLTest : public testing::Test { | 144 class CloudPrintURLTest : public testing::Test { |
| 149 public: | 145 public: |
| 150 CloudPrintURLTest() {} | 146 CloudPrintURLTest() {} |
| 151 | 147 |
| 152 protected: | 148 protected: |
| 153 virtual void SetUp() { | 149 virtual void SetUp() { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 io_thread_(BrowserThread::IO, &message_loop_) {} | 213 io_thread_(BrowserThread::IO, &message_loop_) {} |
| 218 | 214 |
| 219 protected: | 215 protected: |
| 220 virtual void SetUp() { | 216 virtual void SetUp() { |
| 221 mock_helper_.reset(new MockCloudPrintDataSenderHelper); | 217 mock_helper_.reset(new MockCloudPrintDataSenderHelper); |
| 222 } | 218 } |
| 223 | 219 |
| 224 scoped_refptr<CloudPrintDataSender> CreateSender( | 220 scoped_refptr<CloudPrintDataSender> CreateSender( |
| 225 const base::RefCountedString* data) { | 221 const base::RefCountedString* data) { |
| 226 return new CloudPrintDataSender(mock_helper_.get(), | 222 return new CloudPrintDataSender(mock_helper_.get(), |
| 227 ASCIIToUTF16(kMockJobTitle), | 223 base::ASCIIToUTF16(kMockJobTitle), |
| 228 ASCIIToUTF16(kMockPrintTicket), | 224 base::ASCIIToUTF16(kMockPrintTicket), |
| 229 std::string("application/pdf"), | 225 std::string("application/pdf"), |
| 230 data); | 226 data); |
| 231 } | 227 } |
| 232 | 228 |
| 233 scoped_refptr<CloudPrintDataSender> print_data_sender_; | 229 scoped_refptr<CloudPrintDataSender> print_data_sender_; |
| 234 scoped_ptr<MockCloudPrintDataSenderHelper> mock_helper_; | 230 scoped_ptr<MockCloudPrintDataSenderHelper> mock_helper_; |
| 235 | 231 |
| 236 base::MessageLoop message_loop_; | 232 base::MessageLoop message_loop_; |
| 237 content::TestBrowserThread file_thread_; | 233 content::TestBrowserThread file_thread_; |
| 238 content::TestBrowserThread io_thread_; | 234 content::TestBrowserThread io_thread_; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 std::vector<WebUIMessageHandler*> handlers; | 335 std::vector<WebUIMessageHandler*> handlers; |
| 340 delegate_->GetWebUIMessageHandlers(&handlers); | 336 delegate_->GetWebUIMessageHandlers(&handlers); |
| 341 delegate_.reset(); | 337 delegate_.reset(); |
| 342 EXPECT_THAT(mock_flow_handler_.get(), NotNull()); | 338 EXPECT_THAT(mock_flow_handler_.get(), NotNull()); |
| 343 } | 339 } |
| 344 | 340 |
| 345 // Testing for ExternalWebDialogUI needs a mock WebContents and mock | 341 // Testing for ExternalWebDialogUI needs a mock WebContents and mock |
| 346 // CloudPrintWebDialogDelegate (attached to the mock web_contents). | 342 // CloudPrintWebDialogDelegate (attached to the mock web_contents). |
| 347 | 343 |
| 348 // Testing for PrintDialogCloud needs a mock Browser. | 344 // Testing for PrintDialogCloud needs a mock Browser. |
| OLD | NEW |