diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-19 01:19:17 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-19 01:19:17 +0000 |
commit | f1b75a3d17fb083d617ce6dc77b8ba8d728f9581 (patch) | |
tree | ef1489c5fe756f6d056ead7981963193495bf2eb /ui | |
parent | 938cd942af407c8e4469411ff68df8e75c48e0f3 (diff) | |
download | chromium_src-f1b75a3d17fb083d617ce6dc77b8ba8d728f9581.zip chromium_src-f1b75a3d17fb083d617ce6dc77b8ba8d728f9581.tar.gz chromium_src-f1b75a3d17fb083d617ce6dc77b8ba8d728f9581.tar.bz2 |
Fixes TooltipControllerTest to create a toplevel tooltip window on Linux.
Also removes obsolete test cases which tested the behavior before tooltips were toplevel windows on Linux
BUG=None
TEST=None
Review URL: https://codereview.chromium.org/333333003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278221 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/corewm/DEPS | 2 | ||||
-rw-r--r-- | ui/views/corewm/tooltip_controller_unittest.cc | 132 | ||||
-rw-r--r-- | ui/views/test/desktop_test_views_delegate_aura.cc | 6 |
3 files changed, 17 insertions, 123 deletions
diff --git a/ui/views/corewm/DEPS b/ui/views/corewm/DEPS index 07e032c..a2d52d6 100644 --- a/ui/views/corewm/DEPS +++ b/ui/views/corewm/DEPS @@ -28,6 +28,8 @@ specific_include_rules = { ], "tooltip_controller_unittest.cc": [ + "+ui/views/test/desktop_test_views_delegate.h", + "+ui/views/test/test_views_delegate.h", "+ui/views/view.h", "+ui/views/widget/desktop_aura/desktop_native_widget_aura.h", "+ui/views/widget/desktop_aura/desktop_screen.h", diff --git a/ui/views/corewm/tooltip_controller_unittest.cc b/ui/views/corewm/tooltip_controller_unittest.cc index 5460227..e3487ae 100644 --- a/ui/views/corewm/tooltip_controller_unittest.cc +++ b/ui/views/corewm/tooltip_controller_unittest.cc @@ -22,6 +22,8 @@ #include "ui/gfx/text_elider.h" #include "ui/views/corewm/tooltip_aura.h" #include "ui/views/corewm/tooltip_controller_test_helper.h" +#include "ui/views/test/desktop_test_views_delegate.h" +#include "ui/views/test/test_views_delegate.h" #include "ui/views/view.h" #include "ui/views/widget/tooltip_manager.h" #include "ui/views/widget/widget.h" @@ -77,7 +79,12 @@ class TooltipControllerTest : public aura::test::AuraTestBase { virtual ~TooltipControllerTest() {} virtual void SetUp() OVERRIDE { - wm_state_.reset(new wm::WMState); +#if defined(OS_CHROMEOS) + views_delegate_.reset(new TestViewsDelegate); +#else + views_delegate_.reset(new DesktopTestViewsDelegate); +#endif + aura::test::AuraTestBase::SetUp(); new wm::DefaultActivationClient(root_window()); #if defined(OS_CHROMEOS) @@ -107,7 +114,7 @@ class TooltipControllerTest : public aura::test::AuraTestBase { helper_.reset(); widget_.reset(); aura::test::AuraTestBase::TearDown(); - wm_state_.reset(); + views_delegate_.reset(); } protected: @@ -135,12 +142,12 @@ class TooltipControllerTest : public aura::test::AuraTestBase { private: scoped_ptr<TooltipController> controller_; + scoped_ptr<views::TestViewsDelegate> views_delegate_; + #if defined(OS_WIN) ui::ScopedOleInitializer ole_initializer_; #endif - scoped_ptr<wm::WMState> wm_state_; - DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest); }; @@ -540,123 +547,6 @@ TEST_F(TooltipControllerCaptureTest, MAYBE_Capture) { widget2.reset(); } -// These tests search for a specific aura::Window to identify the -// tooltip. Windows shows the tooltip using a native tooltip, so these tests -// don't apply. -#if !defined(OS_WIN) && !defined(OS_CHROMEOS) -// This test creates two top level windows and verifies that the tooltip -// displays correctly when mouse moves are dispatched to these windows. -// Additionally it also verifies that the tooltip is reparented to the new -// window when mouse moves are dispatched to it. -TEST_F(TooltipControllerTest, TooltipsInMultipleRootWindows) { - view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text For RootWindow1")); - EXPECT_EQ(base::string16(), helper_->GetTooltipText()); - EXPECT_EQ(NULL, helper_->GetTooltipWindow()); - - aura::Window* window = GetWindow(); - aura::Window* root_window = GetRootWindow(); - - // Fire tooltip timer so tooltip becomes visible. - generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint()); - helper_->FireTooltipTimer(); - EXPECT_TRUE(helper_->IsTooltipVisible()); - for (int i = 0; i < 49; ++i) { - generator_->MoveMouseBy(1, 0); - EXPECT_TRUE(helper_->IsTooltipVisible()); - EXPECT_EQ(window, root_window->GetEventHandlerForPoint( - generator_->current_location())); - base::string16 expected_tooltip = - ASCIIToUTF16("Tooltip Text For RootWindow1"); - EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window)); - EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); - EXPECT_EQ(window, helper_->GetTooltipWindow()); - } - - views::Widget* widget2 = CreateWidget(NULL); - widget2->SetContentsView(new View); - TooltipTestView* view2 = new TooltipTestView; - widget2->GetContentsView()->AddChildView(view2); - view2->SetBoundsRect(widget2->GetContentsView()->GetLocalBounds()); - helper_.reset(new TooltipControllerTestHelper( - GetController(widget2))); - generator_.reset(new aura::test::EventGenerator( - widget2->GetNativeWindow()->GetRootWindow())); - view2->set_tooltip_text(ASCIIToUTF16("Tooltip Text For RootWindow2")); - - aura::Window* window2 = widget2->GetNativeWindow(); - aura::Window* root_window2 = - widget2->GetNativeWindow()->GetRootWindow(); - // Fire tooltip timer so tooltip becomes visible. - generator_->MoveMouseRelativeTo(window2, view2->bounds().CenterPoint()); - helper_->FireTooltipTimer(); - - EXPECT_NE(root_window, root_window2); - EXPECT_NE(window, window2); - - for (int i = 0; i < 49; ++i) { - generator_->MoveMouseBy(1, 0); - EXPECT_TRUE(helper_->IsTooltipVisible()); - EXPECT_EQ(window2, root_window2->GetEventHandlerForPoint( - generator_->current_location())); - base::string16 expected_tooltip = - ASCIIToUTF16("Tooltip Text For RootWindow2"); - EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(window2)); - EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); - EXPECT_EQ(window2, helper_->GetTooltipWindow()); - } - - bool tooltip_reparented = false; - for (size_t i = 0; i < root_window2->children().size(); ++i) { - if (root_window2->children()[i]->type() == ui::wm::WINDOW_TYPE_TOOLTIP) { - tooltip_reparented = true; - break; - } - } - EXPECT_TRUE(tooltip_reparented); - widget2->Close(); -} - -// This test validates whether the tooltip after becoming visible stays at the -// top of the ZOrder in its root window after activation changes. -TEST_F(TooltipControllerTest, TooltipAtTopOfZOrderAfterActivation) { - view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); - EXPECT_EQ(base::string16(), helper_->GetTooltipText()); - EXPECT_EQ(NULL, helper_->GetTooltipWindow()); - generator_->MoveMouseToCenterOf(GetWindow()); - - EXPECT_EQ(GetWindow(), GetRootWindow()->GetEventHandlerForPoint( - generator_->current_location())); - base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); - EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); - EXPECT_EQ(base::string16(), helper_->GetTooltipText()); - EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); - - // Fire tooltip timer so tooltip becomes visible. - helper_->FireTooltipTimer(); - - EXPECT_TRUE(helper_->IsTooltipVisible()); - generator_->MoveMouseBy(1, 0); - - EXPECT_TRUE(helper_->IsTooltipVisible()); - EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); - EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); - EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); - - // Fake activation loss and gain in the native widget. This should cause a - // ZOrder change which should not affect the position of the tooltip. - DesktopNativeWidgetAura* native_widget = - static_cast<DesktopNativeWidgetAura*>(widget_->native_widget()); - EXPECT_TRUE(native_widget != NULL); - - native_widget->HandleActivationChanged(false); - native_widget->HandleActivationChanged(true); - - EXPECT_EQ( - widget_->GetNativeWindow()->GetRootWindow()->children().back()->type(), - ui::wm::WINDOW_TYPE_TOOLTIP); -} -#endif - namespace { class TestTooltip : public Tooltip { diff --git a/ui/views/test/desktop_test_views_delegate_aura.cc b/ui/views/test/desktop_test_views_delegate_aura.cc index 5627b07..96f6391 100644 --- a/ui/views/test/desktop_test_views_delegate_aura.cc +++ b/ui/views/test/desktop_test_views_delegate_aura.cc @@ -25,9 +25,11 @@ void DesktopTestViewsDelegate::OnBeforeWidgetInit( if (params->native_widget) return; - if (params->parent && params->type != views::Widget::InitParams::TYPE_MENU) { + if (params->parent && + params->type != views::Widget::InitParams::TYPE_MENU && + params->type != views::Widget::InitParams::TYPE_TOOLTIP) { params->native_widget = new views::NativeWidgetAura(delegate); - } else if (!params->parent && !params->context) { + } else { params->native_widget = new views::DesktopNativeWidgetAura(delegate); } #endif |