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

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

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