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

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

Issue 1849623002: Remove unused ash::SHELF_ALIGNMENT_TOP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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/wm/panels/panel_layout_manager.cc ('k') | ash/wm/panels/panel_window_resizer.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/wm/panels/panel_layout_manager.h" 5 #include "ash/wm/panels/panel_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_button.h" 10 #include "ash/shelf/shelf_button.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 switch (alignment) { 143 switch (alignment) {
144 case SHELF_ALIGNMENT_BOTTOM: 144 case SHELF_ALIGNMENT_BOTTOM:
145 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); 145 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom());
146 break; 146 break;
147 case SHELF_ALIGNMENT_LEFT: 147 case SHELF_ALIGNMENT_LEFT:
148 EXPECT_EQ(shelf_bounds.right(), window_bounds.x()); 148 EXPECT_EQ(shelf_bounds.right(), window_bounds.x());
149 break; 149 break;
150 case SHELF_ALIGNMENT_RIGHT: 150 case SHELF_ALIGNMENT_RIGHT:
151 EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); 151 EXPECT_EQ(shelf_bounds.x(), window_bounds.right());
152 break; 152 break;
153 case SHELF_ALIGNMENT_TOP:
154 EXPECT_EQ(shelf_bounds.bottom(), window_bounds.y());
155 break;
156 } 153 }
157 } 154 }
158 155
159 void IsCalloutAboveLauncherIcon(aura::Window* panel) { 156 void IsCalloutAboveLauncherIcon(aura::Window* panel) {
160 // Flush the message loop, since callout updates use a delayed task. 157 // Flush the message loop, since callout updates use a delayed task.
161 base::RunLoop().RunUntilIdle(); 158 base::RunLoop().RunUntilIdle();
162 views::Widget* widget = GetCalloutWidgetForPanel(panel); 159 views::Widget* widget = GetCalloutWidgetForPanel(panel);
163 160
164 Shelf* shelf = Shelf::ForWindow(panel); 161 Shelf* shelf = Shelf::ForWindow(panel);
165 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); 162 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel);
166 ASSERT_FALSE(icon_bounds.IsEmpty()); 163 ASSERT_FALSE(icon_bounds.IsEmpty());
167 164
168 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); 165 gfx::Rect panel_bounds = panel->GetBoundsInScreen();
169 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); 166 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen();
170 ASSERT_FALSE(icon_bounds.IsEmpty()); 167 ASSERT_FALSE(icon_bounds.IsEmpty());
171 168
172 EXPECT_TRUE(widget->IsVisible()); 169 EXPECT_TRUE(widget->IsVisible());
173 170
174 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); 171 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow());
175 switch (alignment) { 172 switch (alignment) {
176 case SHELF_ALIGNMENT_BOTTOM: 173 case SHELF_ALIGNMENT_BOTTOM:
177 EXPECT_EQ(panel_bounds.bottom(), callout_bounds.y()); 174 EXPECT_EQ(panel_bounds.bottom(), callout_bounds.y());
178 break; 175 break;
179 case SHELF_ALIGNMENT_LEFT: 176 case SHELF_ALIGNMENT_LEFT:
180 EXPECT_EQ(panel_bounds.x(), callout_bounds.right()); 177 EXPECT_EQ(panel_bounds.x(), callout_bounds.right());
181 break; 178 break;
182 case SHELF_ALIGNMENT_RIGHT: 179 case SHELF_ALIGNMENT_RIGHT:
183 EXPECT_EQ(panel_bounds.right(), callout_bounds.x()); 180 EXPECT_EQ(panel_bounds.right(), callout_bounds.x());
184 break; 181 break;
185 case SHELF_ALIGNMENT_TOP:
186 EXPECT_EQ(panel_bounds.y(), callout_bounds.bottom());
187 break;
188 } 182 }
189 183
190 if (IsHorizontal(alignment)) { 184 if (IsHorizontal(alignment)) {
191 EXPECT_NEAR(icon_bounds.CenterPoint().x(), 185 EXPECT_NEAR(icon_bounds.CenterPoint().x(),
192 widget->GetWindowBoundsInScreen().CenterPoint().x(), 186 widget->GetWindowBoundsInScreen().CenterPoint().x(),
193 1); 187 1);
194 } else { 188 } else {
195 EXPECT_NEAR(icon_bounds.CenterPoint().y(), 189 EXPECT_NEAR(icon_bounds.CenterPoint().y(),
196 widget->GetWindowBoundsInScreen().CenterPoint().y(), 190 widget->GetWindowBoundsInScreen().CenterPoint().y(),
197 1); 191 1);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 243 }
250 244
251 ShelfView* GetShelfView(Shelf* shelf) { 245 ShelfView* GetShelfView(Shelf* shelf) {
252 return test::ShelfTestAPI(shelf).shelf_view(); 246 return test::ShelfTestAPI(shelf).shelf_view();
253 } 247 }
254 248
255 private: 249 private:
256 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; 250 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_;
257 251
258 bool IsHorizontal(ShelfAlignment alignment) { 252 bool IsHorizontal(ShelfAlignment alignment) {
259 return alignment == SHELF_ALIGNMENT_BOTTOM || 253 return alignment == SHELF_ALIGNMENT_BOTTOM;
260 alignment == SHELF_ALIGNMENT_TOP;
261 } 254 }
262 255
263 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); 256 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest);
264 }; 257 };
265 258
266 class PanelLayoutManagerTextDirectionTest 259 class PanelLayoutManagerTextDirectionTest
267 : public PanelLayoutManagerTest, 260 : public PanelLayoutManagerTest,
268 public testing::WithParamInterface<bool> { 261 public testing::WithParamInterface<bool> {
269 public: 262 public:
270 PanelLayoutManagerTextDirectionTest() : is_rtl_(GetParam()) {} 263 PanelLayoutManagerTextDirectionTest() : is_rtl_(GetParam()) {}
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 685
693 IsPanelAboveLauncherIcon(p1_d2.get()); 686 IsPanelAboveLauncherIcon(p1_d2.get());
694 IsCalloutAboveLauncherIcon(p1_d2.get()); 687 IsCalloutAboveLauncherIcon(p1_d2.get());
695 688
696 SetAlignment(root_windows[1], SHELF_ALIGNMENT_RIGHT); 689 SetAlignment(root_windows[1], SHELF_ALIGNMENT_RIGHT);
697 IsPanelAboveLauncherIcon(p1_d2.get()); 690 IsPanelAboveLauncherIcon(p1_d2.get());
698 IsCalloutAboveLauncherIcon(p1_d2.get()); 691 IsCalloutAboveLauncherIcon(p1_d2.get());
699 SetAlignment(root_windows[1], SHELF_ALIGNMENT_LEFT); 692 SetAlignment(root_windows[1], SHELF_ALIGNMENT_LEFT);
700 IsPanelAboveLauncherIcon(p1_d2.get()); 693 IsPanelAboveLauncherIcon(p1_d2.get());
701 IsCalloutAboveLauncherIcon(p1_d2.get()); 694 IsCalloutAboveLauncherIcon(p1_d2.get());
702 SetAlignment(root_windows[1], SHELF_ALIGNMENT_TOP);
703 IsPanelAboveLauncherIcon(p1_d2.get());
704 IsCalloutAboveLauncherIcon(p1_d2.get());
705 } 695 }
706 696
707 TEST_F(PanelLayoutManagerTest, AlignmentLeft) { 697 TEST_F(PanelLayoutManagerTest, AlignmentLeft) {
708 gfx::Rect bounds(0, 0, 201, 201); 698 gfx::Rect bounds(0, 0, 201, 201);
709 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds)); 699 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds));
710 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT); 700 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT);
711 IsPanelAboveLauncherIcon(w.get()); 701 IsPanelAboveLauncherIcon(w.get());
712 IsCalloutAboveLauncherIcon(w.get()); 702 IsCalloutAboveLauncherIcon(w.get());
713 } 703 }
714 704
715 TEST_F(PanelLayoutManagerTest, AlignmentRight) { 705 TEST_F(PanelLayoutManagerTest, AlignmentRight) {
716 gfx::Rect bounds(0, 0, 201, 201); 706 gfx::Rect bounds(0, 0, 201, 201);
717 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds)); 707 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds));
718 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); 708 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT);
719 IsPanelAboveLauncherIcon(w.get()); 709 IsPanelAboveLauncherIcon(w.get());
720 IsCalloutAboveLauncherIcon(w.get()); 710 IsCalloutAboveLauncherIcon(w.get());
721 } 711 }
722 712
723 TEST_F(PanelLayoutManagerTest, AlignmentTop) {
724 gfx::Rect bounds(0, 0, 201, 201);
725 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds));
726 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_TOP);
727 IsPanelAboveLauncherIcon(w.get());
728 IsCalloutAboveLauncherIcon(w.get());
729 }
730
731 // Tests that panels will hide and restore their state with the shelf visibility 713 // Tests that panels will hide and restore their state with the shelf visibility
732 // state. This ensures that entering full-screen mode will hide your panels 714 // state. This ensures that entering full-screen mode will hide your panels
733 // until you leave it. 715 // until you leave it.
734 TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) { 716 TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) {
735 gfx::Rect bounds(0, 0, 201, 201); 717 gfx::Rect bounds(0, 0, 201, 201);
736 718
737 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 719 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds));
738 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 720 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds));
739 scoped_ptr<aura::Window> w3; 721 scoped_ptr<aura::Window> w3;
740 // Minimize w2. 722 // Minimize w2.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT); 806 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT);
825 bounds = w->bounds(); 807 bounds = w->bounds();
826 touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6)); 808 touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6));
827 target = targeter->FindTargetForEvent(root, &touch); 809 target = targeter->FindTargetForEvent(root, &touch);
828 EXPECT_EQ(w.get(), target); 810 EXPECT_EQ(w.get(), target);
829 811
830 // Hit test outside the left edge with a left-aligned shelf. 812 // Hit test outside the left edge with a left-aligned shelf.
831 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); 813 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5));
832 target = targeter->FindTargetForEvent(root, &touch); 814 target = targeter->FindTargetForEvent(root, &touch);
833 EXPECT_NE(w.get(), target); 815 EXPECT_NE(w.get(), target);
834
835 // Hit test outside the left edge with a top-aligned shelf.
836 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_TOP);
837 bounds = w->bounds();
838 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5));
839 target = targeter->FindTargetForEvent(root, &touch);
840 EXPECT_EQ(w.get(), target);
841
842 // Hit test outside the top edge with a top-aligned shelf.
843 touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6));
844 target = targeter->FindTargetForEvent(root, &touch);
845 EXPECT_NE(w.get(), target);
846 } 816 }
847 817
848 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, 818 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest,
849 testing::Bool()); 819 testing::Bool());
850 820
851 } // namespace ash 821 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_layout_manager.cc ('k') | ash/wm/panels/panel_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698