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

Side by Side Diff: chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm

Issue 10868072: Make TabContents ctor private; poke hole for existing callers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all green Created 8 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/memory/scoped_nsobject.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
11 #include "chrome/browser/infobars/infobar_tab_helper.h" 11 #include "chrome/browser/infobars/infobar_tab_helper.h"
12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
13 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 13 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
14 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" 14 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
15 #include "chrome/browser/ui/cocoa/infobars/mock_confirm_infobar_delegate.h" 15 #include "chrome/browser/ui/cocoa/infobars/mock_confirm_infobar_delegate.h"
16 #include "chrome/browser/ui/cocoa/infobars/mock_link_infobar_delegate.h" 16 #include "chrome/browser/ui/cocoa/infobars/mock_link_infobar_delegate.h"
17 #include "chrome/browser/ui/cocoa/run_loop_testing.h" 17 #include "chrome/browser/ui/cocoa/run_loop_testing.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
19 #import "content/public/browser/web_contents.h" 19 #import "content/public/browser/web_contents.h"
20 #include "ipc/ipc_message.h" 20 #include "ipc/ipc_message.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/platform_test.h" 22 #include "testing/platform_test.h"
23 23
24 using content::WebContents; 24 using content::WebContents;
25 25
26 // TODO(avi): Kill this when TabContents goes away.
27 class InfoBarControllerContentsCreator {
28 public:
29 static TabContents* CreateTabContents(content::WebContents* contents) {
30 return TabContents::Factory::CreateTabContents(contents);
31 }
32 };
33
26 @interface InfoBarController (ExposedForTesting) 34 @interface InfoBarController (ExposedForTesting)
27 - (NSString*)labelString; 35 - (NSString*)labelString;
28 - (NSRect)labelFrame; 36 - (NSRect)labelFrame;
29 @end 37 @end
30 38
31 @implementation InfoBarController (ExposedForTesting) 39 @implementation InfoBarController (ExposedForTesting)
32 - (NSString*)labelString { 40 - (NSString*)labelString {
33 return [label_.get() string]; 41 return [label_.get() string];
34 } 42 }
35 - (NSRect)labelFrame { 43 - (NSRect)labelFrame {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 namespace { 101 namespace {
94 102
95 /////////////////////////////////////////////////////////////////////////// 103 ///////////////////////////////////////////////////////////////////////////
96 // Test fixtures 104 // Test fixtures
97 105
98 class LinkInfoBarControllerTest : public CocoaProfileTest, 106 class LinkInfoBarControllerTest : public CocoaProfileTest,
99 public MockLinkInfoBarDelegate::Owner { 107 public MockLinkInfoBarDelegate::Owner {
100 public: 108 public:
101 virtual void SetUp() { 109 virtual void SetUp() {
102 CocoaProfileTest::SetUp(); 110 CocoaProfileTest::SetUp();
103 tab_contents_.reset(new TabContents(WebContents::Create( 111 tab_contents_.reset(InfoBarControllerContentsCreator::CreateTabContents(
104 profile(), NULL, MSG_ROUTING_NONE, NULL))); 112 WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL)));
105 tab_contents_->infobar_tab_helper()->set_infobars_enabled(false); 113 tab_contents_->infobar_tab_helper()->set_infobars_enabled(false);
106 114
107 delegate_ = new MockLinkInfoBarDelegate(this); 115 delegate_ = new MockLinkInfoBarDelegate(this);
108 controller_.reset([[TestLinkInfoBarController alloc] 116 controller_.reset([[TestLinkInfoBarController alloc]
109 initWithDelegate:delegate_ 117 initWithDelegate:delegate_
110 owner:tab_contents_.get()->infobar_tab_helper()]); 118 owner:tab_contents_.get()->infobar_tab_helper()]);
111 container_.reset( 119 container_.reset(
112 [[InfoBarContainerTest alloc] initWithController:controller_]); 120 [[InfoBarContainerTest alloc] initWithController:controller_]);
113 [controller_ setContainerController:container_]; 121 [controller_ setContainerController:container_];
114 [[test_window() contentView] addSubview:[controller_ view]]; 122 [[test_window() contentView] addSubview:[controller_ view]];
(...skipping 22 matching lines...) Expand all
137 } 145 }
138 146
139 scoped_ptr<TabContents> tab_contents_; 147 scoped_ptr<TabContents> tab_contents_;
140 }; 148 };
141 149
142 class ConfirmInfoBarControllerTest : public CocoaProfileTest, 150 class ConfirmInfoBarControllerTest : public CocoaProfileTest,
143 public MockConfirmInfoBarDelegate::Owner { 151 public MockConfirmInfoBarDelegate::Owner {
144 public: 152 public:
145 virtual void SetUp() { 153 virtual void SetUp() {
146 CocoaProfileTest::SetUp(); 154 CocoaProfileTest::SetUp();
147 tab_contents_.reset(new TabContents(WebContents::Create( 155 tab_contents_.reset(InfoBarControllerContentsCreator::CreateTabContents(
148 profile(), NULL, MSG_ROUTING_NONE, NULL))); 156 WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL)));
149 tab_contents_->infobar_tab_helper()->set_infobars_enabled(false); 157 tab_contents_->infobar_tab_helper()->set_infobars_enabled(false);
150 158
151 delegate_ = new MockConfirmInfoBarDelegate(this); 159 delegate_ = new MockConfirmInfoBarDelegate(this);
152 controller_.reset([[TestConfirmInfoBarController alloc] 160 controller_.reset([[TestConfirmInfoBarController alloc]
153 initWithDelegate:delegate_ 161 initWithDelegate:delegate_
154 owner:tab_contents_.get()->infobar_tab_helper()]); 162 owner:tab_contents_.get()->infobar_tab_helper()]);
155 container_.reset( 163 container_.reset(
156 [[InfoBarContainerTest alloc] initWithController:controller_]); 164 [[InfoBarContainerTest alloc] initWithController:controller_]);
157 [controller_ setContainerController:container_]; 165 [controller_ setContainerController:container_];
158 [[test_window() contentView] addSubview:[controller_ view]]; 166 [[test_window() contentView] addSubview:[controller_ view]];
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 const CGFloat width = 20; 338 const CGFloat width = 20;
331 NSRect newViewFrame = [[controller_ view] frame]; 339 NSRect newViewFrame = [[controller_ view] frame];
332 newViewFrame.size.width += width; 340 newViewFrame.size.width += width;
333 [[controller_ view] setFrame:newViewFrame]; 341 [[controller_ view] setFrame:newViewFrame];
334 342
335 NSRect newLabelFrame = [controller_ labelFrame]; 343 NSRect newLabelFrame = [controller_ labelFrame];
336 EXPECT_EQ(NSWidth(newLabelFrame), NSWidth(originalLabelFrame) + width); 344 EXPECT_EQ(NSWidth(newLabelFrame), NSWidth(originalLabelFrame) + width);
337 } 345 }
338 346
339 } // namespace 347 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_tabstrip.cc ('k') | chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698