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

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, 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
« 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/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete.h" 10 #include "chrome/browser/autocomplete/autocomplete.h"
11 #include "chrome/common/notification_observer.h" 11 #include "chrome/common/notification_observer.h"
12 #include "chrome/common/notification_registrar.h" 12 #include "chrome/common/notification_registrar.h"
13 #include "chrome/common/notification_service.h" 13 #include "chrome/common/notification_service.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 // identifiers for known autocomplete providers 16 // identifiers for known autocomplete providers
17 #define HISTORY_IDENTIFIER L"Chrome:History" 17 #define HISTORY_IDENTIFIER L"Chrome:History"
18 #define SEARCH_IDENTIFIER L"google.com/websearch/en" 18 #define SEARCH_IDENTIFIER L"google.com/websearch/en"
19 19
20 std::ostream& operator<<(std::ostream& os,
21 const AutocompleteResult::const_iterator& iter) {
22 return os << static_cast<const AutocompleteMatch*>(&(*iter));
23 }
24
25
20 namespace { 26 namespace {
21 27
22 const size_t num_results_per_provider = 3; 28 const size_t num_results_per_provider = 3;
23 29
24 // Autocomplete provider that provides known results. Note that this is 30 // Autocomplete provider that provides known results. Note that this is
25 // refcounted so that it can also be a task on the message loop. 31 // refcounted so that it can also be a task on the message loop.
26 class TestProvider : public AutocompleteProvider { 32 class TestProvider : public AutocompleteProvider {
27 public: 33 public:
28 TestProvider(int relevance, const std::wstring& prefix) 34 TestProvider(int relevance, const std::wstring& prefix)
29 : AutocompleteProvider(NULL, NULL, ""), 35 : AutocompleteProvider(NULL, NULL, ""),
(...skipping 131 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << 377 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " <<
377 input_cases[i].input; 378 input_cases[i].input;
378 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << 379 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " <<
379 input_cases[i].input; 380 input_cases[i].input;
380 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << 381 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " <<
381 input_cases[i].input; 382 input_cases[i].input;
382 } 383 }
383 } 384 }
384 385
385 } // namespace 386 } // 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