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

Side by Side Diff: chrome/browser/cocoa/location_bar/autocomplete_text_field_editor_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 "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h" 5 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h"
6 6
7 #include "base/scoped_nsobject.h" 7 #include "base/scoped_nsobject.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/app/chrome_dll_resource.h" // IDC_* 10 #include "chrome/app/chrome_dll_resource.h" // IDC_*
11 #import "chrome/browser/cocoa/cocoa_test_helper.h" 11 #import "chrome/browser/cocoa/cocoa_test_helper.h"
12 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_unittest_help er.h" 12 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_unittest_help er.h"
13 #import "chrome/browser/cocoa/test_event_utils.h" 13 #import "chrome/browser/cocoa/test_event_utils.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "testing/gmock/include/gmock/gmock-matchers.h" 15 #include "testing/gmock/include/gmock/gmock-matchers.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #import "testing/gtest_mac.h"
17 #include "testing/platform_test.h" 18 #include "testing/platform_test.h"
18 #import "third_party/ocmock/OCMock/OCMock.h" 19 #import "third_party/ocmock/OCMock/OCMock.h"
19 20
20 using ::testing::Return; 21 using ::testing::Return;
21 using ::testing::StrictMock; 22 using ::testing::StrictMock;
22 using ::testing::A; 23 using ::testing::A;
23 24
24 namespace { 25 namespace {
25 26
26 int NumTypesOnPasteboard(NSPasteboard* pb) { 27 int NumTypesOnPasteboard(NSPasteboard* pb) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 TEST_VIEW(AutocompleteTextFieldEditorTest, field_); 67 TEST_VIEW(AutocompleteTextFieldEditorTest, field_);
67 68
68 // Test that control characters are stripped from insertions. 69 // Test that control characters are stripped from insertions.
69 TEST_F(AutocompleteTextFieldEditorTest, InsertStripsControlChars) { 70 TEST_F(AutocompleteTextFieldEditorTest, InsertStripsControlChars) {
70 // Sets a string in the field. 71 // Sets a string in the field.
71 NSString* test_string = @"astring"; 72 NSString* test_string = @"astring";
72 [field_ setStringValue:test_string]; 73 [field_ setStringValue:test_string];
73 [editor_ selectAll:nil]; 74 [editor_ selectAll:nil];
74 75
75 [editor_ insertText:@"t"]; 76 [editor_ insertText:@"t"];
76 EXPECT_TRUE([[field_ stringValue] isEqualToString:@"t"]); 77 EXPECT_NSEQ(@"t", [field_ stringValue]);
77 78
78 [editor_ insertText:@"h"]; 79 [editor_ insertText:@"h"];
79 EXPECT_TRUE([[field_ stringValue] isEqualToString:@"th"]); 80 EXPECT_NSEQ(@"th", [field_ stringValue]);
80 81
81 // TAB doesn't get inserted. 82 // TAB doesn't get inserted.
82 [editor_ insertText:[NSString stringWithFormat:@"%c", 7]]; 83 [editor_ insertText:[NSString stringWithFormat:@"%c", 7]];
83 EXPECT_TRUE([[field_ stringValue] isEqualToString:@"th"]); 84 EXPECT_NSEQ(@"th", [field_ stringValue]);
84 85
85 // Newline doesn't get inserted. 86 // Newline doesn't get inserted.
86 [editor_ insertText:[NSString stringWithFormat:@"%c", 12]]; 87 [editor_ insertText:[NSString stringWithFormat:@"%c", 12]];
87 EXPECT_TRUE([[field_ stringValue] isEqualToString:@"th"]); 88 EXPECT_NSEQ(@"th", [field_ stringValue]);
88 89
89 // Multi-character strings get through. 90 // Multi-character strings get through.
90 [editor_ insertText:[NSString stringWithFormat:@"i%cs%c", 8, 127]]; 91 [editor_ insertText:[NSString stringWithFormat:@"i%cs%c", 8, 127]];
91 EXPECT_TRUE([[field_ stringValue] isEqualToString:@"this"]); 92 EXPECT_NSEQ(@"this", [field_ stringValue]);
92 93
93 // Attempting to insert newline when everything is selected clears 94 // Attempting to insert newline when everything is selected clears
94 // the field. 95 // the field.
95 [editor_ selectAll:nil]; 96 [editor_ selectAll:nil];
96 [editor_ insertText:[NSString stringWithFormat:@"%c", 12]]; 97 [editor_ insertText:[NSString stringWithFormat:@"%c", 12]];
97 EXPECT_TRUE([[field_ stringValue] isEqualToString:@""]); 98 EXPECT_NSEQ(@"", [field_ stringValue]);
98 } 99 }
99 100
100 // Test that |delegate| can provide page action menus. 101 // Test that |delegate| can provide page action menus.
101 TEST_F(AutocompleteTextFieldEditorTest, PageActionMenus) { 102 TEST_F(AutocompleteTextFieldEditorTest, PageActionMenus) {
102 // The event just needs to be something the mock can recognize. 103 // The event just needs to be something the mock can recognize.
103 NSEvent* event = 104 NSEvent* event =
104 test_event_utils::MouseEventAtPoint(NSZeroPoint, NSRightMouseDown, 0); 105 test_event_utils::MouseEventAtPoint(NSZeroPoint, NSRightMouseDown, 0);
105 106
106 // Trivial menu which we can recognize and which doesn't look like 107 // Trivial menu which we can recognize and which doesn't look like
107 // the default editor context menu. 108 // the default editor context menu.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 NSArray* items = [menu itemArray]; 288 NSArray* items = [menu itemArray];
288 ASSERT_EQ([items count], 3U); 289 ASSERT_EQ([items count], 3U);
289 // TODO(shess): Check the titles, too? 290 // TODO(shess): Check the titles, too?
290 NSUInteger i = 0; // Use an index to make future changes easier. 291 NSUInteger i = 0; // Use an index to make future changes easier.
291 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(cut:)); 292 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(cut:));
292 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:)); 293 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:));
293 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:)); 294 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:));
294 } 295 }
295 296
296 } // namespace 297 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698