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 #ifndef UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_
6 #define UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_
12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h"
16 #include "ui/app_list/app_list_view_delegate.h"
17 #include "ui/app_list/speech_ui_model.h"
22 class AppListTestModel
;
24 // A concrete AppListViewDelegate for unit tests.
25 class AppListTestViewDelegate
: public AppListViewDelegate
{
27 AppListTestViewDelegate();
28 ~AppListTestViewDelegate() override
;
30 int dismiss_count() { return dismiss_count_
; }
31 int open_search_result_count() { return open_search_result_count_
; }
32 void SetUsers(const Users
& users
) {
35 std::map
<size_t, int> open_search_result_counts() {
36 return open_search_result_counts_
;
39 // Sets the number of apps that the model will be created with the next time
40 // SetProfileByPath() is called.
41 void set_next_profile_app_count(int apps
) { next_profile_app_count_
= apps
; }
43 void set_auto_launch_timeout(const base::TimeDelta
& timeout
) {
44 auto_launch_timeout_
= timeout
;
47 // Returns the value of |toggle_speech_recognition_count_| and then
48 // resets this value to 0.
49 int GetToggleSpeechRecognitionCountAndReset();
51 // AppListViewDelegate overrides:
52 bool ForceNativeDesktop() const override
;
53 void SetProfileByPath(const base::FilePath
& profile_path
) override
;
54 AppListModel
* GetModel() override
;
55 SpeechUIModel
* GetSpeechUI() override
;
56 void GetShortcutPathForApp(
57 const std::string
& app_id
,
58 const base::Callback
<void(const base::FilePath
&)>& callback
) override
;
59 void StartSearch() override
{}
60 void StopSearch() override
{}
61 void OpenSearchResult(SearchResult
* result
,
63 int event_flags
) override
;
64 void InvokeSearchResultAction(SearchResult
* result
,
66 int event_flags
) override
{}
67 base::TimeDelta
GetAutoLaunchTimeout() override
;
68 void AutoLaunchCanceled() override
;
69 void ViewInitialized() override
{}
70 void Dismiss() override
;
71 void ViewClosing() override
{}
72 gfx::ImageSkia
GetWindowIcon() override
;
73 void OpenSettings() override
{}
74 void OpenHelp() override
{}
75 void OpenFeedback() override
{}
76 void ToggleSpeechRecognition() override
;
77 void ShowForProfileByPath(const base::FilePath
& profile_path
) override
{}
78 #if defined(TOOLKIT_VIEWS)
79 views::View
* CreateStartPageWebView(const gfx::Size
& size
) override
;
80 std::vector
<views::View
*> CreateCustomPageWebViews(
81 const gfx::Size
& size
) override
;
82 void CustomLauncherPageAnimationChanged(double progress
) override
{}
83 void CustomLauncherPagePopSubpage() override
{}
85 bool IsSpeechRecognitionEnabled() override
;
86 const Users
& GetUsers() const override
;
87 bool ShouldCenterWindow() const override
;
88 void AddObserver(AppListViewDelegateObserver
* observer
) override
;
89 void RemoveObserver(AppListViewDelegateObserver
* observer
) override
;
91 // Do a bulk replacement of the items in the model.
92 void ReplaceTestModel(int item_count
);
94 AppListTestModel
* ReleaseTestModel() { return model_
.release(); }
95 AppListTestModel
* GetTestModel() { return model_
.get(); }
99 int toggle_speech_recognition_count_
;
100 int open_search_result_count_
;
101 int next_profile_app_count_
;
102 std::map
<size_t, int> open_search_result_counts_
;
104 scoped_ptr
<AppListTestModel
> model_
;
105 ObserverList
<AppListViewDelegateObserver
> observers_
;
106 SpeechUIModel speech_ui_
;
107 base::TimeDelta auto_launch_timeout_
;
109 DISALLOW_COPY_AND_ASSIGN(AppListTestViewDelegate
);
113 } // namespace app_list
115 #endif // UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_