OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/app_paths.h" | 7 #include "app/app_paths.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #import "chrome/browser/cocoa/blocked_popup_container_controller.h" | 9 #import "chrome/browser/cocoa/blocked_popup_container_controller.h" |
10 #include "chrome/browser/cocoa/browser_test_helper.h" | 10 #include "chrome/browser/cocoa/browser_test_helper.h" |
11 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
12 #include "chrome/browser/renderer_host/test_render_view_host.h" | 12 #include "chrome/browser/renderer_host/test_render_view_host.h" |
13 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 | 16 |
17 namespace { | 17 namespace { |
18 const std::string host1 = "host1"; | 18 const std::string host1 = "host1"; |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 class BlockedPopupContainerControllerTest : public RenderViewHostTestHarness { | 21 class BlockedPopupContainerControllerTest : public RenderViewHostTestHarness { |
22 public: | 22 public: |
23 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... | |
24 | |
25 virtual void SetUp() { | 23 virtual void SetUp() { |
26 RenderViewHostTestHarness::SetUp(); | 24 RenderViewHostTestHarness::SetUp(); |
27 container_ = BlockedPopupContainer::Create(contents(), profile()); | 25 container_ = BlockedPopupContainer::Create(contents(), profile()); |
28 cocoa_controller_ = [[BlockedPopupContainerController alloc] | 26 cocoa_controller_ = [[BlockedPopupContainerController alloc] |
29 initWithContainer:container_]; | 27 initWithContainer:container_]; |
30 EXPECT_TRUE([cocoa_controller_ bridge]); | 28 EXPECT_TRUE([cocoa_controller_ bridge]); |
31 container_->set_view([cocoa_controller_ bridge]); | 29 container_->set_view([cocoa_controller_ bridge]); |
32 contents_->set_blocked_popup_container(container_); | 30 contents_->set_blocked_popup_container(container_); |
33 } | 31 } |
34 | 32 |
35 virtual void TearDown() { | 33 virtual void TearDown() { |
36 // This will also signal the Cocoa controller to delete itself with a | 34 // This will also signal the Cocoa controller to delete itself with a |
37 // Destroy() mesage to the bridge. | 35 // Destroy() mesage to the bridge. It also clears out the association with |
| 36 // |contents_|. |
38 container_->Destroy(); | 37 container_->Destroy(); |
39 contents_->set_blocked_popup_container(NULL); | 38 RenderViewHostTestHarness::TearDown(); |
40 } | 39 } |
41 | 40 |
42 TabContents* BuildTabContents() { | 41 TabContents* BuildTabContents() { |
43 // This will be deleted when the TabContents goes away. | 42 // This will be deleted when the TabContents goes away. |
44 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); | 43 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); |
45 | 44 |
46 // Set up and use TestTabContents here. | 45 // Set up and use TestTabContents here. |
47 return new TestTabContents(profile_.get(), instance); | 46 return new TestTabContents(profile_.get(), instance); |
48 } | 47 } |
49 | 48 |
(...skipping 26 matching lines...) Expand all Loading... |
76 EXPECT_TRUE([cocoa_controller_ view]); | 75 EXPECT_TRUE([cocoa_controller_ view]); |
77 EXPECT_TRUE([[cocoa_controller_ view] superview]); | 76 EXPECT_TRUE([[cocoa_controller_ view] superview]); |
78 EXPECT_TRUE([[(NSTextField*)[cocoa_controller_ label] | 77 EXPECT_TRUE([[(NSTextField*)[cocoa_controller_ label] |
79 stringValue] length] > 0); | 78 stringValue] length] > 0); |
80 | 79 |
81 // Close the popup and verify it's no longer in the view hierarchy. This | 80 // Close the popup and verify it's no longer in the view hierarchy. This |
82 // means HideView() has been called. | 81 // means HideView() has been called. |
83 [cocoa_controller_ closePopup:nil]; | 82 [cocoa_controller_ closePopup:nil]; |
84 EXPECT_FALSE([[cocoa_controller_ view] superview]); | 83 EXPECT_FALSE([[cocoa_controller_ view] superview]); |
85 } | 84 } |
OLD | NEW |