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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller_unittest.mm

Issue 2086663003: Change ChooserController ownership model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed temporary unique ptr at ChooserBubbleUiCocoa Created 4 years, 5 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 17 matching lines...) Expand all
28 CocoaProfileTest::SetUp(); 28 CocoaProfileTest::SetUp();
29 ASSERT_TRUE(browser()); 29 ASSERT_TRUE(browser());
30 } 30 }
31 31
32 // Create a ChooserDialogCocoa. 32 // Create a ChooserDialogCocoa.
33 void CreateChooserDialog() { 33 void CreateChooserDialog() {
34 content::WebContents* web_contents = 34 content::WebContents* web_contents =
35 content::WebContents::Create(content::WebContents::CreateParams( 35 content::WebContents::Create(content::WebContents::CreateParams(
36 profile(), content::SiteInstance::Create(profile()))); 36 profile(), content::SiteInstance::Create(profile())));
37 ASSERT_TRUE(web_contents); 37 ASSERT_TRUE(web_contents);
38 chooser_controller_.reset( 38 std::unique_ptr<MockChooserController> chooser_controller(
39 new MockChooserController(web_contents->GetMainFrame())); 39 new MockChooserController(web_contents->GetMainFrame()));
40 ASSERT_TRUE(chooser_controller_); 40 ASSERT_TRUE(chooser_controller);
41 chooser_controller_ = chooser_controller.get();
41 chooser_dialog_.reset( 42 chooser_dialog_.reset(
42 new ChooserDialogCocoa(web_contents, chooser_controller_.get())); 43 new ChooserDialogCocoa(web_contents, std::move(chooser_controller)));
43 ASSERT_TRUE(chooser_dialog_); 44 ASSERT_TRUE(chooser_dialog_);
44 chooser_dialog_controller_ = 45 chooser_dialog_controller_ =
45 chooser_dialog_->chooser_dialog_cocoa_controller_.get(); 46 chooser_dialog_->chooser_dialog_cocoa_controller_.get();
46 ASSERT_TRUE(chooser_dialog_controller_); 47 ASSERT_TRUE(chooser_dialog_controller_);
47 chooser_content_view_ = [chooser_dialog_controller_ chooserContentView]; 48 chooser_content_view_ = [chooser_dialog_controller_ chooserContentView];
48 ASSERT_TRUE(chooser_content_view_); 49 ASSERT_TRUE(chooser_content_view_);
49 table_view_ = [chooser_content_view_ tableView]; 50 table_view_ = [chooser_content_view_ tableView];
50 ASSERT_TRUE(table_view_); 51 ASSERT_TRUE(table_view_);
51 connect_button_ = [chooser_content_view_ connectButton]; 52 connect_button_ = [chooser_content_view_ connectButton];
52 ASSERT_TRUE(connect_button_); 53 ASSERT_TRUE(connect_button_);
53 cancel_button_ = [chooser_content_view_ cancelButton]; 54 cancel_button_ = [chooser_content_view_ cancelButton];
54 ASSERT_TRUE(cancel_button_); 55 ASSERT_TRUE(cancel_button_);
55 help_button_ = [chooser_content_view_ helpButton]; 56 help_button_ = [chooser_content_view_ helpButton];
56 ASSERT_TRUE(help_button_); 57 ASSERT_TRUE(help_button_);
57 } 58 }
58 59
59 std::unique_ptr<MockChooserController> chooser_controller_;
60 std::unique_ptr<ChooserDialogCocoa> chooser_dialog_; 60 std::unique_ptr<ChooserDialogCocoa> chooser_dialog_;
61 61
62 MockChooserController* chooser_controller_;
62 ChooserDialogCocoaController* chooser_dialog_controller_; 63 ChooserDialogCocoaController* chooser_dialog_controller_;
63 ChooserContentViewCocoa* chooser_content_view_; 64 ChooserContentViewCocoa* chooser_content_view_;
64 NSTableView* table_view_; 65 NSTableView* table_view_;
65 NSButton* connect_button_; 66 NSButton* connect_button_;
66 NSButton* cancel_button_; 67 NSButton* cancel_button_;
67 NSButton* help_button_; 68 NSButton* help_button_;
68 69
69 private: 70 private:
70 DISALLOW_COPY_AND_ASSIGN(ChooserDialogCocoaControllerTest); 71 DISALLOW_COPY_AND_ASSIGN(ChooserDialogCocoaControllerTest);
71 }; 72 };
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 chooser_controller_->OptionAdded(base::ASCIIToUTF16("c")); 361 chooser_controller_->OptionAdded(base::ASCIIToUTF16("c"));
361 362
362 // Select option 0 and press "Get help" button. 363 // Select option 0 and press "Get help" button.
363 [table_view_ selectRowIndexes:[NSIndexSet indexSetWithIndex:0] 364 [table_view_ selectRowIndexes:[NSIndexSet indexSetWithIndex:0]
364 byExtendingSelection:NO]; 365 byExtendingSelection:NO];
365 EXPECT_CALL(*chooser_controller_, Select(testing::_)).Times(0); 366 EXPECT_CALL(*chooser_controller_, Select(testing::_)).Times(0);
366 EXPECT_CALL(*chooser_controller_, Cancel()).Times(0); 367 EXPECT_CALL(*chooser_controller_, Cancel()).Times(0);
367 EXPECT_CALL(*chooser_controller_, OpenHelpCenterUrl()).Times(1); 368 EXPECT_CALL(*chooser_controller_, OpenHelpCenterUrl()).Times(1);
368 [help_button_ performClick:chooser_dialog_controller_]; 369 [help_button_ performClick:chooser_dialog_controller_];
369 } 370 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698