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"
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"
21 AppListTestViewDelegate::AppListTestViewDelegate()
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;
39 bool AppListTestViewDelegate::ForceNativeDesktop() const {
43 void AppListTestViewDelegate::SetProfileByPath(
44 const base::FilePath
& profile_path
) {
45 ReplaceTestModel(next_profile_app_count_
);
48 AppListModel
* AppListTestViewDelegate::GetModel() {
52 SpeechUIModel
* AppListTestViewDelegate::GetSpeechUI() {
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
,
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
]++;
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() {
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
) {
100 std::vector
<views::View
*> AppListTestViewDelegate::CreateCustomPageWebViews(
101 const gfx::Size
& size
) {
102 return std::vector
<views::View
*>();
106 bool AppListTestViewDelegate::IsSpeechRecognitionEnabled() {
110 const AppListViewDelegate::Users
& AppListTestViewDelegate::GetUsers() const {
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
);
134 } // namespace app_list