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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_unittest.cc

Issue 2857015: Clang/mac: Get unit_tests built. (Closed)
Patch Set: rebase 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
« no previous file with comments | « build/common.gypi ('k') | chrome/browser/autofill/form_structure_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete.h" 8 #include "chrome/browser/autocomplete/autocomplete.h"
9 #include "chrome/common/notification_registrar.h" 9 #include "chrome/common/notification_registrar.h"
10 #include "chrome/common/notification_service.h" 10 #include "chrome/common/notification_service.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 // identifiers for known autocomplete providers 13 // identifiers for known autocomplete providers
14 #define HISTORY_IDENTIFIER L"Chrome:History" 14 #define HISTORY_IDENTIFIER L"Chrome:History"
15 #define SEARCH_IDENTIFIER L"google.com/websearch/en" 15 #define SEARCH_IDENTIFIER L"google.com/websearch/en"
16 16
17 std::ostream& operator<<(std::ostream& os,
18 const AutocompleteResult::const_iterator& iter) {
19 return os << static_cast<const AutocompleteMatch*>(&(*iter));
20 }
21
22
17 namespace { 23 namespace {
18 24
19 const size_t num_results_per_provider = 3; 25 const size_t num_results_per_provider = 3;
20 26
21 // Autocomplete provider that provides known results. Note that this is 27 // Autocomplete provider that provides known results. Note that this is
22 // refcounted so that it can also be a task on the message loop. 28 // refcounted so that it can also be a task on the message loop.
23 class TestProvider : public AutocompleteProvider { 29 class TestProvider : public AutocompleteProvider {
24 public: 30 public:
25 TestProvider(int relevance, const std::wstring& prefix) 31 TestProvider(int relevance, const std::wstring& prefix)
26 : AutocompleteProvider(NULL, NULL, ""), 32 : AutocompleteProvider(NULL, NULL, ""),
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 167
162 void AutocompleteProviderTest::Observe(NotificationType type, 168 void AutocompleteProviderTest::Observe(NotificationType type,
163 const NotificationSource& source, 169 const NotificationSource& source,
164 const NotificationDetails& details) { 170 const NotificationDetails& details) {
165 if (controller_->done()) { 171 if (controller_->done()) {
166 result_.CopyFrom(*(Details<const AutocompleteResult>(details).ptr())); 172 result_.CopyFrom(*(Details<const AutocompleteResult>(details).ptr()));
167 MessageLoop::current()->Quit(); 173 MessageLoop::current()->Quit();
168 } 174 }
169 } 175 }
170 176
171 std::ostream& operator<<(std::ostream& os,
172 const AutocompleteResult::const_iterator& iter) {
173 return os << static_cast<const AutocompleteMatch*>(&(*iter));
174 }
175
176 // Tests that the default selection is set properly when updating results. 177 // Tests that the default selection is set properly when updating results.
177 TEST_F(AutocompleteProviderTest, Query) { 178 TEST_F(AutocompleteProviderTest, Query) {
178 RunTest(); 179 RunTest();
179 180
180 // Make sure the default match gets set to the highest relevance match. The 181 // Make sure the default match gets set to the highest relevance match. The
181 // highest relevance matches should come from the second provider. 182 // highest relevance matches should come from the second provider.
182 EXPECT_EQ(num_results_per_provider * 2, result_.size()); // two providers 183 EXPECT_EQ(num_results_per_provider * 2, result_.size()); // two providers
183 ASSERT_NE(result_.end(), result_.default_match()); 184 ASSERT_NE(result_.end(), result_.default_match());
184 EXPECT_EQ(providers_[1], result_.default_match()->provider); 185 EXPECT_EQ(providers_[1], result_.default_match()->provider);
185 } 186 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << 370 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " <<
370 input_cases[i].input; 371 input_cases[i].input;
371 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << 372 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " <<
372 input_cases[i].input; 373 input_cases[i].input;
373 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << 374 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " <<
374 input_cases[i].input; 375 input_cases[i].input;
375 } 376 }
376 } 377 }
377 378
378 } // namespace 379 } // namespace
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | chrome/browser/autofill/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698