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

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

Issue 11414303: Make Google Search autocomplete provider cursor aware. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 376
377 // Verify data. 377 // Verify data.
378 for (size_t i = 0; i < size; ++i) { 378 for (size_t i = 0; i < size; ++i) {
379 EXPECT_EQ(aqs_test_data[i].expected_aqs, 379 EXPECT_EQ(aqs_test_data[i].expected_aqs,
380 result_.match_at(i)->search_terms_args->assisted_query_stats); 380 result_.match_at(i)->search_terms_args->assisted_query_stats);
381 } 381 }
382 } 382 }
383 383
384 void AutocompleteProviderTest::RunQuery(const string16 query) { 384 void AutocompleteProviderTest::RunQuery(const string16 query) {
385 result_.Reset(); 385 result_.Reset();
386 controller_->Start(query, string16(), true, false, true, 386 controller_->Start(AutocompleteInput(
387 AutocompleteInput::ALL_MATCHES); 387 query, string16::npos, string16(), true, false, true,
388 AutocompleteInput::ALL_MATCHES));
388 389
389 if (!controller_->done()) 390 if (!controller_->done())
390 // The message loop will terminate when all autocomplete input has been 391 // The message loop will terminate when all autocomplete input has been
391 // collected. 392 // collected.
392 MessageLoop::current()->Run(); 393 MessageLoop::current()->Run();
393 } 394 }
394 395
395 void AutocompleteProviderTest::RunExactKeymatchTest( 396 void AutocompleteProviderTest::RunExactKeymatchTest(
396 bool allow_exact_keyword_match) { 397 bool allow_exact_keyword_match) {
397 // Send the controller input which exactly matches the keyword provider we 398 // Send the controller input which exactly matches the keyword provider we
398 // created in ResetControllerWithKeywordAndSearchProviders(). The default 399 // created in ResetControllerWithKeywordAndSearchProviders(). The default
399 // match should thus be a keyword match iff |allow_exact_keyword_match| is 400 // match should thus be a keyword match iff |allow_exact_keyword_match| is
400 // true. 401 // true.
401 controller_->Start(ASCIIToUTF16("k test"), string16(), true, false, 402 controller_->Start(AutocompleteInput(
402 allow_exact_keyword_match, 403 ASCIIToUTF16("k test"), string16::npos, string16(), true, false,
403 AutocompleteInput::SYNCHRONOUS_MATCHES); 404 allow_exact_keyword_match, AutocompleteInput::SYNCHRONOUS_MATCHES));
404 EXPECT_TRUE(controller_->done()); 405 EXPECT_TRUE(controller_->done());
405 EXPECT_EQ(allow_exact_keyword_match ? 406 EXPECT_EQ(allow_exact_keyword_match ?
406 AutocompleteProvider::TYPE_KEYWORD : AutocompleteProvider::TYPE_SEARCH, 407 AutocompleteProvider::TYPE_KEYWORD : AutocompleteProvider::TYPE_SEARCH,
407 controller_->result().default_match()->provider->type()); 408 controller_->result().default_match()->provider->type());
408 } 409 }
409 410
410 void AutocompleteProviderTest::Observe( 411 void AutocompleteProviderTest::Observe(
411 int type, 412 int type,
412 const content::NotificationSource& source, 413 const content::NotificationSource& source,
413 const content::NotificationDetails& details) { 414 const content::NotificationDetails& details) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, 543 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" },
543 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, 544 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" },
544 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, 545 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" },
545 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, 546 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" },
546 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, 547 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" },
547 }; 548 };
548 SCOPED_TRACE("Multiple matches"); 549 SCOPED_TRACE("Multiple matches");
549 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); 550 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
550 } 551 }
551 } 552 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698