| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_ | 5 #ifndef UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_ |
| 6 #define UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_ | 6 #define UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "ui/app_list/app_list_view_delegate.h" | 15 #include "ui/app_list/app_list_view_delegate.h" |
| 16 #include "ui/app_list/speech_ui_model.h" | 16 #include "ui/app_list/speech_ui_model.h" |
| 17 | 17 |
| 18 namespace app_list { | 18 namespace app_list { |
| 19 namespace test { | 19 namespace test { |
| 20 | 20 |
| 21 class AppListTestModel; | 21 class AppListTestModel; |
| 22 | 22 |
| 23 // A concrete AppListViewDelegate for unit tests. | 23 // A concrete AppListViewDelegate for unit tests. |
| 24 class AppListTestViewDelegate : public AppListViewDelegate { | 24 class AppListTestViewDelegate : public AppListViewDelegate { |
| 25 public: | 25 public: |
| 26 AppListTestViewDelegate(); | 26 AppListTestViewDelegate(); |
| 27 virtual ~AppListTestViewDelegate(); | 27 ~AppListTestViewDelegate() override; |
| 28 | 28 |
| 29 int dismiss_count() { return dismiss_count_; } | 29 int dismiss_count() { return dismiss_count_; } |
| 30 int open_search_result_count() { return open_search_result_count_; } | 30 int open_search_result_count() { return open_search_result_count_; } |
| 31 void SetUsers(const Users& users) { | 31 void SetUsers(const Users& users) { |
| 32 users_ = users; | 32 users_ = users; |
| 33 } | 33 } |
| 34 std::map<size_t, int> open_search_result_counts() { | 34 std::map<size_t, int> open_search_result_counts() { |
| 35 return open_search_result_counts_; | 35 return open_search_result_counts_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Sets the number of apps that the model will be created with the next time | 38 // Sets the number of apps that the model will be created with the next time |
| 39 // SetProfileByPath() is called. | 39 // SetProfileByPath() is called. |
| 40 void set_next_profile_app_count(int apps) { next_profile_app_count_ = apps; } | 40 void set_next_profile_app_count(int apps) { next_profile_app_count_ = apps; } |
| 41 | 41 |
| 42 void set_auto_launch_timeout(const base::TimeDelta& timeout) { | 42 void set_auto_launch_timeout(const base::TimeDelta& timeout) { |
| 43 auto_launch_timeout_ = timeout; | 43 auto_launch_timeout_ = timeout; |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Returns the value of |toggle_speech_recognition_count_| and then | 46 // Returns the value of |toggle_speech_recognition_count_| and then |
| 47 // resets this value to 0. | 47 // resets this value to 0. |
| 48 int GetToggleSpeechRecognitionCountAndReset(); | 48 int GetToggleSpeechRecognitionCountAndReset(); |
| 49 | 49 |
| 50 // AppListViewDelegate overrides: | 50 // AppListViewDelegate overrides: |
| 51 virtual bool ForceNativeDesktop() const override; | 51 bool ForceNativeDesktop() const override; |
| 52 virtual void SetProfileByPath(const base::FilePath& profile_path) override; | 52 void SetProfileByPath(const base::FilePath& profile_path) override; |
| 53 virtual AppListModel* GetModel() override; | 53 AppListModel* GetModel() override; |
| 54 virtual SpeechUIModel* GetSpeechUI() override; | 54 SpeechUIModel* GetSpeechUI() override; |
| 55 virtual void GetShortcutPathForApp( | 55 void GetShortcutPathForApp( |
| 56 const std::string& app_id, | 56 const std::string& app_id, |
| 57 const base::Callback<void(const base::FilePath&)>& callback) override; | 57 const base::Callback<void(const base::FilePath&)>& callback) override; |
| 58 virtual void StartSearch() override {} | 58 void StartSearch() override {} |
| 59 virtual void StopSearch() override {} | 59 void StopSearch() override {} |
| 60 virtual void OpenSearchResult(SearchResult* result, | 60 void OpenSearchResult(SearchResult* result, |
| 61 bool auto_launch, | 61 bool auto_launch, |
| 62 int event_flags) override; | 62 int event_flags) override; |
| 63 virtual void InvokeSearchResultAction(SearchResult* result, | 63 void InvokeSearchResultAction(SearchResult* result, |
| 64 int action_index, | 64 int action_index, |
| 65 int event_flags) override {} | 65 int event_flags) override {} |
| 66 virtual base::TimeDelta GetAutoLaunchTimeout() override; | 66 base::TimeDelta GetAutoLaunchTimeout() override; |
| 67 virtual void AutoLaunchCanceled() override; | 67 void AutoLaunchCanceled() override; |
| 68 virtual void ViewInitialized() override {} | 68 void ViewInitialized() override {} |
| 69 virtual void Dismiss() override; | 69 void Dismiss() override; |
| 70 virtual void ViewClosing() override {} | 70 void ViewClosing() override {} |
| 71 virtual gfx::ImageSkia GetWindowIcon() override; | 71 gfx::ImageSkia GetWindowIcon() override; |
| 72 virtual void OpenSettings() override {} | 72 void OpenSettings() override {} |
| 73 virtual void OpenHelp() override {} | 73 void OpenHelp() override {} |
| 74 virtual void OpenFeedback() override {} | 74 void OpenFeedback() override {} |
| 75 virtual void ToggleSpeechRecognition() override; | 75 void ToggleSpeechRecognition() override; |
| 76 virtual void ShowForProfileByPath( | 76 void ShowForProfileByPath(const base::FilePath& profile_path) override {} |
| 77 const base::FilePath& profile_path) override {} | |
| 78 #if defined(TOOLKIT_VIEWS) | 77 #if defined(TOOLKIT_VIEWS) |
| 79 virtual views::View* CreateStartPageWebView(const gfx::Size& size) override; | 78 virtual views::View* CreateStartPageWebView(const gfx::Size& size) override; |
| 80 virtual std::vector<views::View*> CreateCustomPageWebViews( | 79 virtual std::vector<views::View*> CreateCustomPageWebViews( |
| 81 const gfx::Size& size) override; | 80 const gfx::Size& size) override; |
| 82 #endif | 81 #endif |
| 83 virtual bool IsSpeechRecognitionEnabled() override; | 82 bool IsSpeechRecognitionEnabled() override; |
| 84 virtual const Users& GetUsers() const override; | 83 const Users& GetUsers() const override; |
| 85 virtual bool ShouldCenterWindow() const override; | 84 bool ShouldCenterWindow() const override; |
| 86 virtual void AddObserver(AppListViewDelegateObserver* observer) override; | 85 void AddObserver(AppListViewDelegateObserver* observer) override; |
| 87 virtual void RemoveObserver(AppListViewDelegateObserver* observer) override; | 86 void RemoveObserver(AppListViewDelegateObserver* observer) override; |
| 88 | 87 |
| 89 // Do a bulk replacement of the items in the model. | 88 // Do a bulk replacement of the items in the model. |
| 90 void ReplaceTestModel(int item_count); | 89 void ReplaceTestModel(int item_count); |
| 91 | 90 |
| 92 AppListTestModel* ReleaseTestModel() { return model_.release(); } | 91 AppListTestModel* ReleaseTestModel() { return model_.release(); } |
| 93 AppListTestModel* GetTestModel() { return model_.get(); } | 92 AppListTestModel* GetTestModel() { return model_.get(); } |
| 94 | 93 |
| 95 private: | 94 private: |
| 96 int dismiss_count_; | 95 int dismiss_count_; |
| 97 int toggle_speech_recognition_count_; | 96 int toggle_speech_recognition_count_; |
| 98 int open_search_result_count_; | 97 int open_search_result_count_; |
| 99 int next_profile_app_count_; | 98 int next_profile_app_count_; |
| 100 std::map<size_t, int> open_search_result_counts_; | 99 std::map<size_t, int> open_search_result_counts_; |
| 101 Users users_; | 100 Users users_; |
| 102 scoped_ptr<AppListTestModel> model_; | 101 scoped_ptr<AppListTestModel> model_; |
| 103 ObserverList<AppListViewDelegateObserver> observers_; | 102 ObserverList<AppListViewDelegateObserver> observers_; |
| 104 SpeechUIModel speech_ui_; | 103 SpeechUIModel speech_ui_; |
| 105 base::TimeDelta auto_launch_timeout_; | 104 base::TimeDelta auto_launch_timeout_; |
| 106 | 105 |
| 107 DISALLOW_COPY_AND_ASSIGN(AppListTestViewDelegate); | 106 DISALLOW_COPY_AND_ASSIGN(AppListTestViewDelegate); |
| 108 }; | 107 }; |
| 109 | 108 |
| 110 } // namespace test | 109 } // namespace test |
| 111 } // namespace app_list | 110 } // namespace app_list |
| 112 | 111 |
| 113 #endif // UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_ | 112 #endif // UI_APP_LIST_TEST_APP_LIST_TEST_VIEW_DELEGATE_H_ |
| OLD | NEW |