Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 infobars own themselves. |
|
Nico
2011/05/04 21:15:52
This would be more informative if it was "These in
Peter Kasting
2011/05/04 22:54:56
Changed to "These delegates delete themselves when
| |
| 58 MockLinkInfoBarDelegate* linkDelegate = new MockLinkInfoBarDelegate(NULL); | |
| 59 MockLinkInfoBarDelegate* linkDelegate2 = new MockLinkInfoBarDelegate(NULL); | |
| 60 MockConfirmInfoBarDelegate* confirmDelegate = | |
| 61 new MockConfirmInfoBarDelegate(NULL); | |
| 62 | |
| 63 [controller_ addInfoBar:linkDelegate animate:NO]; | |
| 60 EXPECT_EQ(1U, [[view subviews] count]); | 64 EXPECT_EQ(1U, [[view subviews] count]); |
| 61 | 65 |
| 62 [controller_ addInfoBar:&confirmDelegate animate:NO]; | 66 [controller_ addInfoBar:confirmDelegate animate:NO]; |
| 63 EXPECT_EQ(2U, [[view subviews] count]); | 67 EXPECT_EQ(2U, [[view subviews] count]); |
| 64 | 68 |
| 65 [controller_ addInfoBar:&linkDelegate2 animate:NO]; | 69 [controller_ addInfoBar:linkDelegate2 animate:NO]; |
| 66 EXPECT_EQ(3U, [[view subviews] count]); | 70 EXPECT_EQ(3U, [[view subviews] count]); |
| 67 | 71 |
| 68 // Just to mix things up, remove them in a different order. | 72 // Just to mix things up, remove them in a different order. |
| 69 [controller_ closeInfoBarsForDelegate:&confirmDelegate animate:NO]; | 73 [controller_ closeInfoBarsForDelegate:confirmDelegate animate:NO]; |
| 70 EXPECT_EQ(2U, [[view subviews] count]); | 74 EXPECT_EQ(2U, [[view subviews] count]); |
| 71 | 75 |
| 72 [controller_ closeInfoBarsForDelegate:&linkDelegate animate:NO]; | 76 [controller_ closeInfoBarsForDelegate:linkDelegate animate:NO]; |
| 73 EXPECT_EQ(1U, [[view subviews] count]); | 77 EXPECT_EQ(1U, [[view subviews] count]); |
| 74 | 78 |
| 75 [controller_ closeInfoBarsForDelegate:&linkDelegate2 animate:NO]; | 79 [controller_ closeInfoBarsForDelegate:linkDelegate2 animate:NO]; |
| 76 EXPECT_EQ(0U, [[view subviews] count]); | 80 EXPECT_EQ(0U, [[view subviews] count]); |
| 77 } | 81 } |
| 78 | 82 |
| 79 TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) { | 83 TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) { |
| 80 NSView* view = [controller_ view]; | 84 NSView* view = [controller_ view]; |
| 81 | 85 |
| 82 // Add three infobars and then remove them all. | 86 // Add three infobars and then remove them all. |
| 83 MockLinkInfoBarDelegate linkDelegate; | |
| 84 MockConfirmInfoBarDelegate confirmDelegate, confirmDelegate2; | |
| 85 | 87 |
| 86 [controller_ addInfoBar:&linkDelegate animate:NO]; | 88 // These infobars own themselves. |
| 87 [controller_ addInfoBar:&confirmDelegate animate:NO]; | 89 MockLinkInfoBarDelegate* linkDelegate = new MockLinkInfoBarDelegate(NULL); |
| 88 [controller_ addInfoBar:&confirmDelegate2 animate:NO]; | 90 MockConfirmInfoBarDelegate* confirmDelegate = |
| 91 new MockConfirmInfoBarDelegate(NULL); | |
| 92 MockConfirmInfoBarDelegate* confirmDelegate2 = | |
| 93 new MockConfirmInfoBarDelegate(NULL); | |
| 94 | |
| 95 [controller_ addInfoBar:linkDelegate animate:NO]; | |
| 96 [controller_ addInfoBar:confirmDelegate animate:NO]; | |
| 97 [controller_ addInfoBar:confirmDelegate2 animate:NO]; | |
| 89 EXPECT_EQ(3U, [[view subviews] count]); | 98 EXPECT_EQ(3U, [[view subviews] count]); |
| 90 | 99 |
| 91 [controller_ removeAllInfoBars]; | 100 [controller_ removeAllInfoBars]; |
| 92 EXPECT_EQ(0U, [[view subviews] count]); | 101 EXPECT_EQ(0U, [[view subviews] count]); |
| 93 } | 102 } |
| 94 } // namespace | 103 } // namespace |
| OLD | NEW |