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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/cocoa/cookies_window_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009-2010 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/tree_model.h" 7 #include "app/tree_model.h"
8 #import "base/scoped_nsobject.h" 8 #import "base/scoped_nsobject.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "chrome/browser/cocoa/browser_test_helper.h" 10 #include "chrome/browser/cocoa/browser_test_helper.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 forKey:kClearBrowsingDataControllerRemoveMask]; 427 forKey:kClearBrowsingDataControllerRemoveMask];
428 NSNotification* notif = 428 NSNotification* notif =
429 [NSNotification notificationWithName:kClearBrowsingDataControllerDidDelete 429 [NSNotification notificationWithName:kClearBrowsingDataControllerDidDelete
430 object:nil 430 object:nil
431 userInfo:userInfo]; 431 userInfo:userInfo];
432 [controller_ clearBrowsingDataNotification:notif]; 432 [controller_ clearBrowsingDataNotification:notif];
433 433
434 [mock verify]; 434 [mock verify];
435 } 435 }
436 436
437 TEST_F(CookiesWindowControllerTest, RemoveButtonEnabled) {
438 const GURL url = GURL("http://foo.com");
439 TestingProfile* profile = browser_helper_.profile();
440 net::CookieMonster* cm = profile->GetCookieMonster();
441 cm->SetCookie(url, "A=B");
442 cm->SetCookie(url, "C=D");
443
444 // This will clean itself up when we call |-closeSheet:|. If we reset the
445 // scoper, we'd get a double-free.
446 CookiesWindowController* controller =
447 [[CookiesWindowController alloc] initWithProfile:profile];
448 [controller attachSheetTo:test_window()];
449
450 // Nothing should be selected right now.
451 EXPECT_FALSE([controller removeButtonEnabled]);
452
453 {
454 // Pretend to select cookie A.
455 NSUInteger path[3] = {0, 0, 0};
456 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
457 [[controller treeController] setSelectionIndexPath:indexPath];
458 [controller outlineViewSelectionDidChange:nil];
459 EXPECT_TRUE([controller removeButtonEnabled]);
460 }
461
462 {
463 // Pretend to select cookie C.
464 NSUInteger path[3] = {0, 0, 1};
465 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
466 [[controller treeController] setSelectionIndexPath:indexPath];
467 [controller outlineViewSelectionDidChange:nil];
468 EXPECT_TRUE([controller removeButtonEnabled]);
469 }
470
471 {
472 // Pretend to select something that isn't there!
473 NSUInteger path[3] = {0, 0, 2};
474 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
475 [[controller treeController] setSelectionIndexPath:indexPath];
476 [controller outlineViewSelectionDidChange:nil];
477 EXPECT_FALSE([controller removeButtonEnabled]);
478 }
479
480 {
481 // Try selecting something that doesn't exist again.
482 NSUInteger path[3] = {3, 1, 4};
483 NSIndexPath* indexPath = [NSIndexPath indexPathWithIndexes:path length:3];
484 [[controller treeController] setSelectionIndexPath:indexPath];
485 [controller outlineViewSelectionDidChange:nil];
486 EXPECT_FALSE([controller removeButtonEnabled]);
487 }
488
489 [controller closeSheet:nil];
490 }
491
437 } // namespace 492 } // namespace
OLDNEW
« 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