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

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

Issue 546102: [Mac] Fix a crash in the cookies manager that was caused by an invalid selection. (Closed)
Patch Set: do'h Created 10 years, 11 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/cookies_window_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/cookies_window_controller_unittest.mm
diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
index 6d41b5821f5191f7c723f601e60c5a020570523f..e6fc92967123c5759aac5f532a9e69aac92146c0 100644
--- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
@@ -434,4 +434,59 @@ TEST_F(CookiesWindowControllerTest, ClearBrowsingData) {
[mock verify];
}
+TEST_F(CookiesWindowControllerTest, RemoveButtonEnabled) {
+ const GURL url = GURL("http://foo.com");
+ TestingProfile* profile = browser_helper_.profile();
+ net::CookieMonster* cm = profile->GetCookieMonster();
+ cm->SetCookie(url, "A=B");
+ cm->SetCookie(url, "C=D");
+
+ // This will clean itself up when we call |-closeSheet:|. If we reset the
+ // scoper, we'd get a double-free.
+ CookiesWindowController* controller =
+ [[CookiesWindowController alloc] initWithProfile:profile];
+ [controller attachSheetTo:test_window()];
+
+ // Nothing should be selected right now.
+ EXPECT_FALSE([controller removeButtonEnabled]);
+
+ {
+ // Pretend to select cookie A.
+ NSUInteger path[3] = {0, 0, 0};
+ NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
+ [[controller treeController] setSelectionIndexPath:indexPath];
+ [controller outlineViewSelectionDidChange:nil];
+ EXPECT_TRUE([controller removeButtonEnabled]);
+ }
+
+ {
+ // Pretend to select cookie C.
+ NSUInteger path[3] = {0, 0, 1};
+ NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
+ [[controller treeController] setSelectionIndexPath:indexPath];
+ [controller outlineViewSelectionDidChange:nil];
+ EXPECT_TRUE([controller removeButtonEnabled]);
+ }
+
+ {
+ // Pretend to select something that isn't there!
+ NSUInteger path[3] = {0, 0, 2};
+ NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
+ [[controller treeController] setSelectionIndexPath:indexPath];
+ [controller outlineViewSelectionDidChange:nil];
+ EXPECT_FALSE([controller removeButtonEnabled]);
+ }
+
+ {
+ // Try selecting something that doesn't exist again.
+ NSUInteger path[3] = {3, 1, 4};
+ NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
+ [[controller treeController] setSelectionIndexPath:indexPath];
+ [controller outlineViewSelectionDidChange:nil];
+ EXPECT_FALSE([controller removeButtonEnabled]);
+ }
+
+ [controller closeSheet:nil];
+}
+
} // namespace
« no previous file with comments | « chrome/browser/cocoa/cookies_window_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698