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/tooltip_client.h" | 9 #include "ui/aura/client/tooltip_client.h" |
10 #include "ui/aura/client/window_types.h" | 10 #include "ui/aura/client/window_types.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 for (size_t i = 0; i < root_window2->children().size(); ++i) { | 492 for (size_t i = 0; i < root_window2->children().size(); ++i) { |
493 if (root_window2->children()[i]->type() == | 493 if (root_window2->children()[i]->type() == |
494 aura::client::WINDOW_TYPE_TOOLTIP) { | 494 aura::client::WINDOW_TYPE_TOOLTIP) { |
495 tooltip_reparented = true; | 495 tooltip_reparented = true; |
496 break; | 496 break; |
497 } | 497 } |
498 } | 498 } |
499 EXPECT_TRUE(tooltip_reparented); | 499 EXPECT_TRUE(tooltip_reparented); |
500 widget2->Close(); | 500 widget2->Close(); |
501 } | 501 } |
| 502 |
| 503 // This test validates whether the tooltip after becoming visible stays at the |
| 504 // top of the ZOrder in its root window after activation changes. |
| 505 TEST_F(TooltipControllerTest, TooltipAtTopOfZOrderAfterActivation) { |
| 506 view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); |
| 507 EXPECT_EQ(string16(), helper_->GetTooltipText()); |
| 508 EXPECT_EQ(NULL, helper_->GetTooltipWindow()); |
| 509 generator_->MoveMouseToCenterOf(GetWindow()); |
| 510 |
| 511 EXPECT_EQ(GetWindow(), GetRootWindow()->GetEventHandlerForPoint( |
| 512 generator_->current_location())); |
| 513 string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); |
| 514 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); |
| 515 EXPECT_EQ(string16(), helper_->GetTooltipText()); |
| 516 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); |
| 517 |
| 518 // Fire tooltip timer so tooltip becomes visible. |
| 519 helper_->FireTooltipTimer(); |
| 520 |
| 521 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 522 generator_->MoveMouseBy(1, 0); |
| 523 |
| 524 EXPECT_TRUE(helper_->IsTooltipVisible()); |
| 525 EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); |
| 526 EXPECT_EQ(expected_tooltip, helper_->GetTooltipText()); |
| 527 EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); |
| 528 |
| 529 // Fake activation loss and gain in the native widget. This should cause a |
| 530 // ZOrder change which should not affect the position of the tooltip. |
| 531 DesktopNativeWidgetAura* native_widget = |
| 532 static_cast<DesktopNativeWidgetAura*>(widget_->native_widget()); |
| 533 EXPECT_TRUE(native_widget != NULL); |
| 534 |
| 535 native_widget->HandleActivationChanged(false); |
| 536 native_widget->HandleActivationChanged(true); |
| 537 |
| 538 EXPECT_EQ( |
| 539 widget_->GetNativeWindow()->GetRootWindow()->children().back()->type(), |
| 540 aura::client::WINDOW_TYPE_TOOLTIP); |
| 541 } |
| 542 |
502 #endif | 543 #endif |
503 | 544 |
504 } // namespace test | 545 } // namespace test |
505 } // namespace corewm | 546 } // namespace corewm |
506 } // namespace views | 547 } // namespace views |
OLD | NEW |