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

Side by Side Diff: ash/wm/panels/panel_layout_manager_unittest.cc

Issue 2237903003: mash: Migrate Shelf aura::Window uses to WmWindow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move shelf notify functions to WmShell. Created 4 years, 4 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
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/window_animations.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/common/wm/panels/panel_layout_manager.h" 5 #include "ash/common/wm/panels/panel_layout_manager.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/ash_switches.h" 8 #include "ash/common/ash_switches.h"
9 #include "ash/common/shelf/shelf_button.h" 9 #include "ash/common/shelf/shelf_button.h"
10 #include "ash/common/shelf/shelf_model.h" 10 #include "ash/common/shelf/shelf_model.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 void PanelsNotOverlapping(aura::Window* panel1, aura::Window* panel2) { 118 void PanelsNotOverlapping(aura::Window* panel1, aura::Window* panel2) {
119 // Waits until all shelf view animations are done. 119 // Waits until all shelf view animations are done.
120 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 120 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
121 gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow(); 121 gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow();
122 gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow(); 122 gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow();
123 123
124 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); 124 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds));
125 } 125 }
126 126
127 void IsPanelAboveLauncherIcon(const aura::Window* panel) { 127 void IsPanelAboveLauncherIcon(aura::Window* panel) {
128 // Waits until all shelf view animations are done. 128 // Waits until all shelf view animations are done.
129 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 129 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
130 130
131 Shelf* shelf = Shelf::ForWindow(panel); 131 WmWindow* wm_panel = WmWindowAura::Get(panel);
132 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); 132 Shelf* shelf = Shelf::ForWindow(wm_panel);
133 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel);
133 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); 134 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0);
134 135
135 gfx::Rect window_bounds = panel->GetBoundsInScreen(); 136 gfx::Rect window_bounds = panel->GetBoundsInScreen();
136 ASSERT_LT(icon_bounds.width(), window_bounds.width()); 137 ASSERT_LT(icon_bounds.width(), window_bounds.width());
137 ASSERT_LT(icon_bounds.height(), window_bounds.height()); 138 ASSERT_LT(icon_bounds.height(), window_bounds.height());
138 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); 139 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen();
139 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); 140 const ShelfAlignment alignment = shelf->alignment();
140 141
141 if (IsHorizontal(alignment)) { 142 if (IsHorizontal(alignment)) {
142 // The horizontal bounds of the panel window should contain the bounds of 143 // The horizontal bounds of the panel window should contain the bounds of
143 // the shelf icon. 144 // the shelf icon.
144 EXPECT_LE(window_bounds.x(), icon_bounds.x()); 145 EXPECT_LE(window_bounds.x(), icon_bounds.x());
145 EXPECT_GE(window_bounds.right(), icon_bounds.right()); 146 EXPECT_GE(window_bounds.right(), icon_bounds.right());
146 } else { 147 } else {
147 // The vertical bounds of the panel window should contain the bounds of 148 // The vertical bounds of the panel window should contain the bounds of
148 // the shelf icon. 149 // the shelf icon.
149 EXPECT_LE(window_bounds.y(), icon_bounds.y()); 150 EXPECT_LE(window_bounds.y(), icon_bounds.y());
150 EXPECT_GE(window_bounds.bottom(), icon_bounds.bottom()); 151 EXPECT_GE(window_bounds.bottom(), icon_bounds.bottom());
151 } 152 }
152 153
153 if (alignment == SHELF_ALIGNMENT_LEFT) 154 if (alignment == SHELF_ALIGNMENT_LEFT)
154 EXPECT_EQ(shelf_bounds.right(), window_bounds.x()); 155 EXPECT_EQ(shelf_bounds.right(), window_bounds.x());
155 else if (alignment == SHELF_ALIGNMENT_RIGHT) 156 else if (alignment == SHELF_ALIGNMENT_RIGHT)
156 EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); 157 EXPECT_EQ(shelf_bounds.x(), window_bounds.right());
157 else 158 else
158 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); 159 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom());
159 } 160 }
160 161
161 void IsCalloutAboveLauncherIcon(aura::Window* panel) { 162 void IsCalloutAboveLauncherIcon(aura::Window* panel) {
162 // Flush the message loop, since callout updates use a delayed task. 163 // Flush the message loop, since callout updates use a delayed task.
163 base::RunLoop().RunUntilIdle(); 164 base::RunLoop().RunUntilIdle();
164 views::Widget* widget = GetCalloutWidgetForPanel(panel); 165 views::Widget* widget = GetCalloutWidgetForPanel(panel);
165 166
166 Shelf* shelf = Shelf::ForWindow(panel); 167 WmWindow* wm_panel = WmWindowAura::Get(panel);
167 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); 168 Shelf* shelf = Shelf::ForWindow(wm_panel);
169 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel);
168 ASSERT_FALSE(icon_bounds.IsEmpty()); 170 ASSERT_FALSE(icon_bounds.IsEmpty());
169 171
170 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); 172 gfx::Rect panel_bounds = panel->GetBoundsInScreen();
171 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); 173 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen();
172 ASSERT_FALSE(icon_bounds.IsEmpty()); 174 ASSERT_FALSE(icon_bounds.IsEmpty());
173 175
174 EXPECT_TRUE(widget->IsVisible()); 176 EXPECT_TRUE(widget->IsVisible());
175 177
176 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); 178 const ShelfAlignment alignment = shelf->alignment();
177 if (alignment == SHELF_ALIGNMENT_LEFT) 179 if (alignment == SHELF_ALIGNMENT_LEFT)
178 EXPECT_EQ(panel_bounds.x(), callout_bounds.right()); 180 EXPECT_EQ(panel_bounds.x(), callout_bounds.right());
179 else if (alignment == SHELF_ALIGNMENT_RIGHT) 181 else if (alignment == SHELF_ALIGNMENT_RIGHT)
180 EXPECT_EQ(panel_bounds.right(), callout_bounds.x()); 182 EXPECT_EQ(panel_bounds.right(), callout_bounds.x());
181 else 183 else
182 EXPECT_EQ(panel_bounds.bottom(), callout_bounds.y()); 184 EXPECT_EQ(panel_bounds.bottom(), callout_bounds.y());
183 185
184 if (IsHorizontal(alignment)) { 186 if (IsHorizontal(alignment)) {
185 EXPECT_NEAR(icon_bounds.CenterPoint().x(), 187 EXPECT_NEAR(icon_bounds.CenterPoint().x(),
186 widget->GetWindowBoundsInScreen().CenterPoint().x(), 1); 188 widget->GetWindowBoundsInScreen().CenterPoint().x(), 1);
(...skipping 21 matching lines...) Expand all
208 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); 210 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen();
209 211
210 ui::test::EventGenerator& event_generator = GetEventGenerator(); 212 ui::test::EventGenerator& event_generator = GetEventGenerator();
211 event_generator.MoveMouseTo(bounds.CenterPoint()); 213 event_generator.MoveMouseTo(bounds.CenterPoint());
212 event_generator.ClickLeftButton(); 214 event_generator.ClickLeftButton();
213 215
214 test_api.RunMessageLoopUntilAnimationsDone(); 216 test_api.RunMessageLoopUntilAnimationsDone();
215 } 217 }
216 218
217 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) { 219 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) {
218 Shelf::ForWindow(root_window)->SetAlignment(alignment); 220 Shelf::ForWindow(WmWindowAura::Get(root_window))->SetAlignment(alignment);
219 }
220
221 ShelfAlignment GetAlignment(const aura::Window* root_window) {
222 return Shelf::ForWindow(root_window)->alignment();
223 } 221 }
224 222
225 void SetShelfAutoHideBehavior(aura::Window* window, 223 void SetShelfAutoHideBehavior(aura::Window* window,
226 ShelfAutoHideBehavior behavior) { 224 ShelfAutoHideBehavior behavior) {
227 Shelf* shelf = Shelf::ForWindow(window); 225 Shelf* shelf = Shelf::ForWindow(WmWindowAura::Get(window));
228 shelf->SetAutoHideBehavior(behavior); 226 shelf->SetAutoHideBehavior(behavior);
229 test::ShelfViewTestAPI test_api(GetShelfView(shelf)); 227 test::ShelfViewTestAPI test_api(GetShelfView(shelf));
230 test_api.RunMessageLoopUntilAnimationsDone(); 228 test_api.RunMessageLoopUntilAnimationsDone();
231 } 229 }
232 230
233 void SetShelfVisibilityState(aura::Window* window, 231 void SetShelfVisibilityState(aura::Window* window,
234 ShelfVisibilityState visibility_state) { 232 ShelfVisibilityState visibility_state) {
235 Shelf* shelf = Shelf::ForWindow(window); 233 Shelf* shelf = Shelf::ForWindow(WmWindowAura::Get(window));
236 shelf->shelf_layout_manager()->SetState(visibility_state); 234 shelf->shelf_layout_manager()->SetState(visibility_state);
237 } 235 }
238 236
239 ShelfView* GetShelfView(Shelf* shelf) { 237 ShelfView* GetShelfView(Shelf* shelf) {
240 return test::ShelfTestAPI(shelf).shelf_view(); 238 return test::ShelfTestAPI(shelf).shelf_view();
241 } 239 }
242 240
243 private: 241 private:
244 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; 242 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_;
245 243
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 gfx::Rect bounds(0, 0, 201, 201); 514 gfx::Rect bounds(0, 0, 201, 201);
517 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 515 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds));
518 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 516 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds));
519 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 517 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds));
520 518
521 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 519 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
522 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); 520 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x();
523 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); 521 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x();
524 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); 522 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x();
525 Shelf* shelf = Shelf::ForPrimaryDisplay(); 523 Shelf* shelf = Shelf::ForPrimaryDisplay();
526 int icon_x1 = shelf->GetScreenBoundsOfItemIconForWindow(w1.get()).x(); 524 int icon_x1 =
527 int icon_x2 = shelf->GetScreenBoundsOfItemIconForWindow(w2.get()).x(); 525 shelf->GetScreenBoundsOfItemIconForWindow(WmWindowAura::Get(w1.get()))
526 .x();
527 int icon_x2 =
528 shelf->GetScreenBoundsOfItemIconForWindow(WmWindowAura::Get(w2.get()))
529 .x();
528 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); 530 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2);
529 int spacing = window_x2 - window_x1; 531 int spacing = window_x2 - window_x1;
530 EXPECT_GT(spacing, icon_x2 - icon_x1); 532 EXPECT_GT(spacing, icon_x2 - icon_x1);
531 } 533 }
532 534
533 TEST_F(PanelLayoutManagerTest, FanLargeWindow) { 535 TEST_F(PanelLayoutManagerTest, FanLargeWindow) {
534 gfx::Rect small_bounds(0, 0, 201, 201); 536 gfx::Rect small_bounds(0, 0, 201, 201);
535 gfx::Rect large_bounds(0, 0, 501, 201); 537 gfx::Rect large_bounds(0, 0, 501, 201);
536 std::unique_ptr<aura::Window> w1(CreatePanelWindow(small_bounds)); 538 std::unique_ptr<aura::Window> w1(CreatePanelWindow(small_bounds));
537 std::unique_ptr<aura::Window> w2(CreatePanelWindow(large_bounds)); 539 std::unique_ptr<aura::Window> w2(CreatePanelWindow(large_bounds));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 std::unique_ptr<aura::Window> p1_d1( 583 std::unique_ptr<aura::Window> p1_d1(
582 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); 584 CreatePanelWindow(gfx::Rect(0, 0, 50, 50)));
583 std::unique_ptr<aura::Window> p2_d1( 585 std::unique_ptr<aura::Window> p2_d1(
584 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); 586 CreatePanelWindow(gfx::Rect(0, 0, 50, 50)));
585 std::unique_ptr<aura::Window> p1_d2( 587 std::unique_ptr<aura::Window> p1_d2(
586 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); 588 CreatePanelWindow(gfx::Rect(600, 0, 50, 50)));
587 std::unique_ptr<aura::Window> p2_d2( 589 std::unique_ptr<aura::Window> p2_d2(
588 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); 590 CreatePanelWindow(gfx::Rect(600, 0, 50, 50)));
589 591
590 ShelfView* shelf_view_1st = GetShelfView(Shelf::ForPrimaryDisplay()); 592 ShelfView* shelf_view_1st = GetShelfView(Shelf::ForPrimaryDisplay());
591 ShelfView* shelf_view_2nd = GetShelfView(Shelf::ForWindow(root_windows[1])); 593 ShelfView* shelf_view_2nd =
594 GetShelfView(Shelf::ForWindow(WmWindowAura::Get(root_windows[1])));
592 595
593 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); 596 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow());
594 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); 597 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow());
595 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); 598 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow());
596 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); 599 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow());
597 600
598 EXPECT_EQ(kShellWindowId_PanelContainer, p1_d1->parent()->id()); 601 EXPECT_EQ(kShellWindowId_PanelContainer, p1_d1->parent()->id());
599 EXPECT_EQ(kShellWindowId_PanelContainer, p2_d1->parent()->id()); 602 EXPECT_EQ(kShellWindowId_PanelContainer, p2_d1->parent()->id());
600 EXPECT_EQ(kShellWindowId_PanelContainer, p1_d2->parent()->id()); 603 EXPECT_EQ(kShellWindowId_PanelContainer, p1_d2->parent()->id());
601 EXPECT_EQ(kShellWindowId_PanelContainer, p2_d2->parent()->id()); 604 EXPECT_EQ(kShellWindowId_PanelContainer, p2_d2->parent()->id());
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); 819 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5));
817 target = targeter->FindTargetForEvent(root, &touch); 820 target = targeter->FindTargetForEvent(root, &touch);
818 EXPECT_NE(w.get(), target); 821 EXPECT_NE(w.get(), target);
819 } 822 }
820 823
821 INSTANTIATE_TEST_CASE_P(LtrRtl, 824 INSTANTIATE_TEST_CASE_P(LtrRtl,
822 PanelLayoutManagerTextDirectionTest, 825 PanelLayoutManagerTextDirectionTest,
823 testing::Bool()); 826 testing::Bool());
824 827
825 } // namespace ash 828 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/window_animations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698