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

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

Issue 6926001: Replace the virtual InfoBarDelegate::InfoBarClosed() function with a non-virtual one. This is a ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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) 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 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
9 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 9 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
10 #include "chrome/browser/ui/cocoa/infobars/mock_confirm_infobar_delegate.h" 10 #include "chrome/browser/ui/cocoa/infobars/mock_confirm_infobar_delegate.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 [controller_ positionInfoBarsAndRedraw]; 46 [controller_ positionInfoBarsAndRedraw];
47 EXPECT_NE(-1, [resizeDelegate_ height]); 47 EXPECT_NE(-1, [resizeDelegate_ height]);
48 } 48 }
49 49
50 TEST_F(InfoBarContainerControllerTest, AddAndRemoveInfoBars) { 50 TEST_F(InfoBarContainerControllerTest, AddAndRemoveInfoBars) {
51 NSView* view = [controller_ view]; 51 NSView* view = [controller_ view];
52 52
53 // Add three infobars and then remove them. 53 // Add three infobars and then remove them.
54 // After each step check to make sure we have the correct number of 54 // After each step check to make sure we have the correct number of
55 // infobar subviews. 55 // infobar subviews.
56 MockLinkInfoBarDelegate linkDelegate, linkDelegate2;
57 MockConfirmInfoBarDelegate confirmDelegate;
58 56
59 [controller_ addInfoBar:&linkDelegate animate:NO]; 57 // These delegates delete themselves when they're told their infobars have
58 // closed.
59 MockLinkInfoBarDelegate* linkDelegate = new MockLinkInfoBarDelegate(NULL);
60 MockLinkInfoBarDelegate* linkDelegate2 = new MockLinkInfoBarDelegate(NULL);
61 MockConfirmInfoBarDelegate* confirmDelegate =
62 new MockConfirmInfoBarDelegate(NULL);
63
64 [controller_ addInfoBar:linkDelegate animate:NO];
60 EXPECT_EQ(1U, [[view subviews] count]); 65 EXPECT_EQ(1U, [[view subviews] count]);
61 66
62 [controller_ addInfoBar:&confirmDelegate animate:NO]; 67 [controller_ addInfoBar:confirmDelegate animate:NO];
63 EXPECT_EQ(2U, [[view subviews] count]); 68 EXPECT_EQ(2U, [[view subviews] count]);
64 69
65 [controller_ addInfoBar:&linkDelegate2 animate:NO]; 70 [controller_ addInfoBar:linkDelegate2 animate:NO];
66 EXPECT_EQ(3U, [[view subviews] count]); 71 EXPECT_EQ(3U, [[view subviews] count]);
67 72
68 // Just to mix things up, remove them in a different order. 73 // Just to mix things up, remove them in a different order.
69 [controller_ closeInfoBarsForDelegate:&confirmDelegate animate:NO]; 74 [controller_ closeInfoBarsForDelegate:confirmDelegate animate:NO];
70 EXPECT_EQ(2U, [[view subviews] count]); 75 EXPECT_EQ(2U, [[view subviews] count]);
71 76
72 [controller_ closeInfoBarsForDelegate:&linkDelegate animate:NO]; 77 [controller_ closeInfoBarsForDelegate:linkDelegate animate:NO];
73 EXPECT_EQ(1U, [[view subviews] count]); 78 EXPECT_EQ(1U, [[view subviews] count]);
74 79
75 [controller_ closeInfoBarsForDelegate:&linkDelegate2 animate:NO]; 80 [controller_ closeInfoBarsForDelegate:linkDelegate2 animate:NO];
76 EXPECT_EQ(0U, [[view subviews] count]); 81 EXPECT_EQ(0U, [[view subviews] count]);
77 } 82 }
78 83
79 TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) { 84 TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) {
80 NSView* view = [controller_ view]; 85 NSView* view = [controller_ view];
81 86
82 // Add three infobars and then remove them all. 87 // Add three infobars and then remove them all.
83 MockLinkInfoBarDelegate linkDelegate;
84 MockConfirmInfoBarDelegate confirmDelegate, confirmDelegate2;
85 88
86 [controller_ addInfoBar:&linkDelegate animate:NO]; 89 // These delegates delete themselves when they're told their infobars have
87 [controller_ addInfoBar:&confirmDelegate animate:NO]; 90 // closed.
88 [controller_ addInfoBar:&confirmDelegate2 animate:NO]; 91 MockLinkInfoBarDelegate* linkDelegate = new MockLinkInfoBarDelegate(NULL);
92 MockConfirmInfoBarDelegate* confirmDelegate =
93 new MockConfirmInfoBarDelegate(NULL);
94 MockConfirmInfoBarDelegate* confirmDelegate2 =
95 new MockConfirmInfoBarDelegate(NULL);
96
97 [controller_ addInfoBar:linkDelegate animate:NO];
98 [controller_ addInfoBar:confirmDelegate animate:NO];
99 [controller_ addInfoBar:confirmDelegate2 animate:NO];
89 EXPECT_EQ(3U, [[view subviews] count]); 100 EXPECT_EQ(3U, [[view subviews] count]);
90 101
91 [controller_ removeAllInfoBars]; 102 [controller_ removeAllInfoBars];
92 EXPECT_EQ(0U, [[view subviews] count]); 103 EXPECT_EQ(0U, [[view subviews] count]);
93 } 104 }
94 } // namespace 105 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_init.cc ('k') | chrome/browser/ui/cocoa/infobars/infobar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698