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 model_
->SetFoldersEnabled(true);
30 AppListTestViewDelegate::~AppListTestViewDelegate() {}
32 int AppListTestViewDelegate::GetToggleSpeechRecognitionCountAndReset() {
33 int count
= toggle_speech_recognition_count_
;
34 toggle_speech_recognition_count_
= 0;
38 bool AppListTestViewDelegate::ForceNativeDesktop() const {
42 void AppListTestViewDelegate::SetProfileByPath(
43 const base::FilePath
& profile_path
) {
44 ReplaceTestModel(next_profile_app_count_
);
47 AppListModel
* AppListTestViewDelegate::GetModel() {
51 SpeechUIModel
* AppListTestViewDelegate::GetSpeechUI() {
55 void AppListTestViewDelegate::GetShortcutPathForApp(
56 const std::string
& app_id
,
57 const base::Callback
<void(const base::FilePath
&)>& callback
) {
58 callback
.Run(base::FilePath());
61 void AppListTestViewDelegate::OpenSearchResult(SearchResult
* result
,
64 const AppListModel::SearchResults
* results
= model_
->results();
65 for (size_t i
= 0; i
< results
->item_count(); ++i
) {
66 if (results
->GetItemAt(i
) == result
) {
67 open_search_result_counts_
[i
]++;
71 ++open_search_result_count_
;
74 base::TimeDelta
AppListTestViewDelegate::GetAutoLaunchTimeout() {
75 return auto_launch_timeout_
;
78 void AppListTestViewDelegate::AutoLaunchCanceled() {
79 auto_launch_timeout_
= base::TimeDelta();
82 void AppListTestViewDelegate::Dismiss() {
86 void AppListTestViewDelegate::ToggleSpeechRecognition() {
87 ++toggle_speech_recognition_count_
;
90 gfx::ImageSkia
AppListTestViewDelegate::GetWindowIcon() {
91 return gfx::ImageSkia();
94 #if defined(TOOLKIT_VIEWS)
95 views::View
* AppListTestViewDelegate::CreateStartPageWebView(
96 const gfx::Size
& size
) {
99 std::vector
<views::View
*> AppListTestViewDelegate::CreateCustomPageWebViews(
100 const gfx::Size
& size
) {
101 return std::vector
<views::View
*>();
105 bool AppListTestViewDelegate::IsSpeechRecognitionEnabled() {
109 const AppListViewDelegate::Users
& AppListTestViewDelegate::GetUsers() const {
113 bool AppListTestViewDelegate::ShouldCenterWindow() const {
114 return app_list::switches::IsCenteredAppListEnabled();
117 void AppListTestViewDelegate::ReplaceTestModel(int item_count
) {
118 model_
.reset(new AppListTestModel
);
119 model_
->PopulateApps(item_count
);
122 void AppListTestViewDelegate::AddObserver(
123 AppListViewDelegateObserver
* observer
) {
124 observers_
.AddObserver(observer
);
127 void AppListTestViewDelegate::RemoveObserver(
128 AppListViewDelegateObserver
* observer
) {
129 observers_
.RemoveObserver(observer
);
133 } // namespace app_list