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

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

Issue 12623029: Upstreaming mechanism to add query refinement to omnibox searches. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied Peter's comments. Created 7 years, 9 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Verify data. 380 // Verify data.
381 for (size_t i = 0; i < size; ++i) { 381 for (size_t i = 0; i < size; ++i) {
382 EXPECT_EQ(aqs_test_data[i].expected_aqs, 382 EXPECT_EQ(aqs_test_data[i].expected_aqs,
383 result_.match_at(i)->search_terms_args->assisted_query_stats); 383 result_.match_at(i)->search_terms_args->assisted_query_stats);
384 } 384 }
385 } 385 }
386 386
387 void AutocompleteProviderTest::RunQuery(const string16 query) { 387 void AutocompleteProviderTest::RunQuery(const string16 query) {
388 result_.Reset(); 388 result_.Reset();
389 controller_->Start(AutocompleteInput( 389 controller_->Start(AutocompleteInput(
390 query, string16::npos, string16(), true, false, true, 390 query, string16::npos, string16(), GURL(), true, false, true,
391 AutocompleteInput::ALL_MATCHES)); 391 AutocompleteInput::ALL_MATCHES));
392 392
393 if (!controller_->done()) 393 if (!controller_->done())
394 // The message loop will terminate when all autocomplete input has been 394 // The message loop will terminate when all autocomplete input has been
395 // collected. 395 // collected.
396 MessageLoop::current()->Run(); 396 MessageLoop::current()->Run();
397 } 397 }
398 398
399 void AutocompleteProviderTest::RunExactKeymatchTest( 399 void AutocompleteProviderTest::RunExactKeymatchTest(
400 bool allow_exact_keyword_match) { 400 bool allow_exact_keyword_match) {
401 // Send the controller input which exactly matches the keyword provider we 401 // Send the controller input which exactly matches the keyword provider we
402 // created in ResetControllerWithKeywordAndSearchProviders(). The default 402 // created in ResetControllerWithKeywordAndSearchProviders(). The default
403 // match should thus be a search-other-engine match iff 403 // match should thus be a search-other-engine match iff
404 // |allow_exact_keyword_match| is true. Regardless, the match should 404 // |allow_exact_keyword_match| is true. Regardless, the match should
405 // be from SearchProvider. (It provides all verbatim search matches, 405 // be from SearchProvider. (It provides all verbatim search matches,
406 // keyword or not.) 406 // keyword or not.)
407 controller_->Start(AutocompleteInput( 407 controller_->Start(AutocompleteInput(
408 ASCIIToUTF16("k test"), string16::npos, string16(), true, false, 408 ASCIIToUTF16("k test"), string16::npos, string16(), GURL(), true, false,
409 allow_exact_keyword_match, AutocompleteInput::SYNCHRONOUS_MATCHES)); 409 allow_exact_keyword_match, AutocompleteInput::SYNCHRONOUS_MATCHES));
410 EXPECT_TRUE(controller_->done()); 410 EXPECT_TRUE(controller_->done());
411 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH, 411 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH,
412 controller_->result().default_match()->provider->type()); 412 controller_->result().default_match()->provider->type());
413 EXPECT_EQ(allow_exact_keyword_match ? 413 EXPECT_EQ(allow_exact_keyword_match ?
414 AutocompleteMatch::SEARCH_OTHER_ENGINE : 414 AutocompleteMatch::SEARCH_OTHER_ENGINE :
415 AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, 415 AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
416 controller_->result().default_match()->type); 416 controller_->result().default_match()->type);
417 } 417 }
418 418
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 EXPECT_EQ("//aqs=chrome.0.57j58j5l2j0l3j59.2456j0&", url.path()); 597 EXPECT_EQ("//aqs=chrome.0.57j58j5l2j0l3j59.2456j0&", url.path());
598 598
599 // Test field trial triggered bit set. 599 // Test field trial triggered bit set.
600 controller_->search_provider_->field_trial_triggered_in_session_ = true; 600 controller_->search_provider_->field_trial_triggered_in_session_ = true;
601 EXPECT_TRUE( 601 EXPECT_TRUE(
602 controller_->search_provider_->field_trial_triggered_in_session()); 602 controller_->search_provider_->field_trial_triggered_in_session());
603 url = controller_->GetDestinationURL(match, 603 url = controller_->GetDestinationURL(match,
604 base::TimeDelta::FromMilliseconds(2456)); 604 base::TimeDelta::FromMilliseconds(2456));
605 EXPECT_EQ("//aqs=chrome.0.57j58j5l2j0l3j59.2456j1&", url.path()); 605 EXPECT_EQ("//aqs=chrome.0.57j58j5l2j0l3j59.2456j1&", url.path());
606 } 606 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698