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

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

Issue 2078021: First pass at experimental omnibox API. There are plenty of rough edges and (Closed)
Patch Set: no prefer_keyword Created 10 years, 7 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) 2009 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 #include "base/scoped_nsobject.h" 5 #include "base/scoped_nsobject.h"
6 #include "base/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/cocoa/autocomplete_text_field.h" 8 #include "chrome/browser/cocoa/autocomplete_text_field.h"
9 #include "chrome/browser/cocoa/autocomplete_text_field_cell.h" 9 #include "chrome/browser/cocoa/autocomplete_text_field_cell.h"
10 #include "chrome/browser/cocoa/browser_test_helper.h" 10 #include "chrome/browser/cocoa/browser_test_helper.h"
11 #include "chrome/browser/cocoa/location_bar_view_mac.h" 11 #include "chrome/browser/cocoa/location_bar_view_mac.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 const std::wstring kKeyword(L"Google"); 83 const std::wstring kKeyword(L"Google");
84 const NSString* kKeywordPrefix = @"Press "; 84 const NSString* kKeywordPrefix = @"Press ";
85 const NSString* kKeywordSuffix = @" to search Google"; 85 const NSString* kKeywordSuffix = @" to search Google";
86 const NSString* kKeywordString = @"Search Google:"; 86 const NSString* kKeywordString = @"Search Google:";
87 // 0x2026 is Unicode ellipses. 87 // 0x2026 is Unicode ellipses.
88 const NSString* kPartialString = 88 const NSString* kPartialString =
89 [NSString stringWithFormat:@"Search Go%C:", 0x2026]; 89 [NSString stringWithFormat:@"Search Go%C:", 0x2026];
90 90
91 // With no special hints requested, none set. 91 // With no special hints requested, none set.
92 LocationBarViewMac::OnChangedImpl(field_, std::wstring(), std::wstring(), fals e, image); 92 LocationBarViewMac::OnChangedImpl(field_, std::wstring(), std::wstring(),
93 false, false, image);
93 EXPECT_FALSE([cell keywordString]); 94 EXPECT_FALSE([cell keywordString]);
94 EXPECT_FALSE([cell hintString]); 95 EXPECT_FALSE([cell hintString]);
95 96
96 // Request a keyword hint. 97 // Request a keyword hint.
97 LocationBarViewMac::OnChangedImpl(field_, kKeyword, kKeyword, true, image); 98 LocationBarViewMac::OnChangedImpl(field_, kKeyword, kKeyword,
99 true, false, image);
98 EXPECT_FALSE([cell keywordString]); 100 EXPECT_FALSE([cell keywordString]);
99 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kKeywordPrefix]); 101 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kKeywordPrefix]);
100 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kKeywordSuffix]); 102 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kKeywordSuffix]);
101 103
102 // Request keyword-search mode. 104 // Request keyword-search mode.
103 LocationBarViewMac::OnChangedImpl( 105 LocationBarViewMac::OnChangedImpl(
104 field_, kKeyword, kKeyword, false, image); 106 field_, kKeyword, kKeyword, false, false, image);
105 EXPECT_TRUE([[[cell keywordString] string] hasSuffix:kKeywordString]); 107 EXPECT_TRUE([[[cell keywordString] string] hasSuffix:kKeywordString]);
106 EXPECT_FALSE([cell hintString]); 108 EXPECT_FALSE([cell hintString]);
107 109
108 // Check that a partial keyword-search string is passed down in case 110 // Check that a partial keyword-search string is passed down in case
109 // the view is narrow. 111 // the view is narrow.
110 // TODO(shess): Is this test a good argument for re-writing using a 112 // TODO(shess): Is this test a good argument for re-writing using a
111 // mock field? 113 // mock field?
112 NSRect frame([field_ frame]); 114 NSRect frame([field_ frame]);
113 frame.size.width = 10.0; 115 frame.size.width = 10.0;
114 [field_ setFrame:frame]; 116 [field_ setFrame:frame];
115 LocationBarViewMac::OnChangedImpl(field_, kKeyword, kKeyword, false, image); 117 LocationBarViewMac::OnChangedImpl(field_, kKeyword, kKeyword, false,
118 false, image);
116 EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kPartialString]); 119 EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kPartialString]);
117 EXPECT_FALSE([cell hintString]); 120 EXPECT_FALSE([cell hintString]);
118 121
119 // Transition back to baseline. 122 // Transition back to baseline.
120 LocationBarViewMac::OnChangedImpl( 123 LocationBarViewMac::OnChangedImpl(
121 field_, std::wstring(), std::wstring(), false, image); 124 field_, std::wstring(), std::wstring(), false, false, image);
122 EXPECT_FALSE([cell keywordString]); 125 EXPECT_FALSE([cell keywordString]);
123 EXPECT_FALSE([cell hintString]); 126 EXPECT_FALSE([cell hintString]);
124 } 127 }
125 128
126 } // namespace 129 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/location_bar_view_mac.mm ('k') | chrome/browser/extensions/extension_function_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698