| 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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/aura/client/cursor_client.h" | 8 #include "ui/aura/client/cursor_client.h" |
| 9 #include "ui/aura/client/screen_position_client.h" | 9 #include "ui/aura/client/screen_position_client.h" |
| 10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| 11 #include "ui/aura/test/aura_test_base.h" | 11 #include "ui/aura/test/aura_test_base.h" |
| 12 #include "ui/aura/test/event_generator.h" | 12 #include "ui/aura/test/event_generator.h" |
| 13 #include "ui/aura/test/test_screen.h" | 13 #include "ui/aura/test/test_screen.h" |
| 14 #include "ui/aura/test/test_window_delegate.h" | 14 #include "ui/aura/test/test_window_delegate.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/font.h" | 18 #include "ui/gfx/font.h" |
| 19 #include "ui/gfx/point.h" | 19 #include "ui/gfx/point.h" |
| 20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 21 #include "ui/gfx/screen_type_delegate.h" | 21 #include "ui/gfx/screen_type_delegate.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/view.h" | 25 #include "ui/views/view.h" |
| 26 #include "ui/views/widget/tooltip_manager.h" | 26 #include "ui/views/widget/tooltip_manager.h" |
| 27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 28 #include "ui/wm/core/default_activation_client.h" |
| 28 #include "ui/wm/core/wm_state.h" | 29 #include "ui/wm/core/wm_state.h" |
| 29 #include "ui/wm/public/tooltip_client.h" | 30 #include "ui/wm/public/tooltip_client.h" |
| 30 #include "ui/wm/public/window_types.h" | 31 #include "ui/wm/public/window_types.h" |
| 31 | 32 |
| 32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| 33 #include "ui/base/win/scoped_ole_initializer.h" | 34 #include "ui/base/win/scoped_ole_initializer.h" |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 #if !defined(OS_CHROMEOS) | 37 #if !defined(OS_CHROMEOS) |
| 37 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 38 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } // namespace | 72 } // namespace |
| 72 | 73 |
| 73 class TooltipControllerTest : public aura::test::AuraTestBase { | 74 class TooltipControllerTest : public aura::test::AuraTestBase { |
| 74 public: | 75 public: |
| 75 TooltipControllerTest() : view_(NULL) {} | 76 TooltipControllerTest() : view_(NULL) {} |
| 76 virtual ~TooltipControllerTest() {} | 77 virtual ~TooltipControllerTest() {} |
| 77 | 78 |
| 78 virtual void SetUp() OVERRIDE { | 79 virtual void SetUp() OVERRIDE { |
| 79 wm_state_.reset(new wm::WMState); | 80 wm_state_.reset(new wm::WMState); |
| 80 aura::test::AuraTestBase::SetUp(); | 81 aura::test::AuraTestBase::SetUp(); |
| 82 new wm::DefaultActivationClient(root_window()); |
| 81 #if defined(OS_CHROMEOS) | 83 #if defined(OS_CHROMEOS) |
| 82 controller_.reset(new TooltipController( | 84 controller_.reset(new TooltipController( |
| 83 scoped_ptr<views::corewm::Tooltip>( | 85 scoped_ptr<views::corewm::Tooltip>( |
| 84 new views::corewm::TooltipAura(gfx::SCREEN_TYPE_ALTERNATE)))); | 86 new views::corewm::TooltipAura(gfx::SCREEN_TYPE_ALTERNATE)))); |
| 85 root_window()->AddPreTargetHandler(controller_.get()); | 87 root_window()->AddPreTargetHandler(controller_.get()); |
| 86 SetTooltipClient(root_window(), controller_.get()); | 88 SetTooltipClient(root_window(), controller_.get()); |
| 87 #endif | 89 #endif |
| 88 widget_.reset(CreateWidget(root_window())); | 90 widget_.reset(CreateWidget(root_window())); |
| 89 widget_->SetContentsView(new View); | 91 widget_->SetContentsView(new View); |
| 90 view_ = new TooltipTestView; | 92 view_ = new TooltipTestView; |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 693 |
| 692 // Use for tests that don't depend upon views. | 694 // Use for tests that don't depend upon views. |
| 693 class TooltipControllerTest2 : public aura::test::AuraTestBase { | 695 class TooltipControllerTest2 : public aura::test::AuraTestBase { |
| 694 public: | 696 public: |
| 695 TooltipControllerTest2() : test_tooltip_(new TestTooltip) {} | 697 TooltipControllerTest2() : test_tooltip_(new TestTooltip) {} |
| 696 virtual ~TooltipControllerTest2() {} | 698 virtual ~TooltipControllerTest2() {} |
| 697 | 699 |
| 698 virtual void SetUp() OVERRIDE { | 700 virtual void SetUp() OVERRIDE { |
| 699 wm_state_.reset(new wm::WMState); | 701 wm_state_.reset(new wm::WMState); |
| 700 aura::test::AuraTestBase::SetUp(); | 702 aura::test::AuraTestBase::SetUp(); |
| 703 new wm::DefaultActivationClient(root_window()); |
| 701 controller_.reset(new TooltipController( | 704 controller_.reset(new TooltipController( |
| 702 scoped_ptr<corewm::Tooltip>(test_tooltip_))); | 705 scoped_ptr<corewm::Tooltip>(test_tooltip_))); |
| 703 root_window()->AddPreTargetHandler(controller_.get()); | 706 root_window()->AddPreTargetHandler(controller_.get()); |
| 704 SetTooltipClient(root_window(), controller_.get()); | 707 SetTooltipClient(root_window(), controller_.get()); |
| 705 helper_.reset(new TooltipControllerTestHelper(controller_.get())); | 708 helper_.reset(new TooltipControllerTestHelper(controller_.get())); |
| 706 generator_.reset(new aura::test::EventGenerator(root_window())); | 709 generator_.reset(new aura::test::EventGenerator(root_window())); |
| 707 } | 710 } |
| 708 | 711 |
| 709 virtual void TearDown() OVERRIDE { | 712 virtual void TearDown() OVERRIDE { |
| 710 root_window()->RemovePreTargetHandler(controller_.get()); | 713 root_window()->RemovePreTargetHandler(controller_.get()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 // the tooltip window is closed. | 762 // the tooltip window is closed. |
| 760 ui::CancelModeEvent event; | 763 ui::CancelModeEvent event; |
| 761 helper_->controller()->OnCancelMode(&event); | 764 helper_->controller()->OnCancelMode(&event); |
| 762 EXPECT_FALSE(helper_->IsTooltipVisible()); | 765 EXPECT_FALSE(helper_->IsTooltipVisible()); |
| 763 EXPECT_TRUE(helper_->GetTooltipWindow() == NULL); | 766 EXPECT_TRUE(helper_->GetTooltipWindow() == NULL); |
| 764 } | 767 } |
| 765 | 768 |
| 766 } // namespace test | 769 } // namespace test |
| 767 } // namespace corewm | 770 } // namespace corewm |
| 768 } // namespace views | 771 } // namespace views |
| OLD | NEW |