OLD | NEW |
1 // Copyright (c) 2009 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/scoped_nsobject.h" | 7 #include "base/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/infobar_test_helper.h" | 10 #include "chrome/browser/ui/cocoa/infobars/infobar_test_helper.h" |
11 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" | 11 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" |
(...skipping 30 matching lines...) Expand all Loading... |
42 // Call positionInfoBarsAndResize and check that |resizeDelegate_| got a | 42 // Call positionInfoBarsAndResize and check that |resizeDelegate_| got a |
43 // resize message. | 43 // resize message. |
44 [resizeDelegate_ setHeight:-1]; | 44 [resizeDelegate_ setHeight:-1]; |
45 [controller_ positionInfoBarsAndRedraw]; | 45 [controller_ positionInfoBarsAndRedraw]; |
46 EXPECT_NE(-1, [resizeDelegate_ height]); | 46 EXPECT_NE(-1, [resizeDelegate_ height]); |
47 } | 47 } |
48 | 48 |
49 TEST_F(InfoBarContainerControllerTest, AddAndRemoveInfoBars) { | 49 TEST_F(InfoBarContainerControllerTest, AddAndRemoveInfoBars) { |
50 NSView* view = [controller_ view]; | 50 NSView* view = [controller_ view]; |
51 | 51 |
52 // Add three infobars, one of each type, and then remove them. | 52 // Add three infobars and then remove them. |
53 // After each step check to make sure we have the correct number of | 53 // After each step check to make sure we have the correct number of |
54 // infobar subviews. | 54 // infobar subviews. |
55 MockAlertInfoBarDelegate alertDelegate; | 55 MockLinkInfoBarDelegate linkDelegate, linkDelegate2; |
56 MockLinkInfoBarDelegate linkDelegate; | |
57 MockConfirmInfoBarDelegate confirmDelegate; | 56 MockConfirmInfoBarDelegate confirmDelegate; |
58 | 57 |
59 [controller_ addInfoBar:&alertDelegate animate:NO]; | 58 [controller_ addInfoBar:&linkDelegate animate:NO]; |
60 EXPECT_EQ(1U, [[view subviews] count]); | 59 EXPECT_EQ(1U, [[view subviews] count]); |
61 | 60 |
62 [controller_ addInfoBar:&linkDelegate animate:NO]; | 61 [controller_ addInfoBar:&confirmDelegate animate:NO]; |
63 EXPECT_EQ(2U, [[view subviews] count]); | 62 EXPECT_EQ(2U, [[view subviews] count]); |
64 | 63 |
65 [controller_ addInfoBar:&confirmDelegate animate:NO]; | 64 [controller_ addInfoBar:&linkDelegate2 animate:NO]; |
66 EXPECT_EQ(3U, [[view subviews] count]); | 65 EXPECT_EQ(3U, [[view subviews] count]); |
67 | 66 |
68 // Just to mix things up, remove them in a different order. | 67 // Just to mix things up, remove them in a different order. |
69 [controller_ closeInfoBarsForDelegate:&linkDelegate animate:NO]; | 68 [controller_ closeInfoBarsForDelegate:&confirmDelegate animate:NO]; |
70 EXPECT_EQ(2U, [[view subviews] count]); | 69 EXPECT_EQ(2U, [[view subviews] count]); |
71 | 70 |
72 [controller_ closeInfoBarsForDelegate:&confirmDelegate animate:NO]; | 71 [controller_ closeInfoBarsForDelegate:&linkDelegate animate:NO]; |
73 EXPECT_EQ(1U, [[view subviews] count]); | 72 EXPECT_EQ(1U, [[view subviews] count]); |
74 | 73 |
75 [controller_ closeInfoBarsForDelegate:&alertDelegate animate:NO]; | 74 [controller_ closeInfoBarsForDelegate:&linkDelegate2 animate:NO]; |
76 EXPECT_EQ(0U, [[view subviews] count]); | 75 EXPECT_EQ(1U, [[view subviews] count]); |
77 } | 76 } |
78 | 77 |
79 TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) { | 78 TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) { |
80 NSView* view = [controller_ view]; | 79 NSView* view = [controller_ view]; |
81 | 80 |
82 // Add three infobars and then remove them all. | 81 // Add three infobars and then remove them all. |
83 MockAlertInfoBarDelegate alertDelegate; | |
84 MockLinkInfoBarDelegate linkDelegate; | 82 MockLinkInfoBarDelegate linkDelegate; |
85 MockConfirmInfoBarDelegate confirmDelegate; | 83 MockConfirmInfoBarDelegate confirmDelegate, confirmDelegate2; |
86 | 84 |
87 [controller_ addInfoBar:&alertDelegate animate:NO]; | |
88 [controller_ addInfoBar:&linkDelegate animate:NO]; | 85 [controller_ addInfoBar:&linkDelegate animate:NO]; |
89 [controller_ addInfoBar:&confirmDelegate animate:NO]; | 86 [controller_ addInfoBar:&confirmDelegate animate:NO]; |
| 87 [controller_ addInfoBar:&confirmDelegate2 animate:NO]; |
90 EXPECT_EQ(3U, [[view subviews] count]); | 88 EXPECT_EQ(3U, [[view subviews] count]); |
91 | 89 |
92 [controller_ removeAllInfoBars]; | 90 [controller_ removeAllInfoBars]; |
93 EXPECT_EQ(0U, [[view subviews] count]); | 91 EXPECT_EQ(0U, [[view subviews] count]); |
94 } | 92 } |
95 } // namespace | 93 } // namespace |
OLD | NEW |