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

Side by Side Diff: ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc

Issue 2020623004: ash: Move shelf alignment and auto-hide calls from Shell to Shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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_unittest.cc ('k') | ash/sysui/context_menu_mus.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/system/web_notification/ash_popup_alignment_delegate.h" 5 #include "ash/system/web_notification/ash_popup_alignment_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 TEST_F(AshPopupAlignmentDelegateTest, MAYBE_ShelfAlignment) { 113 TEST_F(AshPopupAlignmentDelegateTest, MAYBE_ShelfAlignment) {
114 const gfx::Rect toast_size(0, 0, 10, 10); 114 const gfx::Rect toast_size(0, 0, 10, 10);
115 UpdateDisplay("600x600"); 115 UpdateDisplay("600x600");
116 gfx::Point toast_point; 116 gfx::Point toast_point;
117 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); 117 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size));
118 toast_point.set_y(alignment_delegate()->GetBaseLine()); 118 toast_point.set_y(alignment_delegate()->GetBaseLine());
119 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); 119 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point));
120 EXPECT_FALSE(alignment_delegate()->IsTopDown()); 120 EXPECT_FALSE(alignment_delegate()->IsTopDown());
121 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); 121 EXPECT_FALSE(alignment_delegate()->IsFromLeft());
122 122
123 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_RIGHT, 123 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT);
124 Shell::GetPrimaryRootWindow());
125 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); 124 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size));
126 toast_point.set_y(alignment_delegate()->GetBaseLine()); 125 toast_point.set_y(alignment_delegate()->GetBaseLine());
127 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); 126 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point));
128 EXPECT_FALSE(alignment_delegate()->IsTopDown()); 127 EXPECT_FALSE(alignment_delegate()->IsTopDown());
129 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); 128 EXPECT_FALSE(alignment_delegate()->IsFromLeft());
130 129
131 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, 130 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
132 Shell::GetPrimaryRootWindow());
133 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); 131 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size));
134 toast_point.set_y(alignment_delegate()->GetBaseLine()); 132 toast_point.set_y(alignment_delegate()->GetBaseLine());
135 EXPECT_EQ(BOTTOM_LEFT, GetPositionInDisplay(toast_point)); 133 EXPECT_EQ(BOTTOM_LEFT, GetPositionInDisplay(toast_point));
136 EXPECT_FALSE(alignment_delegate()->IsTopDown()); 134 EXPECT_FALSE(alignment_delegate()->IsTopDown());
137 EXPECT_TRUE(alignment_delegate()->IsFromLeft()); 135 EXPECT_TRUE(alignment_delegate()->IsFromLeft());
138 } 136 }
139 137
140 TEST_F(AshPopupAlignmentDelegateTest, LockScreen) { 138 TEST_F(AshPopupAlignmentDelegateTest, LockScreen) {
141 if (!SupportsHostWindowResize()) 139 if (!SupportsHostWindowResize())
142 return; 140 return;
143 141
144 const gfx::Rect toast_size(0, 0, 10, 10); 142 const gfx::Rect toast_size(0, 0, 10, 10);
145 143
146 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, 144 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
147 Shell::GetPrimaryRootWindow());
148 gfx::Point toast_point; 145 gfx::Point toast_point;
149 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); 146 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size));
150 toast_point.set_y(alignment_delegate()->GetBaseLine()); 147 toast_point.set_y(alignment_delegate()->GetBaseLine());
151 EXPECT_EQ(BOTTOM_LEFT, GetPositionInDisplay(toast_point)); 148 EXPECT_EQ(BOTTOM_LEFT, GetPositionInDisplay(toast_point));
152 EXPECT_FALSE(alignment_delegate()->IsTopDown()); 149 EXPECT_FALSE(alignment_delegate()->IsTopDown());
153 EXPECT_TRUE(alignment_delegate()->IsFromLeft()); 150 EXPECT_TRUE(alignment_delegate()->IsFromLeft());
154 151
155 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); 152 BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
156 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); 153 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size));
157 toast_point.set_y(alignment_delegate()->GetBaseLine()); 154 toast_point.set_y(alignment_delegate()->GetBaseLine());
158 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); 155 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point));
159 EXPECT_FALSE(alignment_delegate()->IsTopDown()); 156 EXPECT_FALSE(alignment_delegate()->IsTopDown());
160 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); 157 EXPECT_FALSE(alignment_delegate()->IsFromLeft());
161 } 158 }
162 159
163 TEST_F(AshPopupAlignmentDelegateTest, AutoHide) { 160 TEST_F(AshPopupAlignmentDelegateTest, AutoHide) {
164 const gfx::Rect toast_size(0, 0, 10, 10); 161 const gfx::Rect toast_size(0, 0, 10, 10);
165 UpdateDisplay("600x600"); 162 UpdateDisplay("600x600");
166 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); 163 int origin_x = alignment_delegate()->GetToastOriginX(toast_size);
167 int baseline = alignment_delegate()->GetBaseLine(); 164 int baseline = alignment_delegate()->GetBaseLine();
168 165
169 // Create a window, otherwise autohide doesn't work. 166 // Create a window, otherwise autohide doesn't work.
170 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 167 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
171 Shell::GetInstance()->SetShelfAutoHideBehavior( 168 Shelf* shelf = Shelf::ForPrimaryDisplay();
172 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 169 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
173 Shell::GetPrimaryRootWindow()); 170 shelf->shelf_layout_manager()->UpdateAutoHideStateNow();
174 Shelf::ForPrimaryDisplay()->shelf_layout_manager()->UpdateAutoHideStateNow();
175 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); 171 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
176 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); 172 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine());
177 } 173 }
178 174
179 // Verify that docked window doesn't affect the popup alignment. 175 // Verify that docked window doesn't affect the popup alignment.
180 TEST_F(AshPopupAlignmentDelegateTest, DockedWindow) { 176 TEST_F(AshPopupAlignmentDelegateTest, DockedWindow) {
181 const gfx::Rect toast_size(0, 0, 10, 10); 177 const gfx::Rect toast_size(0, 0, 10, 10);
182 UpdateDisplay("600x600"); 178 UpdateDisplay("600x600");
183 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); 179 int origin_x = alignment_delegate()->GetToastOriginX(toast_size);
184 int baseline = alignment_delegate()->GetBaseLine(); 180 int baseline = alignment_delegate()->GetBaseLine();
185 181
186 std::unique_ptr<aura::Window> window( 182 std::unique_ptr<aura::Window> window(
187 CreateTestWindowInShellWithBounds(gfx::Rect(0, 0, 50, 50))); 183 CreateTestWindowInShellWithBounds(gfx::Rect(0, 0, 50, 50)));
188 aura::Window* docked_container = Shell::GetContainer( 184 aura::Window* docked_container = Shell::GetContainer(
189 Shell::GetPrimaryRootWindow(), 185 Shell::GetPrimaryRootWindow(),
190 kShellWindowId_DockedContainer); 186 kShellWindowId_DockedContainer);
191 docked_container->AddChild(window.get()); 187 docked_container->AddChild(window.get());
192 188
193 // Left-side dock should not affect popup alignment 189 // Left-side dock should not affect popup alignment
194 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); 190 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
195 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); 191 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
196 EXPECT_FALSE(alignment_delegate()->IsTopDown()); 192 EXPECT_FALSE(alignment_delegate()->IsTopDown());
197 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); 193 EXPECT_FALSE(alignment_delegate()->IsFromLeft());
198 194
199 // Force dock to right-side 195 // Force dock to right-side
200 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, 196 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
201 Shell::GetPrimaryRootWindow()); 197 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM);
202 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_BOTTOM,
203 Shell::GetPrimaryRootWindow());
204 198
205 // Right-side dock should not affect popup alignment 199 // Right-side dock should not affect popup alignment
206 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); 200 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
207 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); 201 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
208 EXPECT_FALSE(alignment_delegate()->IsTopDown()); 202 EXPECT_FALSE(alignment_delegate()->IsTopDown());
209 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); 203 EXPECT_FALSE(alignment_delegate()->IsFromLeft());
210 } 204 }
211 205
212 #if defined(OS_WIN) && !defined(USE_ASH) 206 #if defined(OS_WIN) && !defined(USE_ASH)
213 // TODO(msw): Broken on Windows. http://crbug.com/584038 207 // TODO(msw): Broken on Windows. http://crbug.com/584038
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 SetKeyboardBounds(keyboard_bounds); 319 SetKeyboardBounds(keyboard_bounds);
326 int keyboard_baseline = alignment_delegate()->GetBaseLine(); 320 int keyboard_baseline = alignment_delegate()->GetBaseLine();
327 EXPECT_NE(baseline, keyboard_baseline); 321 EXPECT_NE(baseline, keyboard_baseline);
328 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); 322 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline);
329 323
330 SetKeyboardBounds(gfx::Rect()); 324 SetKeyboardBounds(gfx::Rect());
331 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); 325 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
332 } 326 }
333 327
334 } // namespace ash 328 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell_unittest.cc ('k') | ash/sysui/context_menu_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698