| 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 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 // Testing for CloudPrintDataSender needs a mock WebUI. | 140 // Testing for CloudPrintDataSender needs a mock WebUI. |
| 141 class CloudPrintDataSenderTest : public testing::Test { | 141 class CloudPrintDataSenderTest : public testing::Test { |
| 142 public: | 142 public: |
| 143 CloudPrintDataSenderTest() | 143 CloudPrintDataSenderTest() |
| 144 : file_thread_(BrowserThread::FILE, &message_loop_), | 144 : file_thread_(BrowserThread::FILE, &message_loop_), |
| 145 io_thread_(BrowserThread::IO, &message_loop_) {} | 145 io_thread_(BrowserThread::IO, &message_loop_) {} |
| 146 | 146 |
| 147 protected: | 147 protected: |
| 148 virtual void SetUp() { | 148 void SetUp() override { |
| 149 mock_helper_.reset(new MockCloudPrintDataSenderHelper); | 149 mock_helper_.reset(new MockCloudPrintDataSenderHelper); |
| 150 } | 150 } |
| 151 | 151 |
| 152 scoped_refptr<CloudPrintDataSender> CreateSender( | 152 scoped_refptr<CloudPrintDataSender> CreateSender( |
| 153 const base::RefCountedString* data) { | 153 const base::RefCountedString* data) { |
| 154 return new CloudPrintDataSender(mock_helper_.get(), | 154 return new CloudPrintDataSender(mock_helper_.get(), |
| 155 base::ASCIIToUTF16(kMockJobTitle), | 155 base::ASCIIToUTF16(kMockJobTitle), |
| 156 base::ASCIIToUTF16(kMockPrintTicket), | 156 base::ASCIIToUTF16(kMockPrintTicket), |
| 157 std::string("application/pdf"), | 157 std::string("application/pdf"), |
| 158 data); | 158 data); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 using internal_cloud_print_helpers::MockCloudPrintFlowHandler; | 216 using internal_cloud_print_helpers::MockCloudPrintFlowHandler; |
| 217 using internal_cloud_print_helpers::CloudPrintWebDialogDelegate; | 217 using internal_cloud_print_helpers::CloudPrintWebDialogDelegate; |
| 218 | 218 |
| 219 class CloudPrintWebDialogDelegateTest : public testing::Test { | 219 class CloudPrintWebDialogDelegateTest : public testing::Test { |
| 220 public: | 220 public: |
| 221 CloudPrintWebDialogDelegateTest() | 221 CloudPrintWebDialogDelegateTest() |
| 222 : ui_thread_(BrowserThread::UI, &message_loop_) {} | 222 : ui_thread_(BrowserThread::UI, &message_loop_) {} |
| 223 | 223 |
| 224 protected: | 224 protected: |
| 225 virtual void SetUp() { | 225 void SetUp() override { |
| 226 base::string16 mock_title; | 226 base::string16 mock_title; |
| 227 base::string16 mock_print_ticket; | 227 base::string16 mock_print_ticket; |
| 228 std::string mock_file_type; | 228 std::string mock_file_type; |
| 229 MockCloudPrintFlowHandler* handler = | 229 MockCloudPrintFlowHandler* handler = |
| 230 new MockCloudPrintFlowHandler(mock_print_ticket, mock_title, | 230 new MockCloudPrintFlowHandler(mock_print_ticket, mock_title, |
| 231 mock_file_type); | 231 mock_file_type); |
| 232 mock_flow_handler_ = handler->AsWeakPtr(); | 232 mock_flow_handler_ = handler->AsWeakPtr(); |
| 233 EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(_)); | 233 EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(_)); |
| 234 EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(NULL)); | 234 EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(NULL)); |
| 235 delegate_.reset(new CloudPrintWebDialogDelegate(mock_flow_handler_.get(), | 235 delegate_.reset(new CloudPrintWebDialogDelegate(mock_flow_handler_.get(), |
| 236 std::string())); | 236 std::string())); |
| 237 } | 237 } |
| 238 | 238 |
| 239 virtual void TearDown() { | 239 void TearDown() override { |
| 240 delegate_.reset(); | 240 delegate_.reset(); |
| 241 if (mock_flow_handler_.get()) | 241 if (mock_flow_handler_.get()) |
| 242 delete mock_flow_handler_.get(); | 242 delete mock_flow_handler_.get(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 base::MessageLoopForUI message_loop_; | 245 base::MessageLoopForUI message_loop_; |
| 246 content::TestBrowserThread ui_thread_; | 246 content::TestBrowserThread ui_thread_; |
| 247 base::WeakPtr<MockCloudPrintFlowHandler> mock_flow_handler_; | 247 base::WeakPtr<MockCloudPrintFlowHandler> mock_flow_handler_; |
| 248 scoped_ptr<CloudPrintWebDialogDelegate> delegate_; | 248 scoped_ptr<CloudPrintWebDialogDelegate> delegate_; |
| 249 }; | 249 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 267 std::vector<WebUIMessageHandler*> handlers; | 267 std::vector<WebUIMessageHandler*> handlers; |
| 268 delegate_->GetWebUIMessageHandlers(&handlers); | 268 delegate_->GetWebUIMessageHandlers(&handlers); |
| 269 delegate_.reset(); | 269 delegate_.reset(); |
| 270 EXPECT_THAT(mock_flow_handler_.get(), NotNull()); | 270 EXPECT_THAT(mock_flow_handler_.get(), NotNull()); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // Testing for ExternalWebDialogUI needs a mock WebContents and mock | 273 // Testing for ExternalWebDialogUI needs a mock WebContents and mock |
| 274 // CloudPrintWebDialogDelegate (attached to the mock web_contents). | 274 // CloudPrintWebDialogDelegate (attached to the mock web_contents). |
| 275 | 275 |
| 276 // Testing for PrintDialogCloud needs a mock Browser. | 276 // Testing for PrintDialogCloud needs a mock Browser. |
| OLD | NEW |