Index: ui/app_list/search/mixer_unittest.cc |
diff --git a/ui/app_list/search/mixer_unittest.cc b/ui/app_list/search/mixer_unittest.cc |
index 8397a98e58ef1c2ad3ae33db0cfd1946d6b54aeb..565b81bdf1e965b843b3a4211e609958b64e249b 100644 |
--- a/ui/app_list/search/mixer_unittest.cc |
+++ b/ui/app_list/search/mixer_unittest.cc |
@@ -120,7 +120,7 @@ class MixerTest : public testing::Test { |
providers_[i]->Stop(); |
} |
- mixer_->MixAndPublish(is_voice_query_, KnownResults()); |
+ mixer_->MixAndPublish(is_voice_query_, known_results_); |
} |
std::string GetResults() const { |
@@ -146,9 +146,14 @@ class MixerTest : public testing::Test { |
is_voice_query_ = is_voice_query; |
} |
+ void AddKnownResult(const std::string& id, KnownResultType type) { |
+ known_results_[id] = type; |
+ } |
+ |
private: |
scoped_ptr<Mixer> mixer_; |
scoped_ptr<AppListModel::SearchResults> results_; |
+ KnownResults known_results_; |
bool is_voice_query_; |
@@ -218,6 +223,25 @@ TEST_F(MixerTest, RemoveDuplicates) { |
EXPECT_EQ("dup0,dup1,dup2", GetResults()); |
} |
+// Tests that "known results" have priority over others. |
+TEST_F(MixerTest, KnownResultsPriority) { |
+ // This gives omnibox 0 -- 5. |
+ omnibox_provider()->set_count(6); |
+ |
+ // omnibox 1 -- 4 are "known results". |
+ AddKnownResult("omnibox1", PREFIX_SECONDARY); |
+ AddKnownResult("omnibox2", PERFECT_SECONDARY); |
+ AddKnownResult("omnibox3", PREFIX_PRIMARY); |
+ AddKnownResult("omnibox4", PERFECT_PRIMARY); |
+ |
+ RunQuery(); |
+ |
+ // omnibox 1 -- 4 should be prioritised over the others. They should be |
+ // ordered 4, 3, 2, 1 (in order of match quality). |
+ EXPECT_EQ("omnibox4,omnibox3,omnibox2,omnibox1,omnibox0,omnibox5", |
+ GetResults()); |
+} |
+ |
TEST_F(MixerTest, VoiceQuery) { |
omnibox_provider()->set_count(3); |
RunQuery(); |