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 #include "base/scoped_nsautorelease_pool.h" | 9 #include "base/scoped_nsautorelease_pool.h" |
10 #import "chrome/browser/cocoa/blocked_popup_container_controller.h" | 10 #import "chrome/browser/cocoa/blocked_popup_container_controller.h" |
11 #include "chrome/browser/cocoa/browser_test_helper.h" | 11 #include "chrome/browser/cocoa/browser_test_helper.h" |
12 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 12 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
13 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 13 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 | 17 |
18 namespace { | 18 namespace { |
19 const std::string host1 = "host1"; | 19 const std::string host1 = "host1"; |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 class BlockedPopupContainerControllerTest : public RenderViewHostTestHarness { | 22 class BlockedPopupContainerControllerTest : public RenderViewHostTestHarness { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 GURL GetTestCase(const std::string& file) { | 56 GURL GetTestCase(const std::string& file) { |
57 FilePath filename; | 57 FilePath filename; |
58 PathService::Get(app::DIR_TEST_DATA, &filename); | 58 PathService::Get(app::DIR_TEST_DATA, &filename); |
59 filename = filename.AppendASCII("constrained_files"); | 59 filename = filename.AppendASCII("constrained_files"); |
60 filename = filename.AppendASCII(file); | 60 filename = filename.AppendASCII(file); |
61 return net::FilePathToFileURL(filename); | 61 return net::FilePathToFileURL(filename); |
62 } | 62 } |
63 | 63 |
64 base::ScopedNSAutoreleasePool pool; | 64 base::ScopedNSAutoreleasePool pool; |
| 65 CocoaTestHelper cocoa_helper_; |
65 BlockedPopupContainer* container_; | 66 BlockedPopupContainer* container_; |
66 BlockedPopupContainerController* cocoa_controller_; | 67 BlockedPopupContainerController* cocoa_controller_; |
67 }; | 68 }; |
68 | 69 |
69 TEST_F(BlockedPopupContainerControllerTest, BasicPopupBlock) { | 70 TEST_F(BlockedPopupContainerControllerTest, BasicPopupBlock) { |
70 // This is taken from the popup blocker unit test. | 71 // This is taken from the popup blocker unit test. |
71 TabContents* popup = BuildTabContents(); | 72 TabContents* popup = BuildTabContents(); |
72 popup->controller().LoadURL(GetTestCase("error"), GURL(), | 73 popup->controller().LoadURL(GetTestCase("error"), GURL(), |
73 PageTransition::LINK); | 74 PageTransition::LINK); |
74 container_->AddTabContents(popup, gfx::Rect(), host1); | 75 container_->AddTabContents(popup, gfx::Rect(), host1); |
(...skipping 19 matching lines...) Expand all Loading... |
94 menu = [cocoa_controller_ buildMenu]; | 95 menu = [cocoa_controller_ buildMenu]; |
95 EXPECT_TRUE(menu); | 96 EXPECT_TRUE(menu); |
96 EXPECT_EQ([menu numberOfItems], 2); | 97 EXPECT_EQ([menu numberOfItems], 2); |
97 EXPECT_EQ([[menu itemAtIndex:1] state], NSOnState); | 98 EXPECT_EQ([[menu itemAtIndex:1] state], NSOnState); |
98 | 99 |
99 // Close the popup and verify it's no longer in the view hierarchy. This | 100 // Close the popup and verify it's no longer in the view hierarchy. This |
100 // means HideView() has been called. | 101 // means HideView() has been called. |
101 [cocoa_controller_ closePopup:nil]; | 102 [cocoa_controller_ closePopup:nil]; |
102 EXPECT_FALSE([[cocoa_controller_ view] superview]); | 103 EXPECT_FALSE([[cocoa_controller_ view] superview]); |
103 } | 104 } |
OLD | NEW |