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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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 "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 5 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 11 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
12 #import "chrome/browser/ui/cocoa/infobars/confirm_infobar_controller.h"
12 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" 13 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h"
13 #include "chrome/browser/ui/cocoa/infobars/mock_confirm_infobar_delegate.h" 14 #include "chrome/browser/ui/cocoa/infobars/mock_confirm_infobar_delegate.h"
14 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" 15 #import "chrome/browser/ui/cocoa/view_resizer_pong.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #import "content/public/browser/web_contents.h" 17 #import "content/public/browser/web_contents.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/platform_test.h" 19 #include "testing/platform_test.h"
19 20
20 namespace { 21 namespace {
21 22
(...skipping 30 matching lines...) Expand all
52 // Call positionInfoBarsAndResize and check that |resizeDelegate_| got a 53 // Call positionInfoBarsAndResize and check that |resizeDelegate_| got a
53 // resize message. 54 // resize message.
54 [resizeDelegate_ resizeView:[controller_ view] newHeight:-1]; 55 [resizeDelegate_ resizeView:[controller_ view] newHeight:-1];
55 [controller_ positionInfoBarsAndRedraw:NO]; 56 [controller_ positionInfoBarsAndRedraw:NO];
56 EXPECT_NE(-1, [resizeDelegate_ height]); 57 EXPECT_NE(-1, [resizeDelegate_ height]);
57 } 58 }
58 59
59 TEST_F(InfoBarContainerControllerTest, AddAndRemoveInfoBars) { 60 TEST_F(InfoBarContainerControllerTest, AddAndRemoveInfoBars) {
60 NSView* view = [controller_ view]; 61 NSView* view = [controller_ view];
61 62
62 // This delegate deletes itself when they're told their infobars have closed. 63 scoped_ptr<InfoBarDelegate> confirm_delegate(
63 InfoBarDelegate* confirmDelegate = new MockConfirmInfoBarDelegate(NULL); 64 new MockConfirmInfoBarDelegate(NULL));
64 65 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(confirm_delegate.Pass()));
65 InfoBarService* infobar_service = 66 base::scoped_nsobject<ConfirmInfoBarController> controller(
66 InfoBarService::FromWebContents(web_contents_.get()); 67 [[ConfirmInfoBarController alloc] initWithInfoBar:infobar.get()]);
67 scoped_ptr<InfoBarCocoa> infobar(static_cast<InfoBarCocoa*>( 68 infobar->set_controller(controller);
68 confirmDelegate->CreateInfoBar(infobar_service)));
69 [controller_ addInfoBar:infobar.get() position:0]; 69 [controller_ addInfoBar:infobar.get() position:0];
70 EXPECT_EQ(1U, [[view subviews] count]); 70 EXPECT_EQ(1U, [[view subviews] count]);
71 71
72 [controller_ removeInfoBar:infobar.release()]; 72 [controller_ removeInfoBar:infobar.get()];
73 EXPECT_EQ(0U, [[view subviews] count]); 73 EXPECT_EQ(0U, [[view subviews] count]);
74 } 74 }
75 75
76 } // namespace 76 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698