| Index: chrome/browser/autocomplete/autocomplete_provider_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/autocomplete/autocomplete_provider_unittest.cc (revision 208572)
|
| +++ chrome/browser/autocomplete/autocomplete_provider_unittest.cc (working copy)
|
| @@ -5,6 +5,7 @@
|
| #include "chrome/browser/autocomplete/autocomplete_provider.h"
|
|
|
| #include "base/bind.h"
|
| +#include "base/command_line.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop.h"
|
| #include "base/strings/string16.h"
|
| @@ -21,6 +22,7 @@
|
| #include "chrome/browser/search_engines/template_url_service.h"
|
| #include "chrome/browser/search_engines/template_url_service_factory.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/test/base/testing_browser_process.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| #include "content/public/browser/notification_observer.h"
|
| @@ -185,11 +187,13 @@
|
| void ResetControllerWithKeywordProvider();
|
| void RunExactKeymatchTest(bool allow_exact_keyword_match);
|
|
|
| + void CopyResults();
|
| +
|
| AutocompleteResult result_;
|
| scoped_ptr<AutocompleteController> controller_;
|
|
|
| private:
|
| - // content::NotificationObserver
|
| + // content::NotificationObserver:
|
| virtual void Observe(int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) OVERRIDE;
|
| @@ -416,12 +420,16 @@
|
| controller_->result().default_match()->type);
|
| }
|
|
|
| +void AutocompleteProviderTest::CopyResults() {
|
| + result_.CopyFrom(controller_->result());
|
| +}
|
| +
|
| void AutocompleteProviderTest::Observe(
|
| int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| if (controller_->done()) {
|
| - result_.CopyFrom(controller_->result());
|
| + CopyResults();
|
| base::MessageLoop::current()->Quit();
|
| }
|
| }
|
| @@ -445,7 +453,7 @@
|
| ResetControllerWithTestProviders(false, NULL, NULL);
|
| RunTest();
|
|
|
| - EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers
|
| + ASSERT_EQ(kResultsPerProvider * 2, result_.size()); // two providers
|
|
|
| // Now, check the results from the second provider, as they should not have
|
| // assisted query stats set.
|
| @@ -480,6 +488,21 @@
|
| RunExactKeymatchTest(false);
|
| }
|
|
|
| +// Ensures matches from (only) the default search provider respect any extra
|
| +// query params set on the command line.
|
| +TEST_F(AutocompleteProviderTest, ExtraQueryParams) {
|
| + ResetControllerWithKeywordAndSearchProviders();
|
| + CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + switches::kExtraSearchQueryParams, "a=b");
|
| + RunExactKeymatchTest(true);
|
| + CopyResults();
|
| + ASSERT_EQ(2, result_.size());
|
| + EXPECT_EQ("http://keyword/test",
|
| + result_.match_at(0)->destination_url.possibly_invalid_spec());
|
| + EXPECT_EQ("http://defaultturl/k%20test?a=b",
|
| + result_.match_at(1)->destination_url.possibly_invalid_spec());
|
| +}
|
| +
|
| // Test that redundant associated keywords are removed.
|
| TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) {
|
| ResetControllerWithKeywordProvider();
|
|
|