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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 StringValue mock_job_title(kMockJobTitle); | 253 StringValue mock_job_title(kMockJobTitle); |
254 EXPECT_CALL(*mock_helper_, | 254 EXPECT_CALL(*mock_helper_, |
255 CallJavascriptFunction(_, _, StringValueEq(&mock_job_title))). | 255 CallJavascriptFunction(_, _, StringValueEq(&mock_job_title))). |
256 WillOnce(Return()); | 256 WillOnce(Return()); |
257 | 257 |
258 FilePath test_data_file_name = GetTestDataFileName(); | 258 FilePath test_data_file_name = GetTestDataFileName(); |
259 BrowserThread::PostTask( | 259 BrowserThread::PostTask( |
260 BrowserThread::FILE, FROM_HERE, | 260 BrowserThread::FILE, FROM_HERE, |
261 base::Bind(&CloudPrintDataSender::ReadPrintDataFile, | 261 base::Bind(&CloudPrintDataSender::ReadPrintDataFile, |
262 print_data_sender_.get(), test_data_file_name)); | 262 print_data_sender_.get(), test_data_file_name)); |
263 MessageLoop::current()->RunAllPending(); | 263 MessageLoop::current()->RunUntilIdle(); |
264 } | 264 } |
265 | 265 |
266 TEST_F(CloudPrintDataSenderTest, BadFile) { | 266 TEST_F(CloudPrintDataSenderTest, BadFile) { |
267 EXPECT_CALL(*mock_helper_, CallJavascriptFunction(_, _, _)).Times(0); | 267 EXPECT_CALL(*mock_helper_, CallJavascriptFunction(_, _, _)).Times(0); |
268 | 268 |
269 #if defined(OS_WIN) | 269 #if defined(OS_WIN) |
270 FilePath bad_data_file_name(L"/some/file/that/isnot/there"); | 270 FilePath bad_data_file_name(L"/some/file/that/isnot/there"); |
271 #else | 271 #else |
272 FilePath bad_data_file_name("/some/file/that/isnot/there"); | 272 FilePath bad_data_file_name("/some/file/that/isnot/there"); |
273 #endif | 273 #endif |
274 BrowserThread::PostTask( | 274 BrowserThread::PostTask( |
275 BrowserThread::FILE, FROM_HERE, | 275 BrowserThread::FILE, FROM_HERE, |
276 base::Bind(&CloudPrintDataSender::ReadPrintDataFile, | 276 base::Bind(&CloudPrintDataSender::ReadPrintDataFile, |
277 print_data_sender_.get(), bad_data_file_name)); | 277 print_data_sender_.get(), bad_data_file_name)); |
278 MessageLoop::current()->RunAllPending(); | 278 MessageLoop::current()->RunUntilIdle(); |
279 } | 279 } |
280 | 280 |
281 TEST_F(CloudPrintDataSenderTest, EmptyFile) { | 281 TEST_F(CloudPrintDataSenderTest, EmptyFile) { |
282 EXPECT_CALL(*mock_helper_, CallJavascriptFunction(_, _, _)).Times(0); | 282 EXPECT_CALL(*mock_helper_, CallJavascriptFunction(_, _, _)).Times(0); |
283 | 283 |
284 FilePath empty_data_file_name = GetEmptyDataFileName(); | 284 FilePath empty_data_file_name = GetEmptyDataFileName(); |
285 BrowserThread::PostTask( | 285 BrowserThread::PostTask( |
286 BrowserThread::FILE, FROM_HERE, | 286 BrowserThread::FILE, FROM_HERE, |
287 base::Bind(&CloudPrintDataSender::ReadPrintDataFile, | 287 base::Bind(&CloudPrintDataSender::ReadPrintDataFile, |
288 print_data_sender_.get(), empty_data_file_name)); | 288 print_data_sender_.get(), empty_data_file_name)); |
289 MessageLoop::current()->RunAllPending(); | 289 MessageLoop::current()->RunUntilIdle(); |
290 } | 290 } |
291 | 291 |
292 // Testing for CloudPrintFlowHandler needs a mock | 292 // Testing for CloudPrintFlowHandler needs a mock |
293 // CloudPrintWebDialogDelegate, mock CloudPrintDataSender, and a mock | 293 // CloudPrintWebDialogDelegate, mock CloudPrintDataSender, and a mock |
294 // WebUI. | 294 // WebUI. |
295 | 295 |
296 // Testing for CloudPrintWebDialogDelegate needs a mock | 296 // Testing for CloudPrintWebDialogDelegate needs a mock |
297 // CloudPrintFlowHandler. | 297 // CloudPrintFlowHandler. |
298 | 298 |
299 using internal_cloud_print_helpers::MockCloudPrintFlowHandler; | 299 using internal_cloud_print_helpers::MockCloudPrintFlowHandler; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 delegate_->GetWebUIMessageHandlers(&handlers); | 353 delegate_->GetWebUIMessageHandlers(&handlers); |
354 delegate_.reset(); | 354 delegate_.reset(); |
355 EXPECT_THAT(mock_flow_handler_.get(), NotNull()); | 355 EXPECT_THAT(mock_flow_handler_.get(), NotNull()); |
356 } | 356 } |
357 | 357 |
358 // Testing for ExternalWebDialogUI needs a mock WebContents, mock | 358 // Testing for ExternalWebDialogUI needs a mock WebContents, mock |
359 // CloudPrintWebDialogDelegate (provided through the mock | 359 // CloudPrintWebDialogDelegate (provided through the mock |
360 // tab_contents) | 360 // tab_contents) |
361 | 361 |
362 // Testing for PrintDialogCloud needs a mock Browser. | 362 // Testing for PrintDialogCloud needs a mock Browser. |
OLD | NEW |