| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_VIEWS_TEST_MENU_TEST_UTILS_H_ | 5 #ifndef UI_VIEWS_TEST_MENU_TEST_UTILS_H_ |
| 6 #define UI_VIEWS_TEST_MENU_TEST_UTILS_H_ | 6 #define UI_VIEWS_TEST_MENU_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 9 #include "ui/views/controls/menu/menu_delegate.h" | 10 #include "ui/views/controls/menu/menu_delegate.h" |
| 10 | 11 |
| 11 namespace views { | 12 namespace views { |
| 13 |
| 14 class MenuController; |
| 15 |
| 12 namespace test { | 16 namespace test { |
| 13 | 17 |
| 14 // Test implementation of MenuDelegate that tracks calls to MenuDelegate, along | 18 // Test implementation of MenuDelegate that tracks calls to MenuDelegate, along |
| 15 // with the provided parameters. | 19 // with the provided parameters. |
| 16 class TestMenuDelegate : public MenuDelegate { | 20 class TestMenuDelegate : public MenuDelegate { |
| 17 public: | 21 public: |
| 18 TestMenuDelegate(); | 22 TestMenuDelegate(); |
| 19 ~TestMenuDelegate() override; | 23 ~TestMenuDelegate() override; |
| 20 | 24 |
| 21 int execute_command_id() const { return execute_command_id_; } | 25 int execute_command_id() const { return execute_command_id_; } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 | 49 |
| 46 // The values of the last call to OnMenuClosed. | 50 // The values of the last call to OnMenuClosed. |
| 47 MenuItemView* on_menu_closed_menu_; | 51 MenuItemView* on_menu_closed_menu_; |
| 48 MenuRunner::RunResult on_menu_closed_run_result_; | 52 MenuRunner::RunResult on_menu_closed_run_result_; |
| 49 | 53 |
| 50 bool on_perform_drop_called_; | 54 bool on_perform_drop_called_; |
| 51 | 55 |
| 52 DISALLOW_COPY_AND_ASSIGN(TestMenuDelegate); | 56 DISALLOW_COPY_AND_ASSIGN(TestMenuDelegate); |
| 53 }; | 57 }; |
| 54 | 58 |
| 55 // Test api which can be used to hide the active MenuController, without | 59 // Test api which caches the currently active MenuController. Can be used to |
| 56 // performing normal shutdown. | 60 // toggle visibility, and to clear seletion states, without performing full |
| 61 // shutdown. This is used to simulate menus with varing states, such as during |
| 62 // drags, without performing the entire operation. Used to test strange shutdown |
| 63 // ordering. |
| 57 class MenuControllerTestApi { | 64 class MenuControllerTestApi { |
| 58 public: | 65 public: |
| 59 MenuControllerTestApi(); | 66 MenuControllerTestApi(); |
| 60 ~MenuControllerTestApi(); | 67 ~MenuControllerTestApi(); |
| 61 | 68 |
| 62 // Tells the active MenuController to consider itself not showing. | 69 MenuController* controller() { return controller_.get(); }; |
| 63 void Hide(); | 70 |
| 71 // Clears out the current and pending states, without notifying the associated |
| 72 // menu items. |
| 73 void ClearState(); |
| 74 |
| 75 // Toggles the internal showing state of |controller_| without attempting |
| 76 // to change associated Widgets. |
| 77 void SetShowing(bool showing); |
| 64 | 78 |
| 65 private: | 79 private: |
| 80 base::WeakPtr<MenuController> controller_; |
| 81 |
| 66 DISALLOW_COPY_AND_ASSIGN(MenuControllerTestApi); | 82 DISALLOW_COPY_AND_ASSIGN(MenuControllerTestApi); |
| 67 }; | 83 }; |
| 68 | 84 |
| 69 } // namespace test | 85 } // namespace test |
| 70 } // namespace views | 86 } // namespace views |
| 71 | 87 |
| 72 #endif // UI_VIEWS_TEST_MENU_TEST_UTILS_H_ | 88 #endif // UI_VIEWS_TEST_MENU_TEST_UTILS_H_ |
| OLD | NEW |