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

Side by Side Diff: ui/views/controls/menu/menu_controller_unittest.cc

Issue 2722193003: Update MenuControllerTest Widget Creation (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 MenuItemView* run_result = 1495 MenuItemView* run_result =
1496 controller->Run(nullptr, nullptr, menu_item(), gfx::Rect(), 1496 controller->Run(nullptr, nullptr, menu_item(), gfx::Rect(),
1497 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags); 1497 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags);
1498 EXPECT_EQ(run_result, nullptr); 1498 EXPECT_EQ(run_result, nullptr);
1499 } 1499 }
1500 1500
1501 // Tests that if a MenuController is destroying during drag/drop, and another 1501 // Tests that if a MenuController is destroying during drag/drop, and another
1502 // MenuController becomes active, that the exiting of drag does not cause a 1502 // MenuController becomes active, that the exiting of drag does not cause a
1503 // crash. 1503 // crash.
1504 TEST_F(MenuControllerTest, MenuControllerReplacedDuringDrag) { 1504 TEST_F(MenuControllerTest, MenuControllerReplacedDuringDrag) {
1505 // TODO: this test wedges with aura-mus-client. http://crbug.com/664280. 1505 // Build the menu so that the appropriate root window is available to set the
1506 if (IsMus()) 1506 // drag drop client on.
1507 return; 1507 AddButtonMenuItems();
1508
1509 TestDragDropClient drag_drop_client( 1508 TestDragDropClient drag_drop_client(
1510 base::Bind(&MenuControllerTest::TestMenuControllerReplacementDuringDrag, 1509 base::Bind(&MenuControllerTest::TestMenuControllerReplacementDuringDrag,
1511 base::Unretained(this))); 1510 base::Unretained(this)));
1512 aura::client::SetDragDropClient(owner()->GetNativeWindow()->GetRootWindow(), 1511 aura::client::SetDragDropClient(menu_item()
1512 ->GetSubmenu()
1513 ->GetWidget()
1514 ->GetNativeWindow()
1515 ->GetRootWindow(),
1513 &drag_drop_client); 1516 &drag_drop_client);
1514 AddButtonMenuItems();
1515 StartDrag(); 1517 StartDrag();
1516 } 1518 }
1517 1519
1518 // Tests that if a CancelAll is called during drag-and-drop that it does not 1520 // Tests that if a CancelAll is called during drag-and-drop that it does not
1519 // destroy the MenuController. On Windows and Linux this destruction also 1521 // destroy the MenuController. On Windows and Linux this destruction also
1520 // destroys the Widget used for drag-and-drop, thereby ending the drag. 1522 // destroys the Widget used for drag-and-drop, thereby ending the drag.
1521 TEST_F(MenuControllerTest, CancelAllDuringDrag) { 1523 TEST_F(MenuControllerTest, CancelAllDuringDrag) {
1522 // TODO: this test wedges with aura-mus-client. http://crbug.com/664280.
1523 if (IsMus())
1524 return;
1525
1526 MenuController* controller = menu_controller(); 1524 MenuController* controller = menu_controller();
1527 controller->SetAsyncRun(true); 1525 controller->SetAsyncRun(true);
1528 1526
1527 // Build the menu so that the appropriate root window is available to set the
1528 // drag drop client on.
1529 AddButtonMenuItems();
1529 TestDragDropClient drag_drop_client(base::Bind( 1530 TestDragDropClient drag_drop_client(base::Bind(
1530 &MenuControllerTest::TestCancelAllDuringDrag, base::Unretained(this))); 1531 &MenuControllerTest::TestCancelAllDuringDrag, base::Unretained(this)));
1531 aura::client::SetDragDropClient(owner()->GetNativeWindow()->GetRootWindow(), 1532 aura::client::SetDragDropClient(menu_item()
1533 ->GetSubmenu()
1534 ->GetWidget()
1535 ->GetNativeWindow()
1536 ->GetRootWindow(),
1532 &drag_drop_client); 1537 &drag_drop_client);
1533 AddButtonMenuItems();
1534 StartDrag(); 1538 StartDrag();
1535 } 1539 }
1536 1540
1537 // Tests that when releasing the ref on ViewsDelegate and MenuController is 1541 // Tests that when releasing the ref on ViewsDelegate and MenuController is
1538 // deleted, that shutdown occurs without crashing. 1542 // deleted, that shutdown occurs without crashing.
1539 TEST_F(MenuControllerTest, DestroyedDuringViewsRelease) { 1543 TEST_F(MenuControllerTest, DestroyedDuringViewsRelease) {
1540 ExitMenuRun(); 1544 ExitMenuRun();
1541 MenuController* controller = menu_controller(); 1545 MenuController* controller = menu_controller();
1542 controller->SetAsyncRun(true); 1546 controller->SetAsyncRun(true);
1543 1547
1544 int mouse_event_flags = 0; 1548 int mouse_event_flags = 0;
1545 MenuItemView* run_result = 1549 MenuItemView* run_result =
1546 controller->Run(owner(), nullptr, menu_item(), gfx::Rect(), 1550 controller->Run(owner(), nullptr, menu_item(), gfx::Rect(),
1547 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags); 1551 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags);
1548 EXPECT_EQ(run_result, nullptr); 1552 EXPECT_EQ(run_result, nullptr);
1549 TestDestroyedDuringViewsRelease(); 1553 TestDestroyedDuringViewsRelease();
1550 } 1554 }
1551 1555
1552 #endif // defined(USE_AURA) 1556 #endif // defined(USE_AURA)
1553 1557
1554 } // namespace test 1558 } // namespace test
1555 } // namespace views 1559 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698