OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_helper.h" | |
6 | |
7 #import "base/mac/scoped_nsobject.h" | |
8 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" | |
9 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | |
10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | |
11 | |
12 namespace { | |
13 | |
14 // The Cocoa implementation of the TestToolbarActionsBarHelper, which creates | |
15 // (and owns) a BrowserActionsController and BrowserActionsContainerView for | |
16 // testing purposes. | |
17 class TestToolbarActionsBarHelperCocoa : public TestToolbarActionsBarHelper { | |
18 public: | |
19 TestToolbarActionsBarHelperCocoa(Browser* browser, | |
20 TestToolbarActionsBarHelperCocoa* mainBar); | |
21 ~TestToolbarActionsBarHelperCocoa() override; | |
22 | |
23 private: | |
24 // TestToolbarActionsBarHelper: | |
25 ToolbarActionsBar* GetToolbarActionsBar() override; | |
26 | |
27 // The owned BrowserActionsContainerView and BrowserActionsController; the | |
28 // mac implementation of the ToolbarActionsBar delegate and view. | |
29 base::scoped_nsobject<BrowserActionsContainerView> containerView_; | |
30 base::scoped_nsobject<BrowserActionsController> controller_; | |
31 | |
32 DISALLOW_COPY_AND_ASSIGN(TestToolbarActionsBarHelperCocoa); | |
33 }; | |
34 | |
35 TestToolbarActionsBarHelperCocoa::TestToolbarActionsBarHelperCocoa( | |
36 Browser* browser, | |
37 TestToolbarActionsBarHelperCocoa* mainBar) { | |
38 // Make sure that Cocoa has been bootstrapped. | |
39 CocoaTest::BootstrapCocoa(); | |
40 | |
41 containerView_.reset([[BrowserActionsContainerView alloc] | |
42 initWithFrame:NSMakeRect(0, 0, 0, 15)]); | |
43 BrowserActionsController* mainController = | |
44 mainBar ? mainBar->controller_.get() : nil; | |
45 controller_.reset([[BrowserActionsController alloc] | |
46 initWithBrowser:browser | |
47 containerView:containerView_.get() | |
48 mainController:mainController]); | |
49 } | |
50 | |
51 TestToolbarActionsBarHelperCocoa::~TestToolbarActionsBarHelperCocoa() {} | |
52 | |
53 ToolbarActionsBar* TestToolbarActionsBarHelperCocoa::GetToolbarActionsBar() { | |
54 return [controller_ toolbarActionsBar]; | |
55 } | |
56 | |
57 } // namespace | |
58 | |
59 scoped_ptr<TestToolbarActionsBarHelper> TestToolbarActionsBarHelper::Create( | |
60 Browser* browser, | |
61 TestToolbarActionsBarHelper* main_bar) { | |
62 return make_scoped_ptr(new TestToolbarActionsBarHelperCocoa( | |
63 browser, | |
64 static_cast<TestToolbarActionsBarHelperCocoa*>(main_bar))); | |
65 } | |
OLD | NEW |