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_
11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h"
15 #include "ui/app_list/app_list_view_delegate.h"
16 #include "ui/app_list/speech_ui_model.h"
21 class AppListTestModel;
22 class TestSigninDelegate;
24 // A concrete AppListViewDelegate for unit tests.
25 class AppListTestViewDelegate : public AppListViewDelegate {
27 AppListTestViewDelegate();
28 virtual ~AppListTestViewDelegate();
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 void set_auto_launch_timeout(const base::TimeDelta& timeout) {
40 auto_launch_timeout_ = timeout;
43 // Sets the signin status of the signin delegate, creating one if there isn't
45 void SetSignedIn(bool signed_in);
47 // AppListViewDelegate overrides:
48 virtual bool ForceNativeDesktop() const OVERRIDE;
49 virtual void SetProfileByPath(const base::FilePath& profile_path) OVERRIDE {}
50 virtual AppListModel* GetModel() OVERRIDE;
51 virtual SigninDelegate* GetSigninDelegate() OVERRIDE;
52 virtual SpeechUIModel* GetSpeechUI() OVERRIDE;
53 virtual void GetShortcutPathForApp(
54 const std::string& app_id,
55 const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE;
56 virtual void StartSearch() OVERRIDE {}
57 virtual void StopSearch() OVERRIDE {}
58 virtual void OpenSearchResult(SearchResult* result,
60 int event_flags) OVERRIDE;
61 virtual void InvokeSearchResultAction(SearchResult* result,
63 int event_flags) OVERRIDE {}
64 virtual base::TimeDelta GetAutoLaunchTimeout() OVERRIDE;
65 virtual void AutoLaunchCanceled() OVERRIDE;
66 virtual void ViewInitialized() OVERRIDE {}
67 virtual void Dismiss() OVERRIDE;
68 virtual void ViewClosing() OVERRIDE {}
69 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
70 virtual void OpenSettings() OVERRIDE {}
71 virtual void OpenHelp() OVERRIDE {}
72 virtual void OpenFeedback() OVERRIDE {}
73 virtual void ToggleSpeechRecognition() OVERRIDE {}
74 virtual void ShowForProfileByPath(
75 const base::FilePath& profile_path) OVERRIDE {}
76 virtual content::WebContents* GetStartPageContents() OVERRIDE;
77 virtual content::WebContents* GetSpeechRecognitionContents() OVERRIDE;
78 virtual const Users& GetUsers() const OVERRIDE;
79 virtual bool ShouldCenterWindow() const OVERRIDE;
80 virtual void AddObserver(AppListViewDelegateObserver* observer) OVERRIDE;
81 virtual void RemoveObserver(AppListViewDelegateObserver* observer) OVERRIDE;
83 // Do a bulk replacement of the items in the model.
84 void ReplaceTestModel(int item_count);
86 AppListTestModel* ReleaseTestModel() { return model_.release(); }
87 AppListTestModel* GetTestModel() { return model_.get(); }
91 int open_search_result_count_;
92 std::map<size_t, int> open_search_result_counts_;
94 scoped_ptr<TestSigninDelegate> test_signin_delegate_;
95 scoped_ptr<AppListTestModel> model_;
96 ObserverList<AppListViewDelegateObserver> observers_;
97 SpeechUIModel speech_ui_;
98 base::TimeDelta auto_launch_timeout_;
100 DISALLOW_COPY_AND_ASSIGN(AppListTestViewDelegate);
104 } // namespace app_list
106 #endif // UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_