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

Side by Side Diff: ui/views/controls/button/menu_button_unittest.cc

Issue 2488393003: Changes views_aura_mus_unittests to create DesktopNativeWidgetAura (Closed)
Patch Set: remove this and fix mac Created 4 years, 1 month 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
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/button/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 EXPECT_EQ(button(), menu_button_listener.last_source()); 338 EXPECT_EQ(button(), menu_button_listener.last_source());
339 EXPECT_EQ(Button::STATE_HOVERED, menu_button_listener.last_source_state()); 339 EXPECT_EQ(Button::STATE_HOVERED, menu_button_listener.last_source_state());
340 } 340 }
341 341
342 // Test that the MenuButton stays pressed while there are any PressedLocks. 342 // Test that the MenuButton stays pressed while there are any PressedLocks.
343 TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) { 343 TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
344 // Hovered-state is not updated under mus when EventGenerator send a 344 // Hovered-state is not updated under mus when EventGenerator send a
345 // mouse-move event. https://crbug.com/615033 345 // mouse-move event. https://crbug.com/615033
346 if (IsMus()) 346 if (IsMus())
347 return; 347 return;
348
349 // Similarly for aura-mus-client the location of the cursor is not updated by
350 // EventGenerator so that IsMouseHovered() checks the wrong thing.
351 // https://crbug.com/615033.
352 if (IsAuraMusClient())
353 return;
354
348 CreateMenuButtonWithNoListener(); 355 CreateMenuButtonWithNoListener();
349 356
350 // Move the mouse over the button; the button should be in a hovered state. 357 // Move the mouse over the button; the button should be in a hovered state.
351 generator()->MoveMouseTo(gfx::Point(10, 10)); 358 generator()->MoveMouseTo(gfx::Point(10, 10));
352 EXPECT_EQ(Button::STATE_HOVERED, button()->state()); 359 EXPECT_EQ(Button::STATE_HOVERED, button()->state());
353 360
354 // Introduce a PressedLock, which should make the button pressed. 361 // Introduce a PressedLock, which should make the button pressed.
355 std::unique_ptr<MenuButton::PressedLock> pressed_lock1( 362 std::unique_ptr<MenuButton::PressedLock> pressed_lock1(
356 new MenuButton::PressedLock(button())); 363 new MenuButton::PressedLock(button()));
357 EXPECT_EQ(Button::STATE_PRESSED, button()->state()); 364 EXPECT_EQ(Button::STATE_PRESSED, button()->state());
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 537
531 #if defined(USE_AURA) 538 #if defined(USE_AURA)
532 539
533 // Tests that the MenuButton does not become pressed if it can be dragged, and a 540 // Tests that the MenuButton does not become pressed if it can be dragged, and a
534 // DragDropClient is processing the events. 541 // DragDropClient is processing the events.
535 TEST_F(MenuButtonTest, DraggableMenuButtonDoesNotActivateOnDrag) { 542 TEST_F(MenuButtonTest, DraggableMenuButtonDoesNotActivateOnDrag) {
536 // The test uses drag-n-drop, which isn't yet supported on mus. 543 // The test uses drag-n-drop, which isn't yet supported on mus.
537 // https://crbug.com/614037. 544 // https://crbug.com/614037.
538 if (IsMus()) 545 if (IsMus())
539 return; 546 return;
547 // TODO: test uses GetContext(), which is not applicable to aura-mus.
548 // http://crbug.com/663809.
549 if (IsAuraMusClient())
550 return;
540 TestMenuButtonListener menu_button_listener; 551 TestMenuButtonListener menu_button_listener;
541 CreateMenuButtonWithMenuButtonListener(&menu_button_listener); 552 CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
542 TestDragController drag_controller; 553 TestDragController drag_controller;
543 button()->set_drag_controller(&drag_controller); 554 button()->set_drag_controller(&drag_controller);
544 555
545 TestDragDropClient drag_client; 556 TestDragDropClient drag_client;
546 SetDragDropClient(GetContext(), &drag_client); 557 SetDragDropClient(GetContext(), &drag_client);
547 button()->PrependPreTargetHandler(&drag_client); 558 button()->PrependPreTargetHandler(&drag_client);
548 559
549 generator()->DragMouseBy(10, 0); 560 generator()->DragMouseBy(10, 0);
550 EXPECT_EQ(nullptr, menu_button_listener.last_source()); 561 EXPECT_EQ(nullptr, menu_button_listener.last_source());
551 EXPECT_EQ(Button::STATE_NORMAL, menu_button_listener.last_source_state()); 562 EXPECT_EQ(Button::STATE_NORMAL, menu_button_listener.last_source_state());
552 } 563 }
553 564
554 #endif // USE_AURA 565 #endif // USE_AURA
555 566
556 // No touch on desktop Mac. Tracked in http://crbug.com/445520. 567 // No touch on desktop Mac. Tracked in http://crbug.com/445520.
557 #if !defined(OS_MACOSX) || defined(USE_AURA) 568 #if !defined(OS_MACOSX) || defined(USE_AURA)
558 569
559 // Tests if the listener is notified correctly when a gesture tap happens on a 570 // Tests if the listener is notified correctly when a gesture tap happens on a
560 // MenuButton that has a MenuButtonListener. 571 // MenuButton that has a MenuButtonListener.
561 TEST_F(MenuButtonTest, ActivateDropDownOnGestureTap) { 572 TEST_F(MenuButtonTest, ActivateDropDownOnGestureTap) {
562 // Hovered-state is not updated under mus when EventGenerator send a 573 // Hovered-state is not updated under mus when EventGenerator send a
563 // mouse-move event. https://crbug.com/615033 574 // mouse-move event. https://crbug.com/615033
564 if (IsMus()) 575 if (IsMus())
565 return; 576 return;
577 // Similarly for aura-mus-client the location of the cursor is not updated by
578 // EventGenerator so that IsMouseHovered() checks the wrong thing.
579 // https://crbug.com/615033.
580 if (IsAuraMusClient())
581 return;
566 TestMenuButtonListener menu_button_listener; 582 TestMenuButtonListener menu_button_listener;
567 CreateMenuButtonWithMenuButtonListener(&menu_button_listener); 583 CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
568 584
569 // Move the mouse outside the menu button so that it doesn't impact the 585 // Move the mouse outside the menu button so that it doesn't impact the
570 // button state. 586 // button state.
571 generator()->MoveMouseTo(400, 400); 587 generator()->MoveMouseTo(400, 400);
572 EXPECT_FALSE(button()->IsMouseHovered()); 588 EXPECT_FALSE(button()->IsMouseHovered());
573 589
574 generator()->GestureTapAt(gfx::Point(10, 10)); 590 generator()->GestureTapAt(gfx::Point(10, 10));
575 591
(...skipping 28 matching lines...) Expand all
604 620
605 generator()->MoveTouch(gfx::Point(10, 30)); 621 generator()->MoveTouch(gfx::Point(10, 30));
606 generator()->ReleaseTouch(); 622 generator()->ReleaseTouch();
607 EXPECT_EQ(Button::STATE_NORMAL, button()->state()); 623 EXPECT_EQ(Button::STATE_NORMAL, button()->state());
608 EXPECT_EQ(nullptr, menu_button_listener.last_source()); 624 EXPECT_EQ(nullptr, menu_button_listener.last_source());
609 } 625 }
610 626
611 #endif // !defined(OS_MACOSX) || defined(USE_AURA) 627 #endif // !defined(OS_MACOSX) || defined(USE_AURA)
612 628
613 } // namespace views 629 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/accessible_pane_view_unittest.cc ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698