| 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/mac/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" |
| 11 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" | 11 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class InfoBarContainerControllerTest : public CocoaTest { | 17 class InfoBarContainerControllerTest : public CocoaTest { |
| 18 virtual void SetUp() { | 18 virtual void SetUp() { |
| 19 CocoaTest::SetUp(); | 19 CocoaTest::SetUp(); |
| 20 resizeDelegate_.reset([[ViewResizerPong alloc] init]); | 20 resizeDelegate_.reset([[ViewResizerPong alloc] init]); |
| 21 ViewResizerPong *viewResizer = resizeDelegate_.get(); | 21 ViewResizerPong *viewResizer = resizeDelegate_.get(); |
| 22 controller_ = | 22 controller_ = |
| 23 [[InfoBarContainerController alloc] initWithResizeDelegate:viewResizer]; | 23 [[InfoBarContainerController alloc] initWithResizeDelegate:viewResizer]; |
| 24 NSView* view = [controller_ view]; | 24 NSView* view = [controller_ view]; |
| 25 [[test_window() contentView] addSubview:view]; | 25 [[test_window() contentView] addSubview:view]; |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual void TearDown() { | 28 virtual void TearDown() { |
| 29 [[controller_ view] removeFromSuperviewWithoutNeedingDisplay]; | 29 [[controller_ view] removeFromSuperviewWithoutNeedingDisplay]; |
| 30 [controller_ release]; | 30 [controller_ release]; |
| 31 CocoaTest::TearDown(); | 31 CocoaTest::TearDown(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 public: | 34 public: |
| 35 scoped_nsobject<ViewResizerPong> resizeDelegate_; | 35 base::scoped_nsobject<ViewResizerPong> resizeDelegate_; |
| 36 InfoBarContainerController* controller_; | 36 InfoBarContainerController* controller_; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 TEST_VIEW(InfoBarContainerControllerTest, [controller_ view]) | 39 TEST_VIEW(InfoBarContainerControllerTest, [controller_ view]) |
| 40 | 40 |
| 41 TEST_F(InfoBarContainerControllerTest, BWCPong) { | 41 TEST_F(InfoBarContainerControllerTest, BWCPong) { |
| 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]; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 [controller_ addInfoBar:confirmDelegatePtr->CreateInfoBar(NULL) animate:NO]; | 79 [controller_ addInfoBar:confirmDelegatePtr->CreateInfoBar(NULL) animate:NO]; |
| 80 [controller_ addInfoBar:confirmDelegate2Ptr->CreateInfoBar(NULL) animate:NO]; | 80 [controller_ addInfoBar:confirmDelegate2Ptr->CreateInfoBar(NULL) animate:NO]; |
| 81 EXPECT_EQ(2U, [[view subviews] count]); | 81 EXPECT_EQ(2U, [[view subviews] count]); |
| 82 | 82 |
| 83 [controller_ removeAllInfoBars]; | 83 [controller_ removeAllInfoBars]; |
| 84 EXPECT_EQ(0U, [[view subviews] count]); | 84 EXPECT_EQ(0U, [[view subviews] count]); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace | 87 } // namespace |
| OLD | NEW |