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

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

Issue 7006010: Change InfoBar-related notifications to be sourced from a TabContentsWrapper, not a TabContents. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 56
57 // These delegates delete themselves when they're told their infobars have 57 // These delegates delete themselves when they're told their infobars have
58 // closed. 58 // closed.
59 MockLinkInfoBarDelegate* linkDelegate = new MockLinkInfoBarDelegate(NULL); 59 InfoBarDelegate* linkDelegate = new MockLinkInfoBarDelegate(NULL);
60 MockLinkInfoBarDelegate* linkDelegate2 = new MockLinkInfoBarDelegate(NULL); 60 InfoBarDelegate* linkDelegate2 = new MockLinkInfoBarDelegate(NULL);
61 MockConfirmInfoBarDelegate* confirmDelegate = 61 InfoBarDelegate* confirmDelegate = new MockConfirmInfoBarDelegate(NULL);
62 new MockConfirmInfoBarDelegate(NULL);
63 62
64 [controller_ addInfoBar:linkDelegate animate:NO]; 63 [controller_ addInfoBar:linkDelegate->CreateInfoBar(NULL)
64 animate:NO
65 deleteImmediately:YES];
65 EXPECT_EQ(1U, [[view subviews] count]); 66 EXPECT_EQ(1U, [[view subviews] count]);
66 67
67 [controller_ addInfoBar:confirmDelegate animate:NO]; 68 [controller_ addInfoBar:confirmDelegate->CreateInfoBar(NULL)
69 animate:NO
70 deleteImmediately:YES];
68 EXPECT_EQ(2U, [[view subviews] count]); 71 EXPECT_EQ(2U, [[view subviews] count]);
69 72
70 [controller_ addInfoBar:linkDelegate2 animate:NO]; 73 [controller_ addInfoBar:linkDelegate2->CreateInfoBar(NULL)
74 animate:NO
75 deleteImmediately:YES];
71 EXPECT_EQ(3U, [[view subviews] count]); 76 EXPECT_EQ(3U, [[view subviews] count]);
72 77
73 // Just to mix things up, remove them in a different order. 78 // Just to mix things up, remove them in a different order.
74 [controller_ closeInfoBarsForDelegate:confirmDelegate animate:NO]; 79 [controller_ closeInfoBarsForDelegate:confirmDelegate animate:NO];
75 EXPECT_EQ(2U, [[view subviews] count]); 80 EXPECT_EQ(2U, [[view subviews] count]);
76 81
77 [controller_ closeInfoBarsForDelegate:linkDelegate animate:NO]; 82 [controller_ closeInfoBarsForDelegate:linkDelegate animate:NO];
78 EXPECT_EQ(1U, [[view subviews] count]); 83 EXPECT_EQ(1U, [[view subviews] count]);
79 84
80 [controller_ closeInfoBarsForDelegate:linkDelegate2 animate:NO]; 85 [controller_ closeInfoBarsForDelegate:linkDelegate2 animate:NO];
81 EXPECT_EQ(0U, [[view subviews] count]); 86 EXPECT_EQ(0U, [[view subviews] count]);
82 } 87 }
83 88
84 TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) { 89 TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) {
85 NSView* view = [controller_ view]; 90 NSView* view = [controller_ view];
86 91
87 // Add three infobars and then remove them all. 92 // Add three infobars and then remove them all.
88 93
89 // removeAllInfobars does not close these, so we stack-allocate them so 94 // removeAllInfobars does not close these, so we stack-allocate them so
90 // they'll get cleaned up. 95 // they'll get cleaned up.
91 MockLinkInfoBarDelegate linkDelegate(NULL); 96 MockLinkInfoBarDelegate linkDelegate(NULL);
92 MockConfirmInfoBarDelegate confirmDelegate(NULL); 97 MockConfirmInfoBarDelegate confirmDelegate(NULL);
93 MockConfirmInfoBarDelegate confirmDelegate2(NULL); 98 MockConfirmInfoBarDelegate confirmDelegate2(NULL);
99 InfoBarDelegate* linkDelegatePtr = &linkDelegate;
100 InfoBarDelegate* confirmDelegatePtr = &confirmDelegate;
101 InfoBarDelegate* confirmDelegate2Ptr = &confirmDelegate2;
94 102
95 [controller_ addInfoBar:&linkDelegate animate:NO]; 103 [controller_ addInfoBar:linkDelegatePtr->CreateInfoBar(NULL)
96 [controller_ addInfoBar:&confirmDelegate animate:NO]; 104 animate:NO
97 [controller_ addInfoBar:&confirmDelegate2 animate:NO]; 105 deleteImmediately:YES];
106 [controller_ addInfoBar:confirmDelegatePtr->CreateInfoBar(NULL)
107 animate:NO
108 deleteImmediately:YES];
109 [controller_ addInfoBar:confirmDelegate2Ptr->CreateInfoBar(NULL)
110 animate:NO
111 deleteImmediately:YES];
98 EXPECT_EQ(3U, [[view subviews] count]); 112 EXPECT_EQ(3U, [[view subviews] count]);
99 113
100 [controller_ removeAllInfoBars]; 114 [controller_ removeAllInfoBars];
101 EXPECT_EQ(0U, [[view subviews] count]); 115 EXPECT_EQ(0U, [[view subviews] count]);
102 } 116 }
103 } // namespace 117 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698