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

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

Issue 2876002: Mac/clang: First pass over unit_tests (Closed)
Patch Set: '' Created 10 years, 6 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 "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #import "base/cocoa_protocols_mac.h" 8 #import "base/cocoa_protocols_mac.h"
9 #include "base/scoped_nsobject.h" 9 #include "base/scoped_nsobject.h"
10 #import "chrome/browser/cocoa/autocomplete_text_field.h" 10 #import "chrome/browser/cocoa/autocomplete_text_field.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 [field_ resetFieldEditorFrameIfNeeded]; 349 [field_ resetFieldEditorFrameIfNeeded];
350 EXPECT_TRUE(NSEqualRects(baseEditorFrame, EditorFrame())); 350 EXPECT_TRUE(NSEqualRects(baseEditorFrame, EditorFrame()));
351 } 351 }
352 352
353 // Test that the field editor gets the same bounds when focus is 353 // Test that the field editor gets the same bounds when focus is
354 // delivered by the standard focusing machinery, or by 354 // delivered by the standard focusing machinery, or by
355 // -resetFieldEditorFrameIfNeeded. 355 // -resetFieldEditorFrameIfNeeded.
356 TEST_F(AutocompleteTextFieldTest, ResetFieldEditorSearchHint) { 356 TEST_F(AutocompleteTextFieldTest, ResetFieldEditorSearchHint) {
357 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; 357 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
358 358
359 const NSString* kHintString(@"Type to search"); 359 NSString* const kHintString(@"Type to search");
Mark Mentovai 2010/06/23 13:51:28 Use = instead of ().
360 360
361 // Capture the editor frame resulting from the standard focus 361 // Capture the editor frame resulting from the standard focus
362 // machinery. 362 // machinery.
363 [cell setSearchHintString:kHintString availableWidth:kWidth]; 363 [cell setSearchHintString:kHintString availableWidth:kWidth];
364 EXPECT_TRUE([cell hintString]); 364 EXPECT_TRUE([cell hintString]);
365 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; 365 [test_window() makePretendKeyWindowAndSetFirstResponder:field_];
366 const NSRect baseEditorFrame(EditorFrame()); 366 const NSRect baseEditorFrame(EditorFrame());
367 367
368 // Clearing the hint should result in a strictly larger editor 368 // Clearing the hint should result in a strictly larger editor
369 // frame. 369 // frame.
(...skipping 11 matching lines...) Expand all
381 [field_ resetFieldEditorFrameIfNeeded]; 381 [field_ resetFieldEditorFrameIfNeeded];
382 EXPECT_TRUE(NSEqualRects(baseEditorFrame, EditorFrame())); 382 EXPECT_TRUE(NSEqualRects(baseEditorFrame, EditorFrame()));
383 } 383 }
384 384
385 // Test that the field editor gets the same bounds when focus is 385 // Test that the field editor gets the same bounds when focus is
386 // delivered by the standard focusing machinery, or by 386 // delivered by the standard focusing machinery, or by
387 // -resetFieldEditorFrameIfNeeded. 387 // -resetFieldEditorFrameIfNeeded.
388 TEST_F(AutocompleteTextFieldTest, ResetFieldEditorKeywordHint) { 388 TEST_F(AutocompleteTextFieldTest, ResetFieldEditorKeywordHint) {
389 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; 389 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
390 390
391 const NSString* kFullString(@"Search Engine:"); 391 NSString* const kFullString(@"Search Engine:");
Mark Mentovai 2010/06/23 13:51:28 Ditto here and on the next line.
392 const NSString* kPartialString(@"Search Eng:"); 392 NSString* const kPartialString(@"Search Eng:");
393 393
394 // Capture the editor frame resulting from the standard focus 394 // Capture the editor frame resulting from the standard focus
395 // machinery. 395 // machinery.
396 [cell setKeywordString:kFullString 396 [cell setKeywordString:kFullString
397 partialString:kPartialString 397 partialString:kPartialString
398 availableWidth:kWidth]; 398 availableWidth:kWidth];
399 EXPECT_TRUE([cell keywordString]); 399 EXPECT_TRUE([cell keywordString]);
400 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; 400 [test_window() makePretendKeyWindowAndSetFirstResponder:field_];
401 const NSRect baseEditorFrame(EditorFrame()); 401 const NSRect baseEditorFrame(EditorFrame());
402 402
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 // So that we can set rich text. 742 // So that we can set rich text.
743 [field_ setAllowsEditingTextAttributes:YES]; 743 [field_ setAllowsEditingTextAttributes:YES];
744 744
745 // Set an attribute different from the field's default so we can 745 // Set an attribute different from the field's default so we can
746 // tell we got the same string out as we put in. 746 // tell we got the same string out as we put in.
747 NSFont* font = [NSFont fontWithDescriptor:[[field_ font] fontDescriptor] 747 NSFont* font = [NSFont fontWithDescriptor:[[field_ font] fontDescriptor]
748 size:[[field_ font] pointSize] + 2]; 748 size:[[field_ font] pointSize] + 2];
749 NSDictionary* attributes = 749 NSDictionary* attributes =
750 [NSDictionary dictionaryWithObject:font 750 [NSDictionary dictionaryWithObject:font
751 forKey:NSFontAttributeName]; 751 forKey:NSFontAttributeName];
752 static const NSString* kString = @"This is a test"; 752 NSString* const kString = @"This is a test";
753 scoped_nsobject<NSAttributedString> attributedString( 753 scoped_nsobject<NSAttributedString> attributedString(
754 [[NSAttributedString alloc] initWithString:kString 754 [[NSAttributedString alloc] initWithString:kString
755 attributes:attributes]); 755 attributes:attributes]);
756 756
757 // Check that what we get back looks like what we put in. 757 // Check that what we get back looks like what we put in.
758 EXPECT_FALSE([[field_ stringValue] isEqualToString:kString]); 758 EXPECT_FALSE([[field_ stringValue] isEqualToString:kString]);
759 [field_ setAttributedStringValue:attributedString]; 759 [field_ setAttributedStringValue:attributedString];
760 EXPECT_TRUE([[field_ attributedStringValue] 760 EXPECT_TRUE([[field_ attributedStringValue]
761 isEqualToAttributedString:attributedString]); 761 isEqualToAttributedString:attributedString]);
762 EXPECT_TRUE([[field_ stringValue] isEqualToString:kString]); 762 EXPECT_TRUE([[field_ stringValue] isEqualToString:kString]);
(...skipping 12 matching lines...) Expand all
775 EXPECT_TRUE([[field_ stringValue] isEqualToString:kString]); 775 EXPECT_TRUE([[field_ stringValue] isEqualToString:kString]);
776 } 776 }
777 777
778 // -setAttributedStringValue: shouldn't reset the undo state if things 778 // -setAttributedStringValue: shouldn't reset the undo state if things
779 // are being editted. 779 // are being editted.
780 TEST_F(AutocompleteTextFieldTest, SetAttributedStringUndo) { 780 TEST_F(AutocompleteTextFieldTest, SetAttributedStringUndo) {
781 NSColor* redColor = [NSColor redColor]; 781 NSColor* redColor = [NSColor redColor];
782 NSDictionary* attributes = 782 NSDictionary* attributes =
783 [NSDictionary dictionaryWithObject:redColor 783 [NSDictionary dictionaryWithObject:redColor
784 forKey:NSForegroundColorAttributeName]; 784 forKey:NSForegroundColorAttributeName];
785 static const NSString* kString = @"This is a test"; 785 NSString* const kString = @"This is a test";
786 scoped_nsobject<NSAttributedString> attributedString( 786 scoped_nsobject<NSAttributedString> attributedString(
787 [[NSAttributedString alloc] initWithString:kString 787 [[NSAttributedString alloc] initWithString:kString
788 attributes:attributes]); 788 attributes:attributes]);
789 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; 789 [test_window() makePretendKeyWindowAndSetFirstResponder:field_];
790 EXPECT_TRUE([field_ currentEditor]); 790 EXPECT_TRUE([field_ currentEditor]);
791 NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); 791 NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]);
792 NSUndoManager* undoManager = [editor undoManager]; 792 NSUndoManager* undoManager = [editor undoManager];
793 EXPECT_TRUE(undoManager); 793 EXPECT_TRUE(undoManager);
794 794
795 // Nothing to undo, yet. 795 // Nothing to undo, yet.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 887
888 // Not draggable, so no pasteboard. 888 // Not draggable, so no pasteboard.
889 EXPECT_FALSE([field_ locationDragPasteboard]); 889 EXPECT_FALSE([field_ locationDragPasteboard]);
890 890
891 // Gets a pasteboard when draggable. 891 // Gets a pasteboard when draggable.
892 location_icon_view.SetDraggable(true); 892 location_icon_view.SetDraggable(true);
893 EXPECT_TRUE([field_ locationDragPasteboard]); 893 EXPECT_TRUE([field_ locationDragPasteboard]);
894 } 894 }
895 895
896 } // namespace 896 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm ('k') | chrome/browser/cocoa/bookmark_bar_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698