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

Side by Side Diff: chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm

Issue 3095004: [Mac] Use the new {EXPECT,ASSERT}_NS{EQ,NE} macros where possible. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix compile Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/scoped_nsobject.h" 8 #include "base/scoped_nsobject.h"
9 #import "chrome/browser/cocoa/bookmark_bar_constants.h" // namespace bookmarks 9 #import "chrome/browser/cocoa/bookmark_bar_constants.h" // namespace bookmarks
10 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 10 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
11 #import "chrome/browser/cocoa/bookmark_bar_folder_button_cell.h" 11 #import "chrome/browser/cocoa/bookmark_bar_folder_button_cell.h"
12 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h" 12 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h"
13 #import "chrome/browser/cocoa/bookmark_bar_unittest_helper.h" 13 #import "chrome/browser/cocoa/bookmark_bar_unittest_helper.h"
14 #include "chrome/browser/cocoa/browser_test_helper.h" 14 #include "chrome/browser/cocoa/browser_test_helper.h"
15 #import "chrome/browser/cocoa/cocoa_test_helper.h" 15 #import "chrome/browser/cocoa/cocoa_test_helper.h"
16 #import "chrome/browser/cocoa/view_resizer_pong.h" 16 #import "chrome/browser/cocoa/view_resizer_pong.h"
17 #include "chrome/test/model_test_utils.h" 17 #include "chrome/test/model_test_utils.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #import "testing/gtest_mac.h"
19 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
20 21
21 // Add a redirect to make testing easier. 22 // Add a redirect to make testing easier.
22 @interface BookmarkBarFolderController(MakeTestingEasier) 23 @interface BookmarkBarFolderController(MakeTestingEasier)
23 - (IBAction)openBookmarkFolderFromButton:(id)sender; 24 - (IBAction)openBookmarkFolderFromButton:(id)sender;
24 @end 25 @end
25 26
26 @implementation BookmarkBarFolderController(MakeTestingEasier) 27 @implementation BookmarkBarFolderController(MakeTestingEasier)
27 - (IBAction)openBookmarkFolderFromButton:(id)sender { 28 - (IBAction)openBookmarkFolderFromButton:(id)sender {
28 [[self folderTarget] openBookmarkFolderFromButton:sender]; 29 [[self folderTarget] openBookmarkFolderFromButton:sender];
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 withObject:toFolder]; 1029 withObject:toFolder];
1029 BookmarkBarFolderController* folder = [bar_ folderController]; 1030 BookmarkBarFolderController* folder = [bar_ folderController];
1030 EXPECT_TRUE(folder); 1031 EXPECT_TRUE(folder);
1031 1032
1032 // Remember how many buttons are showing. 1033 // Remember how many buttons are showing.
1033 NSArray* buttons = [folder buttons]; 1034 NSArray* buttons = [folder buttons];
1034 NSUInteger oldDisplayedButtons = [buttons count]; 1035 NSUInteger oldDisplayedButtons = [buttons count];
1035 1036
1036 // Move a button around a bit. 1037 // Move a button around a bit.
1037 [folder moveButtonFromIndex:0 toIndex:2]; 1038 [folder moveButtonFromIndex:0 toIndex:2];
1038 EXPECT_TRUE([[[buttons objectAtIndex:0] title] isEqualToString:@"2f2b"]); 1039 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:0] title]);
1039 EXPECT_TRUE([[[buttons objectAtIndex:1] title] isEqualToString:@"2f3b"]); 1040 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:1] title]);
1040 EXPECT_TRUE([[[buttons objectAtIndex:2] title] isEqualToString:@"2f1b"]); 1041 EXPECT_NSEQ(@"2f1b", [[buttons objectAtIndex:2] title]);
1041 EXPECT_EQ(oldDisplayedButtons, [buttons count]); 1042 EXPECT_EQ(oldDisplayedButtons, [buttons count]);
1042 [folder moveButtonFromIndex:2 toIndex:0]; 1043 [folder moveButtonFromIndex:2 toIndex:0];
1043 EXPECT_TRUE([[[buttons objectAtIndex:0] title] isEqualToString:@"2f1b"]); 1044 EXPECT_NSEQ(@"2f1b", [[buttons objectAtIndex:0] title]);
1044 EXPECT_TRUE([[[buttons objectAtIndex:1] title] isEqualToString:@"2f2b"]); 1045 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:1] title]);
1045 EXPECT_TRUE([[[buttons objectAtIndex:2] title] isEqualToString:@"2f3b"]); 1046 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:2] title]);
1046 EXPECT_EQ(oldDisplayedButtons, [buttons count]); 1047 EXPECT_EQ(oldDisplayedButtons, [buttons count]);
1047 1048
1048 // Add a couple of buttons. 1049 // Add a couple of buttons.
1049 const BookmarkNode* node = root->GetChild(2); // Purloin an existing node. 1050 const BookmarkNode* node = root->GetChild(2); // Purloin an existing node.
1050 [folder addButtonForNode:node atIndex:0]; 1051 [folder addButtonForNode:node atIndex:0];
1051 EXPECT_TRUE([[[buttons objectAtIndex:0] title] isEqualToString:@"3b"]); 1052 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:0] title]);
1052 EXPECT_TRUE([[[buttons objectAtIndex:1] title] isEqualToString:@"2f1b"]); 1053 EXPECT_NSEQ(@"2f1b", [[buttons objectAtIndex:1] title]);
1053 EXPECT_TRUE([[[buttons objectAtIndex:2] title] isEqualToString:@"2f2b"]); 1054 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:2] title]);
1054 EXPECT_TRUE([[[buttons objectAtIndex:3] title] isEqualToString:@"2f3b"]); 1055 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:3] title]);
1055 EXPECT_EQ(oldDisplayedButtons + 1, [buttons count]); 1056 EXPECT_EQ(oldDisplayedButtons + 1, [buttons count]);
1056 node = root->GetChild(3); 1057 node = root->GetChild(3);
1057 [folder addButtonForNode:node atIndex:-1]; 1058 [folder addButtonForNode:node atIndex:-1];
1058 EXPECT_TRUE([[[buttons objectAtIndex:0] title] isEqualToString:@"3b"]); 1059 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:0] title]);
1059 EXPECT_TRUE([[[buttons objectAtIndex:1] title] isEqualToString:@"2f1b"]); 1060 EXPECT_NSEQ(@"2f1b", [[buttons objectAtIndex:1] title]);
1060 EXPECT_TRUE([[[buttons objectAtIndex:2] title] isEqualToString:@"2f2b"]); 1061 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:2] title]);
1061 EXPECT_TRUE([[[buttons objectAtIndex:3] title] isEqualToString:@"2f3b"]); 1062 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:3] title]);
1062 EXPECT_TRUE([[[buttons objectAtIndex:4] title] isEqualToString:@"4b"]); 1063 EXPECT_NSEQ(@"4b", [[buttons objectAtIndex:4] title]);
1063 EXPECT_EQ(oldDisplayedButtons + 2, [buttons count]); 1064 EXPECT_EQ(oldDisplayedButtons + 2, [buttons count]);
1064 1065
1065 // Remove a couple of buttons. 1066 // Remove a couple of buttons.
1066 [folder removeButton:4 animate:NO]; 1067 [folder removeButton:4 animate:NO];
1067 [folder removeButton:1 animate:NO]; 1068 [folder removeButton:1 animate:NO];
1068 EXPECT_TRUE([[[buttons objectAtIndex:0] title] isEqualToString:@"3b"]); 1069 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:0] title]);
1069 EXPECT_TRUE([[[buttons objectAtIndex:1] title] isEqualToString:@"2f2b"]); 1070 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:1] title]);
1070 EXPECT_TRUE([[[buttons objectAtIndex:2] title] isEqualToString:@"2f3b"]); 1071 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:2] title]);
1071 EXPECT_EQ(oldDisplayedButtons, [buttons count]); 1072 EXPECT_EQ(oldDisplayedButtons, [buttons count]);
1072 } 1073 }
1073 1074
1074 TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) { 1075 TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) {
1075 BookmarkModel& model(*helper_.profile()->GetBookmarkModel()); 1076 BookmarkModel& model(*helper_.profile()->GetBookmarkModel());
1076 const BookmarkNode* root = model.GetBookmarkBarNode(); 1077 const BookmarkNode* root = model.GetBookmarkBarNode();
1077 const std::wstring model_string(L"1b 2f:[ 2f1b 2f2b ] 3b "); 1078 const std::wstring model_string(L"1b 2f:[ 2f1b 2f2b ] 3b ");
1078 model_test_utils::AddNodesFromModelString(model, root, model_string); 1079 model_test_utils::AddNodesFromModelString(model, root, model_string);
1079 1080
1080 // Validate initial model. 1081 // Validate initial model.
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 [folder deleteBookmark:folder]; 1446 [folder deleteBookmark:folder];
1446 EXPECT_FALSE([folder folderController]); 1447 EXPECT_FALSE([folder folderController]);
1447 } 1448 }
1448 1449
1449 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so 1450 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so
1450 // they are hard to test. Factor out "fire timers" into routines 1451 // they are hard to test. Factor out "fire timers" into routines
1451 // which can be overridden to fire immediately to make behavior 1452 // which can be overridden to fire immediately to make behavior
1452 // confirmable. 1453 // confirmable.
1453 // There is a similar problem with mouseEnteredButton: and 1454 // There is a similar problem with mouseEnteredButton: and
1454 // mouseExitedButton:. 1455 // mouseExitedButton:.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698