| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/corewm/tooltip_controller.h" | 5 #include "ui/views/corewm/tooltip_controller.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
| 11 #include "ui/aura/client/screen_position_client.h" | 11 #include "ui/aura/client/screen_position_client.h" |
| 12 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 13 #include "ui/aura/test/aura_test_base.h" | 13 #include "ui/aura/test/aura_test_base.h" |
| 14 #include "ui/aura/test/test_screen.h" | 14 #include "ui/aura/test/test_screen.h" |
| 15 #include "ui/aura/test/test_window_delegate.h" | 15 #include "ui/aura/test/test_window_delegate.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
| 18 #include "ui/display/screen.h" |
| 18 #include "ui/events/test/event_generator.h" | 19 #include "ui/events/test/event_generator.h" |
| 19 #include "ui/gfx/font.h" | 20 #include "ui/gfx/font.h" |
| 20 #include "ui/gfx/geometry/point.h" | 21 #include "ui/gfx/geometry/point.h" |
| 21 #include "ui/gfx/screen.h" | |
| 22 #include "ui/gfx/text_elider.h" | 22 #include "ui/gfx/text_elider.h" |
| 23 #include "ui/views/corewm/tooltip_aura.h" | 23 #include "ui/views/corewm/tooltip_aura.h" |
| 24 #include "ui/views/corewm/tooltip_controller_test_helper.h" | 24 #include "ui/views/corewm/tooltip_controller_test_helper.h" |
| 25 #include "ui/views/test/desktop_test_views_delegate.h" | 25 #include "ui/views/test/desktop_test_views_delegate.h" |
| 26 #include "ui/views/test/test_views_delegate.h" | 26 #include "ui/views/test/test_views_delegate.h" |
| 27 #include "ui/views/view.h" | 27 #include "ui/views/view.h" |
| 28 #include "ui/views/widget/tooltip_manager.h" | 28 #include "ui/views/widget/tooltip_manager.h" |
| 29 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 30 #include "ui/wm/core/default_activation_client.h" | 30 #include "ui/wm/core/default_activation_client.h" |
| 31 #include "ui/wm/core/default_screen_position_client.h" | 31 #include "ui/wm/core/default_screen_position_client.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 public: | 419 public: |
| 420 TooltipControllerCaptureTest() {} | 420 TooltipControllerCaptureTest() {} |
| 421 ~TooltipControllerCaptureTest() override {} | 421 ~TooltipControllerCaptureTest() override {} |
| 422 | 422 |
| 423 void SetUp() override { | 423 void SetUp() override { |
| 424 TooltipControllerTest::SetUp(); | 424 TooltipControllerTest::SetUp(); |
| 425 aura::client::SetScreenPositionClient(GetRootWindow(), | 425 aura::client::SetScreenPositionClient(GetRootWindow(), |
| 426 &screen_position_client_); | 426 &screen_position_client_); |
| 427 #if !defined(OS_CHROMEOS) | 427 #if !defined(OS_CHROMEOS) |
| 428 desktop_screen_.reset(CreateDesktopScreen()); | 428 desktop_screen_.reset(CreateDesktopScreen()); |
| 429 gfx::Screen::SetScreenInstance(desktop_screen_.get()); | 429 display::Screen::SetScreenInstance(desktop_screen_.get()); |
| 430 #endif | 430 #endif |
| 431 } | 431 } |
| 432 | 432 |
| 433 void TearDown() override { | 433 void TearDown() override { |
| 434 #if !defined(OS_CHROMEOS) | 434 #if !defined(OS_CHROMEOS) |
| 435 gfx::Screen::SetScreenInstance(test_screen()); | 435 display::Screen::SetScreenInstance(test_screen()); |
| 436 desktop_screen_.reset(); | 436 desktop_screen_.reset(); |
| 437 #endif | 437 #endif |
| 438 aura::client::SetScreenPositionClient(GetRootWindow(), NULL); | 438 aura::client::SetScreenPositionClient(GetRootWindow(), NULL); |
| 439 TooltipControllerTest::TearDown(); | 439 TooltipControllerTest::TearDown(); |
| 440 } | 440 } |
| 441 | 441 |
| 442 private: | 442 private: |
| 443 wm::DefaultScreenPositionClient screen_position_client_; | 443 wm::DefaultScreenPositionClient screen_position_client_; |
| 444 std::unique_ptr<gfx::Screen> desktop_screen_; | 444 std::unique_ptr<display::Screen> desktop_screen_; |
| 445 | 445 |
| 446 DISALLOW_COPY_AND_ASSIGN(TooltipControllerCaptureTest); | 446 DISALLOW_COPY_AND_ASSIGN(TooltipControllerCaptureTest); |
| 447 }; | 447 }; |
| 448 | 448 |
| 449 // Verifies when capture is released the TooltipController resets state. | 449 // Verifies when capture is released the TooltipController resets state. |
| 450 // Flaky on all builders. http://crbug.com/388268 | 450 // Flaky on all builders. http://crbug.com/388268 |
| 451 TEST_F(TooltipControllerCaptureTest, DISABLED_CloseOnCaptureLost) { | 451 TEST_F(TooltipControllerCaptureTest, DISABLED_CloseOnCaptureLost) { |
| 452 view_->GetWidget()->SetCapture(view_); | 452 view_->GetWidget()->SetCapture(view_); |
| 453 RunAllPendingInMessageLoop(); | 453 RunAllPendingInMessageLoop(); |
| 454 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); | 454 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 helper_->FireTooltipTimer(); | 795 helper_->FireTooltipTimer(); |
| 796 tooltip_bounds1 = test_tooltip_->location(); | 796 tooltip_bounds1 = test_tooltip_->location(); |
| 797 | 797 |
| 798 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); | 798 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); |
| 799 EXPECT_EQ(reference_string, helper_->GetTooltipText()); | 799 EXPECT_EQ(reference_string, helper_->GetTooltipText()); |
| 800 } | 800 } |
| 801 | 801 |
| 802 } // namespace test | 802 } // namespace test |
| 803 } // namespace corewm | 803 } // namespace corewm |
| 804 } // namespace views | 804 } // namespace views |
| OLD | NEW |