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