Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / app_list / test / app_list_test_view_delegate.cc
blob99b2cd2bb050290efb98369f8912d5d29c06797a
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 model_->SetFoldersEnabled(true);
30 AppListTestViewDelegate::~AppListTestViewDelegate() {}
32 int AppListTestViewDelegate::GetToggleSpeechRecognitionCountAndReset() {
33 int count = toggle_speech_recognition_count_;
34 toggle_speech_recognition_count_ = 0;
35 return count;
38 bool AppListTestViewDelegate::ForceNativeDesktop() const {
39 return false;
42 void AppListTestViewDelegate::SetProfileByPath(
43 const base::FilePath& profile_path) {
44 ReplaceTestModel(next_profile_app_count_);
47 AppListModel* AppListTestViewDelegate::GetModel() {
48 return model_.get();
51 SpeechUIModel* AppListTestViewDelegate::GetSpeechUI() {
52 return &speech_ui_;
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,
62 bool auto_launch,
63 int event_flags) {
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]++;
68 break;
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() {
83 ++dismiss_count_;
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) {
97 return NULL;
99 std::vector<views::View*> AppListTestViewDelegate::CreateCustomPageWebViews(
100 const gfx::Size& size) {
101 return std::vector<views::View*>();
103 #endif
105 bool AppListTestViewDelegate::IsSpeechRecognitionEnabled() {
106 return false;
109 const AppListViewDelegate::Users& AppListTestViewDelegate::GetUsers() const {
110 return users_;
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);
132 } // namespace test
133 } // namespace app_list