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

Unified Diff: ui/views/controls/menu/menu_controller_unittest.cc

Issue 2155243007: Turn Bookmark Menus Async (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
Index: ui/views/controls/menu/menu_controller_unittest.cc
diff --git a/ui/views/controls/menu/menu_controller_unittest.cc b/ui/views/controls/menu/menu_controller_unittest.cc
index 42a2a252e08bc57b4f9a9fce1a150ac47d20241b..5f1b78bc321d2b92dbdbfb53071c35d5dfaa0bb4 100644
--- a/ui/views/controls/menu/menu_controller_unittest.cc
+++ b/ui/views/controls/menu/menu_controller_unittest.cc
@@ -21,6 +21,7 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/views/controls/menu/menu_controller_delegate.h"
#include "ui/views/controls/menu/menu_delegate.h"
+#include "ui/views/controls/menu/menu_host.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_message_loop.h"
#include "ui/views/controls/menu/menu_scroll_view_container.h"
@@ -378,6 +379,12 @@ class MenuControllerTest : public ViewsTestBase {
bool IsShowing() { return menu_controller_->showing_; }
+ MenuHost* GetMenuHost(SubmenuView* submenu) { return submenu->host_; }
+
+ void MenuHostOnDragWillStart(MenuHost* host) { host->OnDragWillStart(); }
+
+ void MenuHostOnDragComplete(MenuHost* host) { host->OnDragComplete(); }
+
void SelectByChar(base::char16 character) {
menu_controller_->SelectByChar(character);
}
@@ -451,6 +458,8 @@ class MenuControllerTest : public ViewsTestBase {
menu_item()->GetSubmenu()->ShowAt(owner(), menu_item()->bounds(), false);
}
+ void DestroyMenuItem() { menu_item_.reset(); }
+
CustomButton* GetHotButton() {
return menu_controller_->hot_button_;
}
@@ -1019,6 +1028,21 @@ TEST_F(MenuControllerTest, AsynchronousDragComplete) {
EXPECT_EQ(MenuController::EXIT_ALL, controller->exit_type());
}
+// Tests that if a menu is destroyed while drag operations are occuring, that
+// the MenuHost does not crash as the drag completes.
+TEST_F(MenuControllerTest, AsynchronousDragHostDeleted) {
+ MenuController* controller = menu_controller();
+ controller->SetAsyncRun(true);
+
+ SubmenuView* submenu = menu_item()->GetSubmenu();
+ submenu->ShowAt(owner(), menu_item()->bounds(), false);
+ MenuHost* host = GetMenuHost(submenu);
+ MenuHostOnDragWillStart(host);
+ submenu->Close();
+ DestroyMenuItem();
+ MenuHostOnDragComplete(host);
+}
+
// Tets that an asynchronous menu nested within an asynchronous menu closes both
// menus, and notifies both delegates.
TEST_F(MenuControllerTest, DoubleAsynchronousNested) {

Powered by Google App Engine
This is Rietveld 408576698