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

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

Issue 10909130: autocomplete: Add AutocompleteProvider::Type enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more indentation changes Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/autocomplete_provider.h" 5 #include "chrome/browser/autocomplete/autocomplete_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 27 matching lines...) Expand all
38 const char kTestTemplateURLKeyword[] = "t"; 38 const char kTestTemplateURLKeyword[] = "t";
39 } 39 }
40 40
41 // Autocomplete provider that provides known results. Note that this is 41 // Autocomplete provider that provides known results. Note that this is
42 // refcounted so that it can also be a task on the message loop. 42 // refcounted so that it can also be a task on the message loop.
43 class TestProvider : public AutocompleteProvider { 43 class TestProvider : public AutocompleteProvider {
44 public: 44 public:
45 TestProvider(int relevance, const string16& prefix, 45 TestProvider(int relevance, const string16& prefix,
46 Profile* profile, 46 Profile* profile,
47 const string16 match_keyword) 47 const string16 match_keyword)
48 : AutocompleteProvider(NULL, profile, ""), 48 : AutocompleteProvider(NULL, profile, AutocompleteProvider::TYPE_SEARCH),
49 relevance_(relevance), 49 relevance_(relevance),
50 prefix_(prefix), 50 prefix_(prefix),
51 match_keyword_(match_keyword) { 51 match_keyword_(match_keyword) {
52 } 52 }
53 53
54 virtual void Start(const AutocompleteInput& input, 54 virtual void Start(const AutocompleteInput& input,
55 bool minimal_changes); 55 bool minimal_changes);
56 56
57 void set_listener(AutocompleteProviderListener* listener) { 57 void set_listener(AutocompleteProviderListener* listener) {
58 listener_ = listener; 58 listener_ = listener;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 data.SetKeyword(ASCIIToUTF16("bar.com")); 326 data.SetKeyword(ASCIIToUTF16("bar.com"));
327 data.SetURL("http://bar.com/{searchTerms}"); 327 data.SetURL("http://bar.com/{searchTerms}");
328 keyword_t_url = new TemplateURL(&profile_, data); 328 keyword_t_url = new TemplateURL(&profile_, data);
329 turl_model->Add(keyword_t_url); 329 turl_model->Add(keyword_t_url);
330 ASSERT_NE(0, keyword_t_url->id()); 330 ASSERT_NE(0, keyword_t_url->id());
331 331
332 // Forget about any existing providers. The controller owns them and will 332 // Forget about any existing providers. The controller owns them and will
333 // Release() them below, when we delete it during the call to reset(). 333 // Release() them below, when we delete it during the call to reset().
334 providers_.clear(); 334 providers_.clear();
335 335
336 // Create both a keyword and search provider, and add them in that order. 336 AutocompleteController* controller = new AutocompleteController(&profile_,
Peter Kasting 2012/09/11 00:05:39 Nit: Even shorter: controller_.reset(new ...);
Daniel Erat 2012/09/11 00:42:19 Done.
337 // (Order is important; see comments in RunExactKeymatchTest().) 337 NULL, AutocompleteProvider::TYPE_KEYWORD);
338 KeywordProvider* keyword_provider = new KeywordProvider(NULL, &profile_); 338 providers_.push_back(controller->keyword_provider());
339 keyword_provider->AddRef();
340 providers_.push_back(keyword_provider);
341
342 AutocompleteController* controller =
343 new AutocompleteController(providers_, &profile_);
344 controller->set_keyword_provider(keyword_provider);
345 controller_.reset(controller); 339 controller_.reset(controller);
346 } 340 }
347 341
348 void AutocompleteProviderTest::RunTest() { 342 void AutocompleteProviderTest::RunTest() {
349 RunQuery(ASCIIToUTF16("a")); 343 RunQuery(ASCIIToUTF16("a"));
350 } 344 }
351 345
352 void AutocompleteProviderTest::RunRedundantKeywordTest( 346 void AutocompleteProviderTest::RunRedundantKeywordTest(
353 const KeywordTestData* match_data, 347 const KeywordTestData* match_data,
354 size_t size) { 348 size_t size) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, 551 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" },
558 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, 552 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" },
559 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, 553 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" },
560 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, 554 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" },
561 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, 555 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" },
562 }; 556 };
563 SCOPED_TRACE("Multiple matches"); 557 SCOPED_TRACE("Multiple matches");
564 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); 558 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
565 } 559 }
566 } 560 }
567
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698