OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 controller->Run(nullptr, nullptr, menu_item(), gfx::Rect(), | 1420 controller->Run(nullptr, nullptr, menu_item(), gfx::Rect(), |
1421 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags); | 1421 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags); |
1422 EXPECT_EQ(run_result, nullptr); | 1422 EXPECT_EQ(run_result, nullptr); |
1423 } | 1423 } |
1424 | 1424 |
1425 // Tests that if a MenuController is destroying during drag/drop, and another | 1425 // Tests that if a MenuController is destroying during drag/drop, and another |
1426 // MenuController becomes active, that the exiting of drag does not cause a | 1426 // MenuController becomes active, that the exiting of drag does not cause a |
1427 // crash. | 1427 // crash. |
1428 TEST_F(MenuControllerTest, MenuControllerReplacedDuringDrag) { | 1428 TEST_F(MenuControllerTest, MenuControllerReplacedDuringDrag) { |
1429 // TODO: this test wedges with aura-mus-client. http://crbug.com/664280. | 1429 // TODO: this test wedges with aura-mus-client. http://crbug.com/664280. |
1430 if (IsAuraMusClient()) | |
1431 return; | |
1432 | |
1433 // This test creates two native widgets, but expects the child native widget | |
1434 // to be able to reach up and use the parent native widget's aura | |
1435 // objects. https://crbug.com/614037 | |
1436 if (IsMus()) | 1430 if (IsMus()) |
1437 return; | 1431 return; |
1438 | 1432 |
1439 TestDragDropClient drag_drop_client( | 1433 TestDragDropClient drag_drop_client( |
1440 base::Bind(&MenuControllerTest::TestMenuControllerReplacementDuringDrag, | 1434 base::Bind(&MenuControllerTest::TestMenuControllerReplacementDuringDrag, |
1441 base::Unretained(this))); | 1435 base::Unretained(this))); |
1442 aura::client::SetDragDropClient(owner()->GetNativeWindow()->GetRootWindow(), | 1436 aura::client::SetDragDropClient(owner()->GetNativeWindow()->GetRootWindow(), |
1443 &drag_drop_client); | 1437 &drag_drop_client); |
1444 AddButtonMenuItems(); | 1438 AddButtonMenuItems(); |
1445 StartDrag(); | 1439 StartDrag(); |
1446 } | 1440 } |
1447 | 1441 |
1448 // Tests that if a CancelAll is called during drag-and-drop that it does not | 1442 // Tests that if a CancelAll is called during drag-and-drop that it does not |
1449 // destroy the MenuController. On Windows and Linux this destruction also | 1443 // destroy the MenuController. On Windows and Linux this destruction also |
1450 // destroys the Widget used for drag-and-drop, thereby ending the drag. | 1444 // destroys the Widget used for drag-and-drop, thereby ending the drag. |
1451 TEST_F(MenuControllerTest, CancelAllDuringDrag) { | 1445 TEST_F(MenuControllerTest, CancelAllDuringDrag) { |
1452 // TODO: this test wedges with aura-mus-client. http://crbug.com/664280. | 1446 // TODO: this test wedges with aura-mus-client. http://crbug.com/664280. |
1453 if (IsAuraMusClient()) | |
1454 return; | |
1455 | |
1456 // This test creates two native widgets, but expects the child native widget | |
1457 // to be able to reach up and use the parent native widget's aura | |
1458 // objects. https://crbug.com/614037 | |
1459 if (IsMus()) | 1447 if (IsMus()) |
1460 return; | 1448 return; |
1461 | 1449 |
1462 MenuController* controller = menu_controller(); | 1450 MenuController* controller = menu_controller(); |
1463 controller->SetAsyncRun(true); | 1451 controller->SetAsyncRun(true); |
1464 | 1452 |
1465 TestDragDropClient drag_drop_client(base::Bind( | 1453 TestDragDropClient drag_drop_client(base::Bind( |
1466 &MenuControllerTest::TestCancelAllDuringDrag, base::Unretained(this))); | 1454 &MenuControllerTest::TestCancelAllDuringDrag, base::Unretained(this))); |
1467 aura::client::SetDragDropClient(owner()->GetNativeWindow()->GetRootWindow(), | 1455 aura::client::SetDragDropClient(owner()->GetNativeWindow()->GetRootWindow(), |
1468 &drag_drop_client); | 1456 &drag_drop_client); |
1469 AddButtonMenuItems(); | 1457 AddButtonMenuItems(); |
1470 StartDrag(); | 1458 StartDrag(); |
1471 } | 1459 } |
1472 | 1460 |
1473 #endif // defined(USE_AURA) | 1461 #endif // defined(USE_AURA) |
1474 | 1462 |
1475 } // namespace test | 1463 } // namespace test |
1476 } // namespace views | 1464 } // namespace views |
OLD | NEW |