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

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

Issue 427009: Preliminary work toward page actions on Mac. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/scoped_nsobject.h" 7 #include "base/scoped_nsobject.h"
8 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" 8 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
9 #import "chrome/browser/cocoa/cocoa_test_helper.h" 9 #import "chrome/browser/cocoa/cocoa_test_helper.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 12
13 namespace { 13 namespace {
14 14
15 // Width of the field so that we don't have to ask |field_| for it all 15 // Width of the field so that we don't have to ask |field_| for it all
16 // the time. 16 // the time.
17 const CGFloat kWidth(300.0); 17 const CGFloat kWidth(300.0);
18 18
19 // A narrow width for tests which test things that don't fit. 19 // A narrow width for tests which test things that don't fit.
20 const CGFloat kNarrowWidth(5.0); 20 const CGFloat kNarrowWidth(5.0);
21 21
22 class AutocompleteTextFieldCellTest : public CocoaTest { 22 class AutocompleteTextFieldCellTest : public CocoaTest {
23 public: 23 public:
24 AutocompleteTextFieldCellTest() : security_image_view_(NULL, NULL) { 24 AutocompleteTextFieldCellTest() : security_image_view_(NULL, NULL),
25 page_action_views_(NULL, NULL, NULL) {
25 // Make sure this is wide enough to play games with the cell 26 // Make sure this is wide enough to play games with the cell
26 // decorations. 27 // decorations.
27 const NSRect frame = NSMakeRect(0, 0, kWidth, 30); 28 const NSRect frame = NSMakeRect(0, 0, kWidth, 30);
28 29
29 scoped_nsobject<NSTextField> view( 30 scoped_nsobject<NSTextField> view(
30 [[NSTextField alloc] initWithFrame:frame]); 31 [[NSTextField alloc] initWithFrame:frame]);
31 view_ = view.get(); 32 view_ = view.get();
32 33
33 scoped_nsobject<AutocompleteTextFieldCell> cell( 34 scoped_nsobject<AutocompleteTextFieldCell> cell(
34 [[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]); 35 [[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]);
35 [cell setEditable:YES]; 36 [cell setEditable:YES];
36 [cell setBordered:YES]; 37 [cell setBordered:YES];
37 [cell setSecurityImageView:&security_image_view_]; 38 [cell setSecurityImageView:&security_image_view_];
39 [cell setPageActionViewList:&page_action_views_];
38 [view_ setCell:cell.get()]; 40 [view_ setCell:cell.get()];
39 41
40 [[test_window() contentView] addSubview:view_]; 42 [[test_window() contentView] addSubview:view_];
41 } 43 }
42 44
43 NSTextField* view_; 45 NSTextField* view_;
44 LocationBarViewMac::SecurityImageView security_image_view_; 46 LocationBarViewMac::SecurityImageView security_image_view_;
47 LocationBarViewMac::PageActionViewList page_action_views_;
45 }; 48 };
46 49
47 // Basic view tests (AddRemove, Display). 50 // Basic view tests (AddRemove, Display).
48 TEST_VIEW(AutocompleteTextFieldCellTest, view_); 51 TEST_VIEW(AutocompleteTextFieldCellTest, view_);
49 52
50 // Test drawing, mostly to ensure nothing leaks or crashes. 53 // Test drawing, mostly to ensure nothing leaks or crashes.
51 TEST_F(AutocompleteTextFieldCellTest, FocusedDisplay) { 54 TEST_F(AutocompleteTextFieldCellTest, FocusedDisplay) {
52 [view_ display]; 55 [view_ display];
53 56
54 // Test focused drawing. 57 // Test focused drawing.
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]); 373 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]);
371 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]); 374 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]);
372 375
373 // Narrow width suppresses everything but the image. 376 // Narrow width suppresses everything but the image.
374 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix 377 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix
375 availableWidth:kNarrowWidth]; 378 availableWidth:kNarrowWidth];
376 EXPECT_EQ([[cell hintString] length], 1U); 379 EXPECT_EQ([[cell hintString] length], 1U);
377 } 380 }
378 381
379 } // namespace 382 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_cell.mm ('k') | chrome/browser/cocoa/autocomplete_text_field_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698