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" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 views_delegate_.reset(new TestViewsDelegate); | 83 views_delegate_.reset(new TestViewsDelegate); |
84 #else | 84 #else |
85 views_delegate_.reset(new DesktopTestViewsDelegate); | 85 views_delegate_.reset(new DesktopTestViewsDelegate); |
86 #endif | 86 #endif |
87 | 87 |
88 aura::test::AuraTestBase::SetUp(); | 88 aura::test::AuraTestBase::SetUp(); |
89 new wm::DefaultActivationClient(root_window()); | 89 new wm::DefaultActivationClient(root_window()); |
90 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
91 controller_.reset(new TooltipController( | 91 controller_.reset(new TooltipController( |
92 scoped_ptr<views::corewm::Tooltip>( | 92 scoped_ptr<views::corewm::Tooltip>( |
93 new views::corewm::TooltipAura(gfx::SCREEN_TYPE_ALTERNATE)))); | 93 new views::corewm::TooltipAura))); |
94 root_window()->AddPreTargetHandler(controller_.get()); | 94 root_window()->AddPreTargetHandler(controller_.get()); |
95 SetTooltipClient(root_window(), controller_.get()); | 95 SetTooltipClient(root_window(), controller_.get()); |
96 #endif | 96 #endif |
97 widget_.reset(CreateWidget(root_window())); | 97 widget_.reset(CreateWidget(root_window())); |
98 widget_->SetContentsView(new View); | 98 widget_->SetContentsView(new View); |
99 view_ = new TooltipTestView; | 99 view_ = new TooltipTestView; |
100 widget_->GetContentsView()->AddChildView(view_); | 100 widget_->GetContentsView()->AddChildView(view_); |
101 view_->SetBoundsRect(widget_->GetContentsView()->GetLocalBounds()); | 101 view_->SetBoundsRect(widget_->GetContentsView()->GetLocalBounds()); |
102 helper_.reset(new TooltipControllerTestHelper( | 102 helper_.reset(new TooltipControllerTestHelper( |
103 GetController(widget_.get()))); | 103 GetController(widget_.get()))); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 namespace { | 525 namespace { |
526 | 526 |
527 class TestTooltip : public Tooltip { | 527 class TestTooltip : public Tooltip { |
528 public: | 528 public: |
529 TestTooltip() : is_visible_(false) {} | 529 TestTooltip() : is_visible_(false) {} |
530 ~TestTooltip() override {} | 530 ~TestTooltip() override {} |
531 | 531 |
532 const base::string16& tooltip_text() const { return tooltip_text_; } | 532 const base::string16& tooltip_text() const { return tooltip_text_; } |
533 | 533 |
534 // Tooltip: | 534 // Tooltip: |
| 535 int GetMaxWidth(const gfx::Point& location, |
| 536 aura::Window* context) const override { |
| 537 return 100; |
| 538 } |
535 void SetText(aura::Window* window, | 539 void SetText(aura::Window* window, |
536 const base::string16& tooltip_text, | 540 const base::string16& tooltip_text, |
537 const gfx::Point& location) override { | 541 const gfx::Point& location) override { |
538 tooltip_text_ = tooltip_text; | 542 tooltip_text_ = tooltip_text; |
539 location_ = location; | 543 location_ = location; |
540 } | 544 } |
541 void Show() override { is_visible_ = true; } | 545 void Show() override { is_visible_ = true; } |
542 void Hide() override { is_visible_ = false; } | 546 void Hide() override { is_visible_ = false; } |
543 bool IsVisible() override { return is_visible_; } | 547 bool IsVisible() override { return is_visible_; } |
544 const gfx::Point& location() { return location_; } | 548 const gfx::Point& location() { return location_; } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 helper_->FireTooltipTimer(); | 796 helper_->FireTooltipTimer(); |
793 tooltip_bounds1 = test_tooltip_->location(); | 797 tooltip_bounds1 = test_tooltip_->location(); |
794 | 798 |
795 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); | 799 EXPECT_NE(tooltip_bounds1_1, tooltip_bounds1); |
796 EXPECT_EQ(reference_string, helper_->GetTooltipText()); | 800 EXPECT_EQ(reference_string, helper_->GetTooltipText()); |
797 } | 801 } |
798 | 802 |
799 } // namespace test | 803 } // namespace test |
800 } // namespace corewm | 804 } // namespace corewm |
801 } // namespace views | 805 } // namespace views |
OLD | NEW |