| 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" | 12 #import "chrome/browser/ui/cocoa/infobars/confirm_infobar_controller.h" |
| 13 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" | 13 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" |
| 14 #include "chrome/browser/ui/cocoa/infobars/mock_confirm_infobar_delegate.h" | 14 #include "chrome/browser/ui/cocoa/infobars/mock_confirm_infobar_delegate.h" |
| 15 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" | 15 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #import "content/public/browser/web_contents.h" | 17 #import "content/public/browser/web_contents.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "testing/platform_test.h" | 19 #include "testing/platform_test.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class InfoBarContainerControllerTest : public CocoaProfileTest { | 23 class InfoBarContainerControllerTest : public CocoaProfileTest { |
| 24 virtual void SetUp() OVERRIDE { | 24 virtual void SetUp() override { |
| 25 CocoaProfileTest::SetUp(); | 25 CocoaProfileTest::SetUp(); |
| 26 web_contents_.reset(content::WebContents::Create( | 26 web_contents_.reset(content::WebContents::Create( |
| 27 content::WebContents::CreateParams(profile()))); | 27 content::WebContents::CreateParams(profile()))); |
| 28 InfoBarService::CreateForWebContents(web_contents_.get()); | 28 InfoBarService::CreateForWebContents(web_contents_.get()); |
| 29 | 29 |
| 30 resizeDelegate_.reset([[ViewResizerPong alloc] init]); | 30 resizeDelegate_.reset([[ViewResizerPong alloc] init]); |
| 31 ViewResizerPong *viewResizer = resizeDelegate_.get(); | 31 ViewResizerPong *viewResizer = resizeDelegate_.get(); |
| 32 controller_.reset([[InfoBarContainerController alloc] | 32 controller_.reset([[InfoBarContainerController alloc] |
| 33 initWithResizeDelegate:viewResizer]); | 33 initWithResizeDelegate:viewResizer]); |
| 34 NSView* view = [controller_ view]; | 34 NSView* view = [controller_ view]; |
| 35 [[test_window() contentView] addSubview:view]; | 35 [[test_window() contentView] addSubview:view]; |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual void TearDown() OVERRIDE { | 38 virtual void TearDown() override { |
| 39 [[controller_ view] removeFromSuperviewWithoutNeedingDisplay]; | 39 [[controller_ view] removeFromSuperviewWithoutNeedingDisplay]; |
| 40 controller_.reset(); | 40 controller_.reset(); |
| 41 CocoaProfileTest::TearDown(); | 41 CocoaProfileTest::TearDown(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 public: | 44 public: |
| 45 base::scoped_nsobject<ViewResizerPong> resizeDelegate_; | 45 base::scoped_nsobject<ViewResizerPong> resizeDelegate_; |
| 46 base::scoped_nsobject<InfoBarContainerController> controller_; | 46 base::scoped_nsobject<InfoBarContainerController> controller_; |
| 47 scoped_ptr<content::WebContents> web_contents_; | 47 scoped_ptr<content::WebContents> web_contents_; |
| 48 }; | 48 }; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 67 [[ConfirmInfoBarController alloc] initWithInfoBar:infobar.get()]); | 67 [[ConfirmInfoBarController alloc] initWithInfoBar:infobar.get()]); |
| 68 infobar->set_controller(controller); | 68 infobar->set_controller(controller); |
| 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.get()]; |
| 73 EXPECT_EQ(0U, [[view subviews] count]); | 73 EXPECT_EQ(0U, [[view subviews] count]); |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace | 76 } // namespace |
| OLD | NEW |