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

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

Issue 1915363002: Rename gfx::Display/Screen to display::Display/Screen in views/wm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanups Created 4 years, 8 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
« no previous file with comments | « ui/views/controls/button/custom_button.cc ('k') | ui/views/controls/button/menu_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 12 #include "ui/base/material_design/material_design_controller.h"
13 #include "ui/display/screen.h"
13 #include "ui/events/event_utils.h" 14 #include "ui/events/event_utils.h"
14 #include "ui/events/test/event_generator.h" 15 #include "ui/events/test/event_generator.h"
15 #include "ui/gfx/screen.h"
16 #include "ui/views/animation/ink_drop_delegate.h" 16 #include "ui/views/animation/ink_drop_delegate.h"
17 #include "ui/views/animation/ink_drop_host.h" 17 #include "ui/views/animation/ink_drop_host.h"
18 #include "ui/views/animation/test/test_ink_drop_delegate.h" 18 #include "ui/views/animation/test/test_ink_drop_delegate.h"
19 #include "ui/views/animation/test/test_ink_drop_host.h" 19 #include "ui/views/animation/test/test_ink_drop_host.h"
20 #include "ui/views/context_menu_controller.h" 20 #include "ui/views/context_menu_controller.h"
21 #include "ui/views/controls/button/checkbox.h" 21 #include "ui/views/controls/button/checkbox.h"
22 #include "ui/views/controls/button/image_button.h" 22 #include "ui/views/controls/button/image_button.h"
23 #include "ui/views/controls/button/label_button.h" 23 #include "ui/views/controls/button/label_button.h"
24 #include "ui/views/controls/button/menu_button.h" 24 #include "ui/views/controls/button/menu_button.h"
25 #include "ui/views/controls/button/radio_button.h" 25 #include "ui/views/controls/button/radio_button.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 Textfield textfield; 386 Textfield textfield;
387 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); 387 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield));
388 } 388 }
389 389
390 // Tests that pressing a button shows the ink drop and releasing the button 390 // Tests that pressing a button shows the ink drop and releasing the button
391 // does not hide the ink drop. 391 // does not hide the ink drop.
392 // Note: Ink drop is not hidden upon release because CustomButton descendants 392 // Note: Ink drop is not hidden upon release because CustomButton descendants
393 // may enter a different ink drop state. 393 // may enter a different ink drop state.
394 TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) { 394 TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) {
395 gfx::Point old_cursor = gfx::Screen::GetScreen()->GetCursorScreenPoint(); 395 gfx::Point old_cursor = display::Screen::GetScreen()->GetCursorScreenPoint();
396 bool ink_shown = false; 396 bool ink_shown = false;
397 bool ink_hidden = false; 397 bool ink_hidden = false;
398 CreateButtonWithInkDrop(base::WrapUnique( 398 CreateButtonWithInkDrop(base::WrapUnique(
399 new TestInkDropDelegateThatTracksVisibilty(&ink_shown, &ink_hidden))); 399 new TestInkDropDelegateThatTracksVisibilty(&ink_shown, &ink_hidden)));
400 400
401 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); 401 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
402 generator.set_current_location(gfx::Point(50, 50)); 402 generator.set_current_location(gfx::Point(50, 50));
403 generator.PressLeftButton(); 403 generator.PressLeftButton();
404 EXPECT_TRUE(ink_shown); 404 EXPECT_TRUE(ink_shown);
405 EXPECT_FALSE(ink_hidden); 405 EXPECT_FALSE(ink_hidden);
406 406
407 generator.ReleaseLeftButton(); 407 generator.ReleaseLeftButton();
408 EXPECT_FALSE(ink_hidden); 408 EXPECT_FALSE(ink_hidden);
409 } 409 }
410 410
411 // Tests that pressing a button shows and releasing capture hides ink drop. 411 // Tests that pressing a button shows and releasing capture hides ink drop.
412 // Releasing capture should also reset PRESSED button state to NORMAL. 412 // Releasing capture should also reset PRESSED button state to NORMAL.
413 TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) { 413 TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) {
414 gfx::Point old_cursor = gfx::Screen::GetScreen()->GetCursorScreenPoint(); 414 gfx::Point old_cursor = display::Screen::GetScreen()->GetCursorScreenPoint();
415 bool ink_shown = false; 415 bool ink_shown = false;
416 bool ink_hidden = false; 416 bool ink_hidden = false;
417 CreateButtonWithInkDrop(base::WrapUnique( 417 CreateButtonWithInkDrop(base::WrapUnique(
418 new TestInkDropDelegateThatTracksVisibilty(&ink_shown, &ink_hidden))); 418 new TestInkDropDelegateThatTracksVisibilty(&ink_shown, &ink_hidden)));
419 419
420 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); 420 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
421 generator.set_current_location(gfx::Point(50, 50)); 421 generator.set_current_location(gfx::Point(50, 50));
422 generator.PressLeftButton(); 422 generator.PressLeftButton();
423 EXPECT_TRUE(ink_shown); 423 EXPECT_TRUE(ink_shown);
424 EXPECT_FALSE(ink_hidden); 424 EXPECT_FALSE(ink_hidden);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 ink_drop_delegate->SetHovered(true); 475 ink_drop_delegate->SetHovered(true);
476 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING); 476 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
477 477
478 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); 478 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
479 479
480 EXPECT_TRUE(ink_drop_delegate->is_hovered()); 480 EXPECT_TRUE(ink_drop_delegate->is_hovered());
481 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop_delegate->state()); 481 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop_delegate->state());
482 } 482 }
483 483
484 } // namespace views 484 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.cc ('k') | ui/views/controls/button/menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698