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

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

Issue 1598001: [Mac] Select the previous node when the last cookie in the list is deleted. (Closed)
Patch Set: Address comments. Created 10 years, 9 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 c1565b40e94d36dc9257a3f567b65470fe069cda..dcc0129285b371ff2860b424c2b01bf5ab874abe 100644
--- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
@@ -361,6 +361,7 @@ TEST_F(CookiesWindowControllerTest, DeleteCookie) {
net::CookieMonster* cm = profile->GetCookieMonster();
cm->SetCookie(url, "A=B");
cm->SetCookie(url, "C=D");
+ cm->SetCookie(GURL("http://google.com"), "E=F");
// This will clean itself up when we call |-closeSheet:|. If we reset the
// scoper, we'd get a double-free.
@@ -372,9 +373,9 @@ TEST_F(CookiesWindowControllerTest, DeleteCookie) {
[controller attachSheetTo:test_window()];
NSTreeController* treeController = [controller treeController];
- // Pretend to select cookie A.
- NSUInteger path[3] = {0, 0, 0};
- NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
+ // Select cookie A.
+ NSUInteger pathA[3] = {0, 0, 0};
+ NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:pathA length:3];
[treeController setSelectionIndexPath:indexPath];
// Press the "Delete" button.
@@ -387,6 +388,29 @@ TEST_F(CookiesWindowControllerTest, DeleteCookie) {
EXPECT_TRUE([@"C" isEqualToString:[[cookies lastObject] title]]);
EXPECT_TRUE([indexPath isEqual:[treeController selectionIndexPath]]);
+ // Select cookie E.
+ NSUInteger pathE[3] = {1, 0, 0};
+ indexPath = [NSIndexPath indexPathWithIndexes:pathE length:3];
+ [treeController setSelectionIndexPath:indexPath];
+
+ // Perform delete.
+ [controller deleteCookie:nil];
+
+ // Make sure that both the domain level node and the Cookies folder node got
+ // deleted because there was only one leaf node.
+ EXPECT_EQ(1U, [[[controller cocoaTreeModel] children] count]);
+
+ // Select cookie C.
+ NSUInteger pathC[3] = {0, 0, 0};
+ indexPath = [NSIndexPath indexPathWithIndexes:pathC length:3];
+ [treeController setSelectionIndexPath:indexPath];
+
+ // Perform delete.
+ [controller deleteCookie:nil];
+
+ // Make sure the world didn't explode and that there's nothing in the tree.
+ EXPECT_EQ(0U, [[[controller cocoaTreeModel] children] count]);
+
[controller closeSheet:nil];
}
« 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