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

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: update comments 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),
Daniel Erat 2012/09/07 21:45:55 I'm using TYPE_SEARCH pretty arbitrarily here. Le
Peter Kasting 2012/09/07 23:23:02 This is fine.
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Create both a keyword and search provider, and add them in that order.
337 // (Order is important; see comments in RunExactKeymatchTest().) 337 // (Order is important; see comments in RunExactKeymatchTest().)
338 KeywordProvider* keyword_provider = new KeywordProvider(NULL, &profile_); 338 KeywordProvider* keyword_provider = new KeywordProvider(NULL, &profile_);
Peter Kasting 2012/09/07 23:23:02 I think this block of code can be replaced with a
Daniel Erat 2012/09/08 16:37:36 Done. Think I was misled by the comment above ("C
339 keyword_provider->AddRef(); 339 keyword_provider->AddRef();
340 providers_.push_back(keyword_provider); 340 providers_.push_back(keyword_provider);
341 341
342 AutocompleteController* controller = 342 AutocompleteController* controller =
343 new AutocompleteController(providers_, &profile_); 343 new AutocompleteController(providers_, &profile_);
344 controller->set_keyword_provider(keyword_provider); 344 controller->set_keyword_provider(keyword_provider);
345 controller_.reset(controller); 345 controller_.reset(controller);
346 } 346 }
347 347
348 void AutocompleteProviderTest::RunTest() { 348 void AutocompleteProviderTest::RunTest() {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, 557 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" },
558 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, 558 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" },
559 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, 559 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" },
560 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, 560 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" },
561 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, 561 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" },
562 }; 562 };
563 SCOPED_TRACE("Multiple matches"); 563 SCOPED_TRACE("Multiple matches");
564 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); 564 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
565 } 565 }
566 } 566 }
567
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698