| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ash/shelf/shelf_tooltip_manager.h" | 5 #include "ash/shelf/shelf_tooltip_manager.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 namespace ash { | 35 namespace ash { |
| 36 namespace test { | 36 namespace test { |
| 37 | 37 |
| 38 class ShelfTooltipManagerTest : public AshTestBase { | 38 class ShelfTooltipManagerTest : public AshTestBase { |
| 39 public: | 39 public: |
| 40 ShelfTooltipManagerTest() {} | 40 ShelfTooltipManagerTest() {} |
| 41 virtual ~ShelfTooltipManagerTest() {} | 41 virtual ~ShelfTooltipManagerTest() {} |
| 42 | 42 |
| 43 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() OVERRIDE { |
| 44 AshTestBase::SetUp(); | 44 AshTestBase::SetUp(); |
| 45 internal::RootWindowController* controller = | 45 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
| 46 Shell::GetPrimaryRootWindowController(); | 46 tooltip_manager_.reset(new ShelfTooltipManager( |
| 47 tooltip_manager_.reset(new internal::ShelfTooltipManager( | |
| 48 controller->GetShelfLayoutManager(), | 47 controller->GetShelfLayoutManager(), |
| 49 ShelfTestAPI(controller->shelf()->shelf()).shelf_view())); | 48 ShelfTestAPI(controller->shelf()->shelf()).shelf_view())); |
| 50 } | 49 } |
| 51 | 50 |
| 52 virtual void TearDown() OVERRIDE { | 51 virtual void TearDown() OVERRIDE { |
| 53 tooltip_manager_.reset(); | 52 tooltip_manager_.reset(); |
| 54 AshTestBase::TearDown(); | 53 AshTestBase::TearDown(); |
| 55 } | 54 } |
| 56 | 55 |
| 57 void ShowDelayed() { | 56 void ShowDelayed() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 76 return tooltip_manager_.get(); | 75 return tooltip_manager_.get(); |
| 77 } | 76 } |
| 78 | 77 |
| 79 views::Widget* GetTooltipWidget() { | 78 views::Widget* GetTooltipWidget() { |
| 80 return tooltip_manager_->widget_; | 79 return tooltip_manager_->widget_; |
| 81 } | 80 } |
| 82 | 81 |
| 83 protected: | 82 protected: |
| 84 scoped_ptr<views::Widget> widget_; | 83 scoped_ptr<views::Widget> widget_; |
| 85 scoped_ptr<views::View> dummy_anchor_; | 84 scoped_ptr<views::View> dummy_anchor_; |
| 86 scoped_ptr<internal::ShelfTooltipManager> tooltip_manager_; | 85 scoped_ptr<ShelfTooltipManager> tooltip_manager_; |
| 87 | 86 |
| 88 private: | 87 private: |
| 89 void CreateWidget() { | 88 void CreateWidget() { |
| 90 dummy_anchor_.reset(new views::View); | 89 dummy_anchor_.reset(new views::View); |
| 91 | 90 |
| 92 widget_.reset(new views::Widget); | 91 widget_.reset(new views::Widget); |
| 93 views::Widget::InitParams params( | 92 views::Widget::InitParams params( |
| 94 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 93 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 95 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 94 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 96 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 95 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 97 params.parent = Shell::GetContainer( | 96 params.parent = Shell::GetContainer(Shell::GetPrimaryRootWindow(), |
| 98 Shell::GetPrimaryRootWindow(), | 97 ash::kShellWindowId_ShelfContainer); |
| 99 ash::internal::kShellWindowId_ShelfContainer); | |
| 100 | 98 |
| 101 widget_->Init(params); | 99 widget_->Init(params); |
| 102 widget_->SetContentsView(dummy_anchor_.get()); | 100 widget_->SetContentsView(dummy_anchor_.get()); |
| 103 } | 101 } |
| 104 | 102 |
| 105 DISALLOW_COPY_AND_ASSIGN(ShelfTooltipManagerTest); | 103 DISALLOW_COPY_AND_ASSIGN(ShelfTooltipManagerTest); |
| 106 }; | 104 }; |
| 107 | 105 |
| 108 TEST_F(ShelfTooltipManagerTest, ShowingBasics) { | 106 TEST_F(ShelfTooltipManagerTest, ShowingBasics) { |
| 109 // ShowDelayed() should just start the timer instead of showing immediately. | 107 // ShowDelayed() should just start the timer instead of showing immediately. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 views::Widget* dummy = new views::Widget; | 148 views::Widget* dummy = new views::Widget; |
| 151 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 149 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 152 params.bounds = gfx::Rect(0, 0, 200, 200); | 150 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 153 params.context = CurrentContext(); | 151 params.context = CurrentContext(); |
| 154 dummy->Init(params); | 152 dummy->Init(params); |
| 155 dummy->Show(); | 153 dummy->Show(); |
| 156 | 154 |
| 157 ShowImmediately(); | 155 ShowImmediately(); |
| 158 ASSERT_TRUE(TooltipIsVisible()); | 156 ASSERT_TRUE(TooltipIsVisible()); |
| 159 | 157 |
| 160 internal::ShelfLayoutManager* shelf = | 158 ShelfLayoutManager* shelf = |
| 161 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 159 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 162 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 160 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 163 shelf->UpdateAutoHideState(); | 161 shelf->UpdateAutoHideState(); |
| 164 ASSERT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 162 ASSERT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 165 | 163 |
| 166 // Tooltip visibility change for auto hide may take time. | 164 // Tooltip visibility change for auto hide may take time. |
| 167 EXPECT_TRUE(TooltipIsVisible()); | 165 EXPECT_TRUE(TooltipIsVisible()); |
| 168 RunAllPendingInMessageLoop(); | 166 RunAllPendingInMessageLoop(); |
| 169 EXPECT_FALSE(TooltipIsVisible()); | 167 EXPECT_FALSE(TooltipIsVisible()); |
| 170 | 168 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 277 |
| 280 SetEventTarget(root_window, &mouse_event); | 278 SetEventTarget(root_window, &mouse_event); |
| 281 event_handler->OnMouseEvent(&mouse_event); | 279 event_handler->OnMouseEvent(&mouse_event); |
| 282 EXPECT_FALSE(mouse_event.handled()); | 280 EXPECT_FALSE(mouse_event.handled()); |
| 283 RunAllPendingInMessageLoop(); | 281 RunAllPendingInMessageLoop(); |
| 284 EXPECT_FALSE(TooltipIsVisible()); | 282 EXPECT_FALSE(TooltipIsVisible()); |
| 285 } | 283 } |
| 286 | 284 |
| 287 } // namespace test | 285 } // namespace test |
| 288 } // namespace ash | 286 } // namespace ash |
| OLD | NEW |