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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/ui/views/menu_test_base.h" | 6 #include "chrome/browser/ui/views/menu_test_base.h" |
7 #include "chrome/test/base/interactive_test_utils.h" | 7 #include "chrome/test/base/interactive_test_utils.h" |
8 #include "ui/base/dragdrop/drag_drop_types.h" | 8 #include "ui/base/dragdrop/drag_drop_types.h" |
9 #include "ui/base/dragdrop/os_exchange_data.h" | 9 #include "ui/base/dragdrop/os_exchange_data.h" |
10 #include "ui/views/controls/menu/menu_controller.h" | 10 #include "ui/views/controls/menu/menu_controller.h" |
11 #include "ui/views/controls/menu/menu_item_view.h" | 11 #include "ui/views/controls/menu/menu_item_view.h" |
12 #include "ui/views/controls/menu/menu_runner.h" | 12 #include "ui/views/controls/menu/menu_runner.h" |
13 #include "ui/views/controls/menu/submenu_view.h" | 13 #include "ui/views/controls/menu/submenu_view.h" |
14 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Borrowed from chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc, | |
19 // since these are also disabled on Linux for drag and drop. | |
20 // TODO(erg): Fix DND tests on linux_aura. crbug.com/163931 | |
21 #if defined(OS_LINUX) && defined(USE_AURA) | |
22 #define MAYBE(x) DISABLED_##x | |
23 #else | |
24 #define MAYBE(x) x | |
25 #endif | |
26 | |
27 const char kTestNestedDragData[] = "test_nested_drag_data"; | 18 const char kTestNestedDragData[] = "test_nested_drag_data"; |
28 const char kTestTopLevelDragData[] = "test_top_level_drag_data"; | 19 const char kTestTopLevelDragData[] = "test_top_level_drag_data"; |
29 | 20 |
30 // A simple view which can be dragged. | 21 // A simple view which can be dragged. |
31 class TestDragView : public views::View { | 22 class TestDragView : public views::View { |
32 public: | 23 public: |
33 TestDragView(); | 24 TestDragView(); |
34 ~TestDragView() override; | 25 ~TestDragView() override; |
35 | 26 |
36 private: | 27 private: |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 EXPECT_FALSE(target_view()->dropped()); | 332 EXPECT_FALSE(target_view()->dropped()); |
342 EXPECT_FALSE(asked_to_close()); | 333 EXPECT_FALSE(asked_to_close()); |
343 EXPECT_FALSE(menu()->GetSubmenu()->IsShowing()); | 334 EXPECT_FALSE(menu()->GetSubmenu()->IsShowing()); |
344 | 335 |
345 Done(); | 336 Done(); |
346 } | 337 } |
347 | 338 |
348 // Test that an in-menu (i.e., entirely implemented in the menu code) closes the | 339 // Test that an in-menu (i.e., entirely implemented in the menu code) closes the |
349 // menu automatically once the drag is complete, and does not ask the delegate | 340 // menu automatically once the drag is complete, and does not ask the delegate |
350 // to stay open. | 341 // to stay open. |
351 #if !defined(OS_WIN) // flaky http://crbug.com/401226 | 342 // Disabled on all platforms for being flaky. Tracked in: |
352 VIEW_TEST(MenuViewDragAndDropTestTestInMenuDrag, MAYBE(TestInMenuDrag)) | 343 // TODO(erg): Fix DND tests on linux_aura. http://crbug.com/163931. |
353 #endif | 344 // Windows: http://crbug.com/401226. |
| 345 // TODO(tapted): De-flake and run on Mac. http://crbug.com/449058. |
| 346 VIEW_TEST(MenuViewDragAndDropTestTestInMenuDrag, DISABLED_TestInMenuDrag) |
354 | 347 |
355 class MenuViewDragAndDropTestNestedDrag : public MenuViewDragAndDropTest { | 348 class MenuViewDragAndDropTestNestedDrag : public MenuViewDragAndDropTest { |
356 public: | 349 public: |
357 MenuViewDragAndDropTestNestedDrag() {} | 350 MenuViewDragAndDropTestNestedDrag() {} |
358 ~MenuViewDragAndDropTestNestedDrag() override {} | 351 ~MenuViewDragAndDropTestNestedDrag() override {} |
359 | 352 |
360 private: | 353 private: |
361 // MenuViewDragAndDropTest: | 354 // MenuViewDragAndDropTest: |
362 void DoTestWithMenuOpen() override; | 355 void DoTestWithMenuOpen() override; |
363 | 356 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 434 |
442 // Clean up. | 435 // Clean up. |
443 menu()->GetSubmenu()->Close(); | 436 menu()->GetSubmenu()->Close(); |
444 | 437 |
445 Done(); | 438 Done(); |
446 } | 439 } |
447 | 440 |
448 // Test that a nested drag (i.e. one via a child view, and not entirely | 441 // Test that a nested drag (i.e. one via a child view, and not entirely |
449 // implemented in menu code) will consult the delegate before closing the view | 442 // implemented in menu code) will consult the delegate before closing the view |
450 // after the drag. | 443 // after the drag. |
451 #if !defined(OS_WIN) // http://crbug.com/401226 | 444 // Disabled on all platforms for being flaky. Tracked in: |
| 445 // TODO(erg): Fix DND tests on linux_aura. http://crbug.com/163931. |
| 446 // Windows: http://crbug.com/401226. |
| 447 // TODO(tapted): De-flake and run on Mac. http://crbug.com/449058. |
452 VIEW_TEST(MenuViewDragAndDropTestNestedDrag, | 448 VIEW_TEST(MenuViewDragAndDropTestNestedDrag, |
453 MAYBE(MenuViewDragAndDropNestedDrag)) | 449 DISABLED_MenuViewDragAndDropNestedDrag) |
454 #endif | |
455 | 450 |
456 class MenuViewDragAndDropForDropStayOpen : public MenuViewDragAndDropTest { | 451 class MenuViewDragAndDropForDropStayOpen : public MenuViewDragAndDropTest { |
457 public: | 452 public: |
458 MenuViewDragAndDropForDropStayOpen() {} | 453 MenuViewDragAndDropForDropStayOpen() {} |
459 ~MenuViewDragAndDropForDropStayOpen() override {} | 454 ~MenuViewDragAndDropForDropStayOpen() override {} |
460 | 455 |
461 private: | 456 private: |
462 // MenuViewDragAndDropTest: | 457 // MenuViewDragAndDropTest: |
463 int GetMenuRunnerFlags() override; | 458 int GetMenuRunnerFlags() override; |
464 void DoTestWithMenuOpen() override; | 459 void DoTestWithMenuOpen() override; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 views::MenuController* controller = menu()->GetMenuController(); | 504 views::MenuController* controller = menu()->GetMenuController(); |
510 ASSERT_TRUE(controller); | 505 ASSERT_TRUE(controller); |
511 EXPECT_TRUE(controller->IsCancelAllTimerRunningForTest()); | 506 EXPECT_TRUE(controller->IsCancelAllTimerRunningForTest()); |
512 | 507 |
513 Done(); | 508 Done(); |
514 } | 509 } |
515 | 510 |
516 // Test that if a menu is opened for a drop handled entirely by menu code, the | 511 // Test that if a menu is opened for a drop handled entirely by menu code, the |
517 // menu will try to close if it does not receive any drag updates. | 512 // menu will try to close if it does not receive any drag updates. |
518 VIEW_TEST(MenuViewDragAndDropForDropCancel, MenuViewCancelsForOwnDrag) | 513 VIEW_TEST(MenuViewDragAndDropForDropCancel, MenuViewCancelsForOwnDrag) |
OLD | NEW |