Chromium Code Reviews| 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, | 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. | 19 // since these are also disabled on Linux for drag and drop. |
| 20 // TODO(erg): Fix DND tests on linux_aura. crbug.com/163931 | 20 // TODO(erg): Fix DND tests on linux_aura. crbug.com/163931 |
| 21 #if defined(OS_LINUX) && defined(USE_AURA) | 21 // Windows: Flaky. http://crbug.com/401226 |
| 22 // MacViews: Enable these tests if they get fixed. https://crbug.com/449058 | |
| 23 #if defined(OS_LINUX) && defined(USE_AURA) || defined(OS_WIN) || defined(OS_MACO SX) | |
|
tapted
2015/01/15 06:38:07
Since this is basically #if (true)... we might as
jackhou1
2015/01/15 06:53:28
Done.
| |
| 22 #define MAYBE(x) DISABLED_##x | 24 #define MAYBE(x) DISABLED_##x |
| 23 #else | 25 #else |
| 24 #define MAYBE(x) x | 26 #define MAYBE(x) x |
| 25 #endif | 27 #endif |
| 26 | 28 |
| 27 const char kTestNestedDragData[] = "test_nested_drag_data"; | 29 const char kTestNestedDragData[] = "test_nested_drag_data"; |
| 28 const char kTestTopLevelDragData[] = "test_top_level_drag_data"; | 30 const char kTestTopLevelDragData[] = "test_top_level_drag_data"; |
| 29 | 31 |
| 30 // A simple view which can be dragged. | 32 // A simple view which can be dragged. |
| 31 class TestDragView : public views::View { | 33 class TestDragView : public views::View { |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 EXPECT_FALSE(target_view()->dropped()); | 343 EXPECT_FALSE(target_view()->dropped()); |
| 342 EXPECT_FALSE(asked_to_close()); | 344 EXPECT_FALSE(asked_to_close()); |
| 343 EXPECT_FALSE(menu()->GetSubmenu()->IsShowing()); | 345 EXPECT_FALSE(menu()->GetSubmenu()->IsShowing()); |
| 344 | 346 |
| 345 Done(); | 347 Done(); |
| 346 } | 348 } |
| 347 | 349 |
| 348 // Test that an in-menu (i.e., entirely implemented in the menu code) closes the | 350 // 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 | 351 // menu automatically once the drag is complete, and does not ask the delegate |
| 350 // to stay open. | 352 // to stay open. |
| 351 #if !defined(OS_WIN) // flaky http://crbug.com/401226 | |
| 352 VIEW_TEST(MenuViewDragAndDropTestTestInMenuDrag, MAYBE(TestInMenuDrag)) | 353 VIEW_TEST(MenuViewDragAndDropTestTestInMenuDrag, MAYBE(TestInMenuDrag)) |
| 353 #endif | |
| 354 | 354 |
| 355 class MenuViewDragAndDropTestNestedDrag : public MenuViewDragAndDropTest { | 355 class MenuViewDragAndDropTestNestedDrag : public MenuViewDragAndDropTest { |
| 356 public: | 356 public: |
| 357 MenuViewDragAndDropTestNestedDrag() {} | 357 MenuViewDragAndDropTestNestedDrag() {} |
| 358 ~MenuViewDragAndDropTestNestedDrag() override {} | 358 ~MenuViewDragAndDropTestNestedDrag() override {} |
| 359 | 359 |
| 360 private: | 360 private: |
| 361 // MenuViewDragAndDropTest: | 361 // MenuViewDragAndDropTest: |
| 362 void DoTestWithMenuOpen() override; | 362 void DoTestWithMenuOpen() override; |
| 363 | 363 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 | 441 |
| 442 // Clean up. | 442 // Clean up. |
| 443 menu()->GetSubmenu()->Close(); | 443 menu()->GetSubmenu()->Close(); |
| 444 | 444 |
| 445 Done(); | 445 Done(); |
| 446 } | 446 } |
| 447 | 447 |
| 448 // Test that a nested drag (i.e. one via a child view, and not entirely | 448 // 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 | 449 // implemented in menu code) will consult the delegate before closing the view |
| 450 // after the drag. | 450 // after the drag. |
| 451 #if !defined(OS_WIN) // http://crbug.com/401226 | |
| 452 VIEW_TEST(MenuViewDragAndDropTestNestedDrag, | 451 VIEW_TEST(MenuViewDragAndDropTestNestedDrag, |
| 453 MAYBE(MenuViewDragAndDropNestedDrag)) | 452 MAYBE(MenuViewDragAndDropNestedDrag)) |
| 454 #endif | |
| 455 | 453 |
| 456 class MenuViewDragAndDropForDropStayOpen : public MenuViewDragAndDropTest { | 454 class MenuViewDragAndDropForDropStayOpen : public MenuViewDragAndDropTest { |
| 457 public: | 455 public: |
| 458 MenuViewDragAndDropForDropStayOpen() {} | 456 MenuViewDragAndDropForDropStayOpen() {} |
| 459 ~MenuViewDragAndDropForDropStayOpen() override {} | 457 ~MenuViewDragAndDropForDropStayOpen() override {} |
| 460 | 458 |
| 461 private: | 459 private: |
| 462 // MenuViewDragAndDropTest: | 460 // MenuViewDragAndDropTest: |
| 463 int GetMenuRunnerFlags() override; | 461 int GetMenuRunnerFlags() override; |
| 464 void DoTestWithMenuOpen() override; | 462 void DoTestWithMenuOpen() override; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 views::MenuController* controller = menu()->GetMenuController(); | 507 views::MenuController* controller = menu()->GetMenuController(); |
| 510 ASSERT_TRUE(controller); | 508 ASSERT_TRUE(controller); |
| 511 EXPECT_TRUE(controller->IsCancelAllTimerRunningForTest()); | 509 EXPECT_TRUE(controller->IsCancelAllTimerRunningForTest()); |
| 512 | 510 |
| 513 Done(); | 511 Done(); |
| 514 } | 512 } |
| 515 | 513 |
| 516 // Test that if a menu is opened for a drop handled entirely by menu code, the | 514 // 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. | 515 // menu will try to close if it does not receive any drag updates. |
| 518 VIEW_TEST(MenuViewDragAndDropForDropCancel, MenuViewCancelsForOwnDrag) | 516 VIEW_TEST(MenuViewDragAndDropForDropCancel, MenuViewCancelsForOwnDrag) |
| OLD | NEW |