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

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

Issue 2433933007: Fix opening App Menu after Bookmarks Drag (Closed)
Patch Set: Fix additional drag shutdown orders Created 4 years, 2 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_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 451b46952853fb6a80de45a9f50ff25ec9123362..cc2e943705b1e0f8e9e3b86696b341489f96bf63 100644
--- a/ui/views/controls/menu/menu_controller_unittest.cc
+++ b/ui/views/controls/menu/menu_controller_unittest.cc
@@ -318,6 +318,21 @@ class MenuControllerTest : public ViewsTestBase {
}
#endif // defined(USE_AURA)
+ // Verifies the state of the |menu_controller_| before destroying it.
+ void VerifyDragCompleteThenDestroy() {
+ EXPECT_FALSE(menu_controller()->drag_in_progress());
+ EXPECT_EQ(MenuController::EXIT_ALL, menu_controller()->exit_type());
+ DestroyMenuController();
+ }
+
+ // Setups |menu_controller_delegate_| to be destroyed when OnMenuClosed is
+ // called.
+ void TestDragCompleteThenDestroyOnMenuClosed() {
+ menu_controller_delegate_->set_on_menu_closed_callback(
+ base::Bind(&MenuControllerTest::VerifyDragCompleteThenDestroy,
+ base::Unretained(this)));
+ }
+
void TestAsynchronousNestedExitAll() {
ASSERT_TRUE(test_message_loop_->is_running());
@@ -1096,17 +1111,34 @@ TEST_F(MenuControllerTest, AsynchronousPerformDrop) {
TEST_F(MenuControllerTest, AsynchronousDragComplete) {
MenuController* controller = menu_controller();
controller->SetAsyncRun(true);
+ TestDragCompleteThenDestroyOnMenuClosed();
controller->OnDragWillStart();
controller->OnDragComplete(true);
- EXPECT_FALSE(controller->drag_in_progress());
TestMenuControllerDelegate* controller_delegate = menu_controller_delegate();
EXPECT_EQ(1, controller_delegate->on_menu_closed_called());
EXPECT_EQ(nullptr, controller_delegate->on_menu_closed_menu());
EXPECT_EQ(internal::MenuControllerDelegate::NOTIFY_DELEGATE,
controller_delegate->on_menu_closed_notify_type());
- EXPECT_EQ(MenuController::EXIT_ALL, controller->exit_type());
+}
+
+// Tests that if Cancel is called during a drag, that OnMenuClosed is still
+// notified when the drag completes.
+TEST_F(MenuControllerTest, AsynchronousCancelDuringDrag) {
+ MenuController* controller = menu_controller();
+ controller->SetAsyncRun(true);
+ TestDragCompleteThenDestroyOnMenuClosed();
+
+ controller->OnDragWillStart();
+ controller->CancelAll();
+ controller->OnDragComplete(true);
+
+ TestMenuControllerDelegate* controller_delegate = menu_controller_delegate();
+ EXPECT_EQ(1, controller_delegate->on_menu_closed_called());
+ EXPECT_EQ(nullptr, controller_delegate->on_menu_closed_menu());
+ EXPECT_EQ(internal::MenuControllerDelegate::NOTIFY_DELEGATE,
+ controller_delegate->on_menu_closed_notify_type());
}
// Tests that if a menu is destroyed while drag operations are occuring, that
« no previous file with comments | « ui/views/controls/menu/menu_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698