OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/app_list/app_list_model.h" | 13 #include "ui/app_list/app_list_model.h" |
14 #include "ui/app_list/search/history_types.h" | 14 #include "ui/app_list/search/history_types.h" |
15 #include "ui/app_list/search/mixer.h" | 15 #include "ui/app_list/search/mixer.h" |
16 #include "ui/app_list/search_provider.h" | 16 #include "ui/app_list/search_provider.h" |
17 #include "ui/app_list/search_result.h" | 17 #include "ui/app_list/search_result.h" |
18 | 18 |
19 namespace app_list { | 19 namespace app_list { |
20 namespace test { | 20 namespace test { |
21 | 21 |
22 // Maximum number of results to show in each mixer group. | 22 // Maximum number of results to show in each mixer group. |
23 const size_t kMaxAppsGroupResults = 4; | 23 const size_t kMaxAppsGroupResults = 4; |
24 const size_t kMaxOmniboxResults = 0; // Ignored. | 24 // Ignored unless AppListMixer field trial is "Blended". |
| 25 const size_t kMaxOmniboxResults = 4; |
25 const size_t kMaxWebstoreResults = 2; | 26 const size_t kMaxWebstoreResults = 2; |
26 const size_t kMaxPeopleResults = 2; | 27 const size_t kMaxPeopleResults = 2; |
27 | 28 |
28 class TestSearchResult : public SearchResult { | 29 class TestSearchResult : public SearchResult { |
29 public: | 30 public: |
30 TestSearchResult(const std::string& id, double relevance) | 31 TestSearchResult(const std::string& id, double relevance) |
31 : instance_id_(instantiation_count++) { | 32 : instance_id_(instantiation_count++) { |
32 set_id(id); | 33 set_id(id); |
33 set_title(base::UTF8ToUTF16(id)); | 34 set_title(base::UTF8ToUTF16(id)); |
34 set_relevance(relevance); | 35 set_relevance(relevance); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 112 |
112 providers_.push_back(new TestSearchProvider("app")); | 113 providers_.push_back(new TestSearchProvider("app")); |
113 providers_.push_back(new TestSearchProvider("omnibox")); | 114 providers_.push_back(new TestSearchProvider("omnibox")); |
114 providers_.push_back(new TestSearchProvider("webstore")); | 115 providers_.push_back(new TestSearchProvider("webstore")); |
115 providers_.push_back(new TestSearchProvider("people")); | 116 providers_.push_back(new TestSearchProvider("people")); |
116 | 117 |
117 is_voice_query_ = false; | 118 is_voice_query_ = false; |
118 | 119 |
119 mixer_.reset(new Mixer(results_.get())); | 120 mixer_.reset(new Mixer(results_.get())); |
120 | 121 |
121 size_t apps_group_id = mixer_->AddGroup(kMaxAppsGroupResults, 3.0); | 122 size_t apps_group_id = mixer_->AddGroup(kMaxAppsGroupResults, 3.0, 1.0); |
122 size_t omnibox_group_id = mixer_->AddOmniboxGroup(kMaxOmniboxResults, 2.0); | 123 size_t omnibox_group_id = |
123 size_t webstore_group_id = mixer_->AddGroup(kMaxWebstoreResults, 1.0); | 124 mixer_->AddOmniboxGroup(kMaxOmniboxResults, 2.0, 1.0); |
124 size_t people_group_id = mixer_->AddGroup(kMaxPeopleResults, 0.0); | 125 size_t webstore_group_id = mixer_->AddGroup(kMaxWebstoreResults, 1.0, 0.5); |
| 126 size_t people_group_id = mixer_->AddGroup(kMaxPeopleResults, 0.0, 1.0); |
125 | 127 |
126 mixer_->AddProviderToGroup(apps_group_id, providers_[0]); | 128 mixer_->AddProviderToGroup(apps_group_id, providers_[0]); |
127 mixer_->AddProviderToGroup(omnibox_group_id, providers_[1]); | 129 mixer_->AddProviderToGroup(omnibox_group_id, providers_[1]); |
128 mixer_->AddProviderToGroup(webstore_group_id, providers_[2]); | 130 mixer_->AddProviderToGroup(webstore_group_id, providers_[2]); |
129 mixer_->AddProviderToGroup(people_group_id, providers_[3]); | 131 mixer_->AddProviderToGroup(people_group_id, providers_[3]); |
130 } | 132 } |
131 | 133 |
132 void RunQuery() { | 134 void RunQuery() { |
133 const base::string16 query; | 135 const base::string16 query; |
134 | 136 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 EXPECT_EQ(old_ui_result_ids[0], | 385 EXPECT_EQ(old_ui_result_ids[0], |
384 TestSearchResult::GetInstanceId(ui_results.GetItemAt(3))); | 386 TestSearchResult::GetInstanceId(ui_results.GetItemAt(3))); |
385 EXPECT_EQ(old_ui_result_ids[1], | 387 EXPECT_EQ(old_ui_result_ids[1], |
386 TestSearchResult::GetInstanceId(ui_results.GetItemAt(0))); | 388 TestSearchResult::GetInstanceId(ui_results.GetItemAt(0))); |
387 EXPECT_EQ(old_ui_result_ids[2], | 389 EXPECT_EQ(old_ui_result_ids[2], |
388 TestSearchResult::GetInstanceId(ui_results.GetItemAt(2))); | 390 TestSearchResult::GetInstanceId(ui_results.GetItemAt(2))); |
389 } | 391 } |
390 | 392 |
391 } // namespace test | 393 } // namespace test |
392 } // namespace app_list | 394 } // namespace app_list |
OLD | NEW |