Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: ui/views/test/menu_test_utils.h

Issue 2654093005: Fix MenuRunner Releasing (Closed)
Patch Set: Clarification and renaming Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/menu/menu_runner_unittest.cc ('k') | ui/views/test/menu_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/test/menu_test_utils.h
diff --git a/ui/views/test/menu_test_utils.h b/ui/views/test/menu_test_utils.h
index b6718275b2cdb4143676ac3e3204b45ea61d2c1b..6a7dbfa365b123a1c37aa841a26277922d62157e 100644
--- a/ui/views/test/menu_test_utils.h
+++ b/ui/views/test/menu_test_utils.h
@@ -6,9 +6,13 @@
#define UI_VIEWS_TEST_MENU_TEST_UTILS_H_
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "ui/views/controls/menu/menu_delegate.h"
namespace views {
+
+class MenuController;
+
namespace test {
// Test implementation of MenuDelegate that tracks calls to MenuDelegate, along
@@ -52,17 +56,29 @@ class TestMenuDelegate : public MenuDelegate {
DISALLOW_COPY_AND_ASSIGN(TestMenuDelegate);
};
-// Test api which can be used to hide the active MenuController, without
-// performing normal shutdown.
+// Test api which caches the currently active MenuController. Can be used to
+// toggle visibility, and to clear seletion states, without performing full
+// shutdown. This is used to simulate menus with varing states, such as during
+// drags, without performing the entire operation. Used to test strange shutdown
+// ordering.
class MenuControllerTestApi {
public:
MenuControllerTestApi();
~MenuControllerTestApi();
- // Tells the active MenuController to consider itself not showing.
- void Hide();
+ MenuController* controller() { return controller_.get(); };
+
+ // Clears out the current and pending states, without notifying the associated
+ // menu items.
+ void ClearState();
+
+ // Toggles the internal showing state of |controller_| without attempting
+ // to change associated Widgets.
+ void SetShowing(bool showing);
private:
+ base::WeakPtr<MenuController> controller_;
+
DISALLOW_COPY_AND_ASSIGN(MenuControllerTestApi);
};
« no previous file with comments | « ui/views/controls/menu/menu_runner_unittest.cc ('k') | ui/views/test/menu_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698