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

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

Issue 2389453002: Remove IsModeMaterial checks in ui/views/ (Closed)
Patch Set: oops Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/base/layout.h" 11 #include "ui/base/layout.h"
12 #include "ui/base/material_design/material_design_controller.h"
13 #include "ui/display/screen.h" 12 #include "ui/display/screen.h"
14 #include "ui/events/event_utils.h" 13 #include "ui/events/event_utils.h"
15 #include "ui/events/test/event_generator.h" 14 #include "ui/events/test/event_generator.h"
16 #include "ui/views/animation/ink_drop_host.h" 15 #include "ui/views/animation/ink_drop_host.h"
17 #include "ui/views/animation/test/ink_drop_host_view_test_api.h" 16 #include "ui/views/animation/test/ink_drop_host_view_test_api.h"
18 #include "ui/views/animation/test/test_ink_drop.h" 17 #include "ui/views/animation/test/test_ink_drop.h"
19 #include "ui/views/animation/test/test_ink_drop_host.h" 18 #include "ui/views/animation/test/test_ink_drop_host.h"
20 #include "ui/views/context_menu_controller.h" 19 #include "ui/views/context_menu_controller.h"
21 #include "ui/views/controls/button/checkbox.h" 20 #include "ui/views/controls/button/checkbox.h"
22 #include "ui/views/controls/button/image_button.h" 21 #include "ui/views/controls/button/image_button.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 generator.set_current_location(gfx::Point(50, 50)); 372 generator.set_current_location(gfx::Point(50, 50));
374 generator.PressLeftButton(); 373 generator.PressLeftButton();
375 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); 374 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState());
376 375
377 EXPECT_EQ(Button::ButtonState::STATE_PRESSED, button()->state()); 376 EXPECT_EQ(Button::ButtonState::STATE_PRESSED, button()->state());
378 SetDraggedView(button()); 377 SetDraggedView(button());
379 widget()->SetCapture(button()); 378 widget()->SetCapture(button());
380 widget()->ReleaseCapture(); 379 widget()->ReleaseCapture();
381 SetDraggedView(nullptr); 380 SetDraggedView(nullptr);
382 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); 381 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState());
383 EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial() 382 EXPECT_EQ(Button::ButtonState::STATE_NORMAL, button()->state());
384 ? Button::ButtonState::STATE_NORMAL
385 : Button::ButtonState::STATE_PRESSED,
386 button()->state());
387 } 383 }
388 384
389 TEST_F(CustomButtonTest, HideInkDropWhenShowingContextMenu) { 385 TEST_F(CustomButtonTest, HideInkDropWhenShowingContextMenu) {
390 TestInkDrop* ink_drop = new TestInkDrop(); 386 TestInkDrop* ink_drop = new TestInkDrop();
391 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); 387 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
392 TestContextMenuController context_menu_controller; 388 TestContextMenuController context_menu_controller;
393 button()->set_context_menu_controller(&context_menu_controller); 389 button()->set_context_menu_controller(&context_menu_controller);
394 button()->set_hide_ink_drop_when_showing_context_menu(true); 390 button()->set_hide_ink_drop_when_showing_context_menu(true);
395 391
396 ink_drop->SetHovered(true); 392 ink_drop->SetHovered(true);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); 581 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state());
586 EXPECT_FALSE(button()->pressed()); 582 EXPECT_FALSE(button()->pressed());
587 583
588 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE); 584 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE);
589 SimulateKeyEvent(&space_release); 585 SimulateKeyEvent(&space_release);
590 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); 586 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state());
591 EXPECT_TRUE(button()->pressed()); 587 EXPECT_TRUE(button()->pressed());
592 } 588 }
593 589
594 } // namespace views 590 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698