Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2756)

Unified Diff: chrome/browser/cocoa/blocked_popup_container_controller_unittest.mm

Issue 149145: Add remaining functionality for popup blocker: popup menu to unblock individu... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/blocked_popup_container_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/blocked_popup_container_controller_unittest.mm
===================================================================
--- chrome/browser/cocoa/blocked_popup_container_controller_unittest.mm (revision 19942)
+++ chrome/browser/cocoa/blocked_popup_container_controller_unittest.mm (working copy)
@@ -6,6 +6,7 @@
#include "app/app_paths.h"
#include "base/path_service.h"
+#include "base/scoped_nsautorelease_pool.h"
#import "chrome/browser/cocoa/blocked_popup_container_controller.h"
#include "chrome/browser/cocoa/browser_test_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
@@ -21,12 +22,18 @@
class BlockedPopupContainerControllerTest : public RenderViewHostTestHarness {
public:
virtual void SetUp() {
+ // This is all a bit convoluted because the standard factory Create() call
+ // doesn't give us access to the cocoa controller for testing (since it's
+ // an internal implementation detail). As a result, we need to create one
+ // separately and inject the bridge with a test-only Create() call.
+ // Unfortunate, but no way around it.
RenderViewHostTestHarness::SetUp();
- container_ = BlockedPopupContainer::Create(contents(), profile());
cocoa_controller_ = [[BlockedPopupContainerController alloc]
- initWithContainer:container_];
+ initWithContainer:nil];
EXPECT_TRUE([cocoa_controller_ bridge]);
- container_->set_view([cocoa_controller_ bridge]);
+ container_ = BlockedPopupContainer::Create(contents(), profile(),
+ [cocoa_controller_ bridge]);
+ [cocoa_controller_ setContainer:container_];
contents_->set_blocked_popup_container(container_);
}
@@ -54,6 +61,7 @@
return net::FilePathToFileURL(filename);
}
+ base::ScopedNSAutoreleasePool pool;
BlockedPopupContainer* container_;
BlockedPopupContainerController* cocoa_controller_;
};
@@ -70,13 +78,25 @@
EXPECT_FALSE(container_->IsHostWhitelisted(0));
// Ensure the view has been displayed. If it has a superview, then ShowView()
- // has been called on the bridge. If the label has a string, then
+ // has been called on the bridge. If the button has a string, then
// UpdateLabel() has been called.
EXPECT_TRUE([cocoa_controller_ view]);
EXPECT_TRUE([[cocoa_controller_ view] superview]);
- EXPECT_TRUE([[(NSTextField*)[cocoa_controller_ label]
- stringValue] length] > 0);
+ EXPECT_TRUE([[[cocoa_controller_ popupButton] title] length] > 0);
+ // Validate the menu. It should have 4 items (the dummy title item, 1 poupup,
+ // a separator, 1 host).
+ NSMenu* menu = [cocoa_controller_ buildMenu];
+ EXPECT_TRUE(menu);
+ EXPECT_EQ([menu numberOfItems], 4);
+
+ // Change the whitelisting and make sure the host is checked.
+ container_->ToggleWhitelistingForHost(0);
+ menu = [cocoa_controller_ buildMenu];
+ EXPECT_TRUE(menu);
+ EXPECT_EQ([menu numberOfItems], 2);
+ EXPECT_EQ([[menu itemAtIndex:1] state], NSOnState);
+
// Close the popup and verify it's no longer in the view hierarchy. This
// means HideView() has been called.
[cocoa_controller_ closePopup:nil];
« no previous file with comments | « chrome/browser/cocoa/blocked_popup_container_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698