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

Side by Side Diff: ash/system/toast/toast_manager_unittest.cc

Issue 2370913002: Removes AshTestBase::SupportsHostWindowResize (Closed)
Patch Set: feedback Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/shelf/shelf_constants.h" 5 #include "ash/common/shelf/shelf_constants.h"
6 #include "ash/common/shelf/wm_shelf.h" 6 #include "ash/common/shelf/wm_shelf.h"
7 #include "ash/common/system/toast/toast_manager.h" 7 #include "ash/common/system/toast/toast_manager.h"
8 #include "ash/common/wm/wm_screen_util.h" 8 #include "ash/common/wm/wm_screen_util.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 ShowToast("DUMMY", ToastData::kInfiniteDuration); 165 ShowToast("DUMMY", ToastData::kInfiniteDuration);
166 EXPECT_EQ(1, GetToastSerial()); 166 EXPECT_EQ(1, GetToastSerial());
167 167
168 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); 168 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen();
169 gfx::Rect root_bounds = wm::GetDisplayBoundsWithShelf(shelf->GetWindow()); 169 gfx::Rect root_bounds = wm::GetDisplayBoundsWithShelf(shelf->GetWindow());
170 170
171 EXPECT_TRUE(toast_bounds.Intersects(shelf->GetUserWorkAreaBounds())); 171 EXPECT_TRUE(toast_bounds.Intersects(shelf->GetUserWorkAreaBounds()));
172 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1); 172 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1);
173 173
174 if (SupportsHostWindowResize()) { 174 gfx::Rect shelf_bounds = shelf->GetIdealBounds();
175 // If host resize is not supported, ShelfLayoutManager::GetIdealBounds() 175 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds));
176 // doesn't return correct value. 176 EXPECT_EQ(shelf_bounds.y() - 5, toast_bounds.bottom());
177 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); 177 EXPECT_EQ(root_bounds.bottom() - shelf_bounds.height() - 5,
178 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); 178 toast_bounds.bottom());
179 EXPECT_EQ(shelf_bounds.y() - 5, toast_bounds.bottom());
180 EXPECT_EQ(root_bounds.bottom() - shelf_bounds.height() - 5,
181 toast_bounds.bottom());
182 }
183 } 179 }
184 180
185 TEST_F(ToastManagerTest, PositionWithAutoHiddenBottomShelf) { 181 TEST_F(ToastManagerTest, PositionWithAutoHiddenBottomShelf) {
186 std::unique_ptr<aura::Window> window( 182 std::unique_ptr<aura::Window> window(
187 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); 183 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
188 184
189 WmShelf* shelf = GetPrimaryShelf(); 185 WmShelf* shelf = GetPrimaryShelf();
190 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); 186 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment());
191 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 187 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
192 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 188 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ShowToast("DUMMY", ToastData::kInfiniteDuration); 224 ShowToast("DUMMY", ToastData::kInfiniteDuration);
229 EXPECT_EQ(1, GetToastSerial()); 225 EXPECT_EQ(1, GetToastSerial());
230 226
231 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); 227 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen();
232 gfx::RectF precise_toast_bounds(toast_bounds); 228 gfx::RectF precise_toast_bounds(toast_bounds);
233 gfx::Rect root_bounds = wm::GetDisplayBoundsWithShelf(shelf->GetWindow()); 229 gfx::Rect root_bounds = wm::GetDisplayBoundsWithShelf(shelf->GetWindow());
234 230
235 EXPECT_TRUE(toast_bounds.Intersects(shelf->GetUserWorkAreaBounds())); 231 EXPECT_TRUE(toast_bounds.Intersects(shelf->GetUserWorkAreaBounds()));
236 EXPECT_EQ(root_bounds.bottom() - 5, toast_bounds.bottom()); 232 EXPECT_EQ(root_bounds.bottom() - 5, toast_bounds.bottom());
237 233
238 if (SupportsHostWindowResize()) { 234 gfx::Rect shelf_bounds = shelf->GetIdealBounds();
239 // If host resize is not supported then calling WmShelf::GetIdealBounds() 235 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds));
240 // doesn't return correct value. 236 EXPECT_EQ(round(shelf_bounds.right() +
241 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); 237 (root_bounds.width() - shelf_bounds.width()) / 2.0),
242 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); 238 round(precise_toast_bounds.CenterPoint().x()));
243 EXPECT_EQ(round(shelf_bounds.right() +
244 (root_bounds.width() - shelf_bounds.width()) / 2.0),
245 round(precise_toast_bounds.CenterPoint().x()));
246 }
247 } 239 }
248 240
249 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { 241 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) {
250 if (!SupportsMultipleDisplays()) 242 if (!SupportsMultipleDisplays())
251 return; 243 return;
252 244
253 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 245 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
254 display_manager->SetUnifiedDesktopEnabled(true); 246 display_manager->SetUnifiedDesktopEnabled(true);
255 UpdateDisplay("1000x500,0+600-100x500"); 247 UpdateDisplay("1000x500,0+600-100x500");
256 248
257 WmShelf* shelf = GetPrimaryShelf(); 249 WmShelf* shelf = GetPrimaryShelf();
258 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); 250 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment());
259 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 251 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
260 252
261 ShowToast("DUMMY", ToastData::kInfiniteDuration); 253 ShowToast("DUMMY", ToastData::kInfiniteDuration);
262 EXPECT_EQ(1, GetToastSerial()); 254 EXPECT_EQ(1, GetToastSerial());
263 255
264 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); 256 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen();
265 gfx::Rect root_bounds = wm::GetDisplayBoundsWithShelf(shelf->GetWindow()); 257 gfx::Rect root_bounds = wm::GetDisplayBoundsWithShelf(shelf->GetWindow());
266 258
267 EXPECT_TRUE(toast_bounds.Intersects(shelf->GetUserWorkAreaBounds())); 259 EXPECT_TRUE(toast_bounds.Intersects(shelf->GetUserWorkAreaBounds()));
268 EXPECT_TRUE(root_bounds.Contains(toast_bounds)); 260 EXPECT_TRUE(root_bounds.Contains(toast_bounds));
269 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1); 261 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1);
270 262
271 if (SupportsHostWindowResize()) { 263 gfx::Rect shelf_bounds = shelf->GetIdealBounds();
272 // If host resize is not supported then calling WmShelf::GetIdealBounds() 264 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds));
273 // doesn't return correct value. 265 EXPECT_EQ(shelf_bounds.y() - 5, toast_bounds.bottom());
274 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); 266 EXPECT_EQ(root_bounds.bottom() - shelf_bounds.height() - 5,
275 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); 267 toast_bounds.bottom());
276 EXPECT_EQ(shelf_bounds.y() - 5, toast_bounds.bottom());
277 EXPECT_EQ(root_bounds.bottom() - shelf_bounds.height() - 5,
278 toast_bounds.bottom());
279 }
280 } 268 }
281 269
282 TEST_F(ToastManagerTest, CancelToast) { 270 TEST_F(ToastManagerTest, CancelToast) {
283 std::string id1 = ShowToast("TEXT1", ToastData::kInfiniteDuration); 271 std::string id1 = ShowToast("TEXT1", ToastData::kInfiniteDuration);
284 std::string id2 = ShowToast("TEXT2", ToastData::kInfiniteDuration); 272 std::string id2 = ShowToast("TEXT2", ToastData::kInfiniteDuration);
285 std::string id3 = ShowToast("TEXT3", ToastData::kInfiniteDuration); 273 std::string id3 = ShowToast("TEXT3", ToastData::kInfiniteDuration);
286 274
287 // Confirm that the first toast is shown. 275 // Confirm that the first toast is shown.
288 EXPECT_EQ(base::ASCIIToUTF16("TEXT1"), GetCurrentText()); 276 EXPECT_EQ(base::ASCIIToUTF16("TEXT1"), GetCurrentText());
289 // Cancel the queued toast. 277 // Cancel the queued toast.
290 CancelToast(id2); 278 CancelToast(id2);
291 // Confirm that the shown toast is still visible. 279 // Confirm that the shown toast is still visible.
292 EXPECT_EQ(base::ASCIIToUTF16("TEXT1"), GetCurrentText()); 280 EXPECT_EQ(base::ASCIIToUTF16("TEXT1"), GetCurrentText());
293 // Cancel the shown toast. 281 // Cancel the shown toast.
294 CancelToast(id1); 282 CancelToast(id1);
295 // Confirm that the next toast is visible. 283 // Confirm that the next toast is visible.
296 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); 284 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText());
297 // Cancel the shown toast. 285 // Cancel the shown toast.
298 CancelToast(id3); 286 CancelToast(id3);
299 // Confirm that the shown toast disappears. 287 // Confirm that the shown toast disappears.
300 EXPECT_FALSE(GetCurrentOverlay()); 288 EXPECT_FALSE(GetCurrentOverlay());
301 // Confirm that only 1 toast is shown. 289 // Confirm that only 1 toast is shown.
302 EXPECT_EQ(2, GetToastSerial()); 290 EXPECT_EQ(2, GetToastSerial());
303 } 291 }
304 292
305 } // namespace ash 293 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell_unittest.cc ('k') | ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698