Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: ash/launcher/launcher_tooltip_manager_unittest.cc

Issue 11017079: Remove Shell::shelf()|status_area_widget()|launcher() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/launcher/launcher.cc ('k') | ash/launcher/launcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/launcher/launcher_tooltip_manager.h" 5 #include "ash/launcher/launcher_tooltip_manager.h"
6 6
7 #include "ash/root_window_controller.h"
8 #include "ash/shell.h"
7 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
8 #include "ash/wm/shelf_layout_manager.h" 10 #include "ash/wm/shelf_layout_manager.h"
9 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
10 #include "base/string16.h" 12 #include "base/string16.h"
11 #include "base/time.h" 13 #include "base/time.h"
12 #include "ui/aura/event_filter.h" 14 #include "ui/aura/event_filter.h"
13 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
14 #include "ui/base/events/event.h" 16 #include "ui/base/events/event.h"
15 #include "ui/base/events/event_constants.h" 17 #include "ui/base/events/event_constants.h"
16 #include "ui/base/keycodes/keyboard_codes.h" 18 #include "ui/base/keycodes/keyboard_codes.h"
17 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
18 20
19 namespace ash { 21 namespace ash {
20 namespace test { 22 namespace test {
21 23
22 class LauncherTooltipManagerTest : public AshTestBase { 24 class LauncherTooltipManagerTest : public AshTestBase {
23 public: 25 public:
24 LauncherTooltipManagerTest() {} 26 LauncherTooltipManagerTest() {}
25 virtual ~LauncherTooltipManagerTest() {} 27 virtual ~LauncherTooltipManagerTest() {}
26 28
27 virtual void SetUp() OVERRIDE { 29 virtual void SetUp() OVERRIDE {
28 AshTestBase::SetUp(); 30 AshTestBase::SetUp();
29 31 internal::RootWindowController* controller =
32 Shell::GetPrimaryRootWindowController();
30 tooltip_manager_.reset(new internal::LauncherTooltipManager( 33 tooltip_manager_.reset(new internal::LauncherTooltipManager(
31 SHELF_ALIGNMENT_BOTTOM, 34 SHELF_ALIGNMENT_BOTTOM,
32 Shell::GetInstance()->shelf(), 35 controller->shelf(),
33 Shell::GetInstance()->launcher()->GetLauncherViewForTest())); 36 controller->launcher()->GetLauncherViewForTest()));
34 } 37 }
35 38
36 virtual void TearDown() OVERRIDE { 39 virtual void TearDown() OVERRIDE {
37 tooltip_manager_.reset(); 40 tooltip_manager_.reset();
38 AshTestBase::TearDown(); 41 AshTestBase::TearDown();
39 } 42 }
40 43
41 void ShowDelayed() { 44 void ShowDelayed() {
42 dummy_anchor_.reset(new views::View); 45 dummy_anchor_.reset(new views::View);
43 tooltip_manager_->ShowDelayed(dummy_anchor_.get(), string16()); 46 tooltip_manager_->ShowDelayed(dummy_anchor_.get(), string16());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 92
90 // Create a full-screen window to hide the shelf. 93 // Create a full-screen window to hide the shelf.
91 scoped_ptr<views::Widget> widget(new views::Widget); 94 scoped_ptr<views::Widget> widget(new views::Widget);
92 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 95 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
93 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 96 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
94 widget->Init(params); 97 widget->Init(params);
95 widget->SetFullscreen(true); 98 widget->SetFullscreen(true);
96 widget->Show(); 99 widget->Show();
97 100
98 // Once the shelf is hidden, the tooltip should be invisible. 101 // Once the shelf is hidden, the tooltip should be invisible.
99 ASSERT_EQ(internal::ShelfLayoutManager::HIDDEN, 102 ASSERT_EQ(
100 Shell::GetInstance()->shelf()->visibility_state()); 103 internal::ShelfLayoutManager::HIDDEN,
104 Shell::GetPrimaryRootWindowController()->shelf()->visibility_state());
101 EXPECT_FALSE(TooltipIsVisible()); 105 EXPECT_FALSE(TooltipIsVisible());
102 106
103 // Do not show the view if the shelf is hidden. 107 // Do not show the view if the shelf is hidden.
104 ShowImmediately(); 108 ShowImmediately();
105 EXPECT_FALSE(TooltipIsVisible()); 109 EXPECT_FALSE(TooltipIsVisible());
106 110
107 // ShowDelayed() doesn't even start the timer for the hidden shelf. 111 // ShowDelayed() doesn't even start the timer for the hidden shelf.
108 ShowDelayed(); 112 ShowDelayed();
109 EXPECT_FALSE(IsTimerRunning()); 113 EXPECT_FALSE(IsTimerRunning());
110 } 114 }
111 115
112 TEST_F(LauncherTooltipManagerTest, HideWhenShelfIsAutoHide) { 116 TEST_F(LauncherTooltipManagerTest, HideWhenShelfIsAutoHide) {
113 ShowImmediately(); 117 ShowImmediately();
114 ASSERT_TRUE(TooltipIsVisible()); 118 ASSERT_TRUE(TooltipIsVisible());
115 119
116 internal::ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); 120 internal::ShelfLayoutManager* shelf =
121 Shell::GetPrimaryRootWindowController()->shelf();
117 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 122 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
118 shelf->UpdateAutoHideState(); 123 shelf->UpdateAutoHideState();
119 ASSERT_EQ(internal::ShelfLayoutManager::AUTO_HIDE_HIDDEN, 124 ASSERT_EQ(internal::ShelfLayoutManager::AUTO_HIDE_HIDDEN,
120 shelf->auto_hide_state()); 125 shelf->auto_hide_state());
121 126
122 // Tooltip visibility change for auto hide may take time. 127 // Tooltip visibility change for auto hide may take time.
123 EXPECT_TRUE(TooltipIsVisible()); 128 EXPECT_TRUE(TooltipIsVisible());
124 RunAllPendingInMessageLoop(); 129 RunAllPendingInMessageLoop();
125 EXPECT_FALSE(TooltipIsVisible()); 130 EXPECT_FALSE(TooltipIsVisible());
126 131
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 196
192 // Should hide if the mouse is out of the tooltip. 197 // Should hide if the mouse is out of the tooltip.
193 test_api.set_location(tooltip_rect.origin().Add(gfx::Point(-1, -1))); 198 test_api.set_location(tooltip_rect.origin().Add(gfx::Point(-1, -1)));
194 EXPECT_FALSE(event_filter->PreHandleMouseEvent(root_window, &mouse_event)); 199 EXPECT_FALSE(event_filter->PreHandleMouseEvent(root_window, &mouse_event));
195 RunAllPendingInMessageLoop(); 200 RunAllPendingInMessageLoop();
196 EXPECT_FALSE(TooltipIsVisible()); 201 EXPECT_FALSE(TooltipIsVisible());
197 } 202 }
198 203
199 } // namespace test 204 } // namespace test
200 } // namespace ash 205 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher.cc ('k') | ash/launcher/launcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698