Allow app list tiles to show search results in the experimental app list.
[chromium-blink-merge.git] / ui / app_list / test / app_list_test_view_delegate.cc
blob56c2e8f3ea1b06802a30fae5c65e109b8601b064
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
3 // found in the LICENSE file.
5 #include "ui/app_list/test/app_list_test_view_delegate.h"
7 #include <string>
8 #include <vector>
10 #include "base/callback.h"
11 #include "base/files/file_path.h"
12 #include "ui/app_list/app_list_model.h"
13 #include "ui/app_list/app_list_switches.h"
14 #include "ui/app_list/app_list_view_delegate_observer.h"
15 #include "ui/app_list/test/app_list_test_model.h"
16 #include "ui/gfx/image/image_skia.h"
18 namespace app_list {
19 namespace test {
21 AppListTestViewDelegate::AppListTestViewDelegate()
22 : dismiss_count_(0),
23 toggle_speech_recognition_count_(0),
24 open_search_result_count_(0),
25 next_profile_app_count_(0),
26 model_(new AppListTestModel),
27 speech_ui_(SPEECH_RECOGNITION_OFF) {
28 model_->SetFoldersEnabled(true);
31 AppListTestViewDelegate::~AppListTestViewDelegate() {}
33 int AppListTestViewDelegate::GetToggleSpeechRecognitionCountAndReset() {
34 int count = toggle_speech_recognition_count_;
35 toggle_speech_recognition_count_ = 0;
36 return count;
39 bool AppListTestViewDelegate::ForceNativeDesktop() const {
40 return false;
43 void AppListTestViewDelegate::SetProfileByPath(
44 const base::FilePath& profile_path) {
45 ReplaceTestModel(next_profile_app_count_);
48 AppListModel* AppListTestViewDelegate::GetModel() {
49 return model_.get();
52 SpeechUIModel* AppListTestViewDelegate::GetSpeechUI() {
53 return &speech_ui_;
56 void AppListTestViewDelegate::GetShortcutPathForApp(
57 const std::string& app_id,
58 const base::Callback<void(const base::FilePath&)>& callback) {
59 callback.Run(base::FilePath());
62 void AppListTestViewDelegate::OpenSearchResult(SearchResult* result,
63 bool auto_launch,
64 int event_flags) {
65 const AppListModel::SearchResults* results = model_->results();
66 for (size_t i = 0; i < results->item_count(); ++i) {
67 if (results->GetItemAt(i) == result) {
68 open_search_result_counts_[i]++;
69 break;
72 ++open_search_result_count_;
75 base::TimeDelta AppListTestViewDelegate::GetAutoLaunchTimeout() {
76 return auto_launch_timeout_;
79 void AppListTestViewDelegate::AutoLaunchCanceled() {
80 auto_launch_timeout_ = base::TimeDelta();
83 void AppListTestViewDelegate::Dismiss() {
84 ++dismiss_count_;
87 void AppListTestViewDelegate::ToggleSpeechRecognition() {
88 ++toggle_speech_recognition_count_;
91 gfx::ImageSkia AppListTestViewDelegate::GetWindowIcon() {
92 return gfx::ImageSkia();
95 #if defined(TOOLKIT_VIEWS)
96 views::View* AppListTestViewDelegate::CreateStartPageWebView(
97 const gfx::Size& size) {
98 return NULL;
100 std::vector<views::View*> AppListTestViewDelegate::CreateCustomPageWebViews(
101 const gfx::Size& size) {
102 return std::vector<views::View*>();
104 #endif
106 bool AppListTestViewDelegate::IsSpeechRecognitionEnabled() {
107 return false;
110 const AppListViewDelegate::Users& AppListTestViewDelegate::GetUsers() const {
111 return users_;
114 bool AppListTestViewDelegate::ShouldCenterWindow() const {
115 return app_list::switches::IsCenteredAppListEnabled();
118 void AppListTestViewDelegate::ReplaceTestModel(int item_count) {
119 model_.reset(new AppListTestModel);
120 model_->PopulateApps(item_count);
123 void AppListTestViewDelegate::AddObserver(
124 AppListViewDelegateObserver* observer) {
125 observers_.AddObserver(observer);
128 void AppListTestViewDelegate::RemoveObserver(
129 AppListViewDelegateObserver* observer) {
130 observers_.RemoveObserver(observer);
133 } // namespace test
134 } // namespace app_list