Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: chrome/browser/printing/print_dialog_cloud_unittest.cc

Issue 10388214: Make cloud print dialog creation function not use browser list, instead obtain profile and parent w… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 string16 mock_print_ticket; 310 string16 mock_print_ticket;
311 std::string mock_file_type; 311 std::string mock_file_type;
312 MockCloudPrintFlowHandler* handler = 312 MockCloudPrintFlowHandler* handler =
313 new MockCloudPrintFlowHandler(mock_path, mock_print_ticket, 313 new MockCloudPrintFlowHandler(mock_path, mock_print_ticket,
314 mock_title, mock_file_type, 314 mock_title, mock_file_type,
315 false, base::Closure()); 315 false, base::Closure());
316 mock_flow_handler_ = handler->AsWeakPtr(); 316 mock_flow_handler_ = handler->AsWeakPtr();
317 EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(_)); 317 EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(_));
318 EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(NULL)); 318 EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(NULL));
319 delegate_.reset(new CloudPrintWebDialogDelegate( 319 delegate_.reset(new CloudPrintWebDialogDelegate(
320 mock_flow_handler_.get(), 100, 100, std::string(), true, false)); 320 mock_path, mock_flow_handler_.get(), std::string(), false));
321 } 321 }
322 322
323 virtual void TearDown() { 323 virtual void TearDown() {
324 delegate_.reset(); 324 delegate_.reset();
325 if (mock_flow_handler_) 325 if (mock_flow_handler_)
326 delete mock_flow_handler_.get(); 326 delete mock_flow_handler_.get();
327 } 327 }
328 328
329 MessageLoopForUI message_loop_; 329 MessageLoopForUI message_loop_;
330 content::TestBrowserThread ui_thread_; 330 content::TestBrowserThread ui_thread_;
331 base::WeakPtr<MockCloudPrintFlowHandler> mock_flow_handler_; 331 base::WeakPtr<MockCloudPrintFlowHandler> mock_flow_handler_;
332 scoped_ptr<CloudPrintWebDialogDelegate> delegate_; 332 scoped_ptr<CloudPrintWebDialogDelegate> delegate_;
333 }; 333 };
334 334
335 TEST_F(CloudPrintWebDialogDelegateTest, BasicChecks) { 335 TEST_F(CloudPrintWebDialogDelegateTest, BasicChecks) {
336 EXPECT_EQ(ui::MODAL_TYPE_WINDOW, delegate_->GetDialogModalType());
337 EXPECT_THAT(delegate_->GetDialogContentURL().spec(), 336 EXPECT_THAT(delegate_->GetDialogContentURL().spec(),
338 StrEq(chrome::kChromeUICloudPrintResourcesURL)); 337 StrEq(chrome::kChromeUICloudPrintResourcesURL));
339 EXPECT_TRUE(delegate_->GetDialogTitle().empty()); 338 EXPECT_TRUE(delegate_->GetDialogTitle().empty());
340 339
341 bool close_dialog = false; 340 bool close_dialog = false;
342 delegate_->OnCloseContents(NULL, &close_dialog); 341 delegate_->OnCloseContents(NULL, &close_dialog);
343 EXPECT_TRUE(close_dialog); 342 EXPECT_TRUE(close_dialog);
344 } 343 }
345 344
346 TEST_F(CloudPrintWebDialogDelegateTest, OwnedFlowDestroyed) { 345 TEST_F(CloudPrintWebDialogDelegateTest, OwnedFlowDestroyed) {
347 delegate_.reset(); 346 delegate_.reset();
348 EXPECT_THAT(mock_flow_handler_.get(), IsNull()); 347 EXPECT_THAT(mock_flow_handler_.get(), IsNull());
349 } 348 }
350 349
351 TEST_F(CloudPrintWebDialogDelegateTest, UnownedFlowLetGo) { 350 TEST_F(CloudPrintWebDialogDelegateTest, UnownedFlowLetGo) {
352 std::vector<WebUIMessageHandler*> handlers; 351 std::vector<WebUIMessageHandler*> handlers;
353 delegate_->GetWebUIMessageHandlers(&handlers); 352 delegate_->GetWebUIMessageHandlers(&handlers);
354 delegate_.reset(); 353 delegate_.reset();
355 EXPECT_THAT(mock_flow_handler_.get(), NotNull()); 354 EXPECT_THAT(mock_flow_handler_.get(), NotNull());
356 } 355 }
357 356
358 // Testing for ExternalWebDialogUI needs a mock WebContents, mock 357 // Testing for ExternalWebDialogUI needs a mock WebContents, mock
359 // CloudPrintWebDialogDelegate (provided through the mock 358 // CloudPrintWebDialogDelegate (provided through the mock
360 // tab_contents) 359 // tab_contents)
361 360
362 // Testing for PrintDialogCloud needs a mock Browser. 361 // Testing for PrintDialogCloud needs a mock Browser.
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_dialog_cloud_internal.h ('k') | chrome/browser/printing/printing_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698