summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_unittest.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_unittest.cc83
1 files changed, 4 insertions, 79 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc
index cadda8d..af96555 100644
--- a/chrome/browser/autocomplete/autocomplete_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_unittest.cc
@@ -150,7 +150,7 @@ void AutocompleteProviderTest::OnAutocompleteUpdate(bool updated_result,
void AutocompleteProviderTest::RunTest() {
result_.Reset();
- const AutocompleteInput input(L"a", std::wstring(), true);
+ const AutocompleteInput input(L"a", std::wstring(), true, false);
EXPECT_FALSE(controller_->Start(input, false, false));
// The message loop will terminate when all autocomplete input has been
@@ -169,86 +169,11 @@ std::ostream& operator<<(std::ostream& os,
TEST_F(AutocompleteProviderTest, Query) {
RunTest();
- // Make sure the default match gets set to the highest relevance match when
- // we have no preference. The highest relevance matches should come from
- // the second provider.
- AutocompleteResult::Selection selection;
- result_.SetDefaultMatch(selection);
+ // Make sure the default match gets set to the highest relevance match. The
+ // highest relevance matches should come from the second provider.
EXPECT_EQ(num_results_per_provider * 2, result_.size()); // two providers
ASSERT_NE(result_.end(), result_.default_match());
EXPECT_EQ(providers_[1], result_.default_match()->provider);
-
- // Change provider affinity.
- selection.provider_affinity = providers_[0];
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(providers_[0], result_.default_match()->provider);
-}
-
-TEST_F(AutocompleteProviderTest, UpdateSelection) {
- RunTest();
-
- // An empty selection should simply result in the default match overall.
- AutocompleteResult::Selection selection;
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(providers_[1], result_.default_match()->provider);
-
- // ...As should specifying a provider that didn't return results.
- scoped_refptr<TestProvider> test_provider = new TestProvider(0, L"");
- selection.provider_affinity = test_provider.get();
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(providers_[1], result_.default_match()->provider);
- selection.provider_affinity = NULL;
- test_provider = NULL;
-
- // ...As should specifying a destination URL that doesn't exist, and no
- // provider.
- selection.destination_url = L"garbage";
- selection.provider_affinity = NULL;
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(providers_[1], result_.default_match()->provider);
- delete selection.provider_affinity;
-
- // Specifying a valid provider should result in the default match from that
- // provider.
- selection.destination_url.clear();
- selection.provider_affinity = providers_[0];
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(providers_[0], result_.default_match()->provider);
-
- // ...And nothing should change if we specify a destination that doesn't
- // exist.
- selection.destination_url = L"garbage";
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(providers_[0], result_.default_match()->provider);
-
- // Specifying a particular URL should match that URL.
- std::wstring non_default_url_from_provider_0(L"a2");
- selection.destination_url = non_default_url_from_provider_0;
- selection.provider_affinity = providers_[0];
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(non_default_url_from_provider_0,
- result_.default_match()->destination_url);
-
- // ...Even when we ask for a different provider.
- selection.provider_affinity = providers_[1];
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(non_default_url_from_provider_0,
- result_.default_match()->destination_url);
-
- // ...Or when we don't ask for a provider at all.
- selection.provider_affinity = NULL;
- result_.SetDefaultMatch(selection);
- ASSERT_NE(result_.end(), result_.default_match());
- EXPECT_EQ(non_default_url_from_provider_0,
- result_.default_match()->destination_url);
}
TEST_F(AutocompleteProviderTest, RemoveDuplicates) {
@@ -303,7 +228,7 @@ TEST(AutocompleteTest, InputType) {
};
for (int i = 0; i < arraysize(input_cases); ++i) {
- AutocompleteInput input(input_cases[i].input, std::wstring(), true);
+ AutocompleteInput input(input_cases[i].input, std::wstring(), true, false);
EXPECT_EQ(input_cases[i].type, input.type()) << "Input: " <<
input_cases[i].input;
}