OLD | NEW |
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" | |
11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
12 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
13 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
14 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
15 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
17 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 17 #include "ui/display/manager/display_manager.h" |
18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 | 21 |
22 class DummyEvent : public ui::Event { | 22 class DummyEvent : public ui::Event { |
23 public: | 23 public: |
24 DummyEvent() : Event(ui::ET_UNKNOWN, base::TimeTicks(), 0) {} | 24 DummyEvent() : Event(ui::ET_UNKNOWN, base::TimeTicks(), 0) {} |
25 ~DummyEvent() override {} | 25 ~DummyEvent() override {} |
26 }; | 26 }; |
27 | 27 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); | 233 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); |
234 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); | 234 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); |
235 EXPECT_NEAR( | 235 EXPECT_NEAR( |
236 shelf_bounds.right() + (root_bounds.width() - shelf_bounds.width()) / 2.0, | 236 shelf_bounds.right() + (root_bounds.width() - shelf_bounds.width()) / 2.0, |
237 precise_toast_bounds.CenterPoint().x(), 1.f /* accepted error */); | 237 precise_toast_bounds.CenterPoint().x(), 1.f /* accepted error */); |
238 } | 238 } |
239 | 239 |
240 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { | 240 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { |
241 if (!SupportsMultipleDisplays()) | 241 if (!SupportsMultipleDisplays()) |
242 return; | 242 return; |
243 | 243 display_manager()->SetUnifiedDesktopEnabled(true); |
244 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | |
245 display_manager->SetUnifiedDesktopEnabled(true); | |
246 UpdateDisplay("1000x500,0+600-100x500"); | 244 UpdateDisplay("1000x500,0+600-100x500"); |
247 | 245 |
248 WmShelf* shelf = GetPrimaryShelf(); | 246 WmShelf* shelf = GetPrimaryShelf(); |
249 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); | 247 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); |
250 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 248 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
251 | 249 |
252 ShowToast("DUMMY", ToastData::kInfiniteDuration); | 250 ShowToast("DUMMY", ToastData::kInfiniteDuration); |
253 EXPECT_EQ(1, GetToastSerial()); | 251 EXPECT_EQ(1, GetToastSerial()); |
254 | 252 |
255 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); | 253 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); |
(...skipping 27 matching lines...) Expand all Loading... |
283 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); | 281 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); |
284 // Cancel the shown toast. | 282 // Cancel the shown toast. |
285 CancelToast(id3); | 283 CancelToast(id3); |
286 // Confirm that the shown toast disappears. | 284 // Confirm that the shown toast disappears. |
287 EXPECT_FALSE(GetCurrentOverlay()); | 285 EXPECT_FALSE(GetCurrentOverlay()); |
288 // Confirm that only 1 toast is shown. | 286 // Confirm that only 1 toast is shown. |
289 EXPECT_EQ(2, GetToastSerial()); | 287 EXPECT_EQ(2, GetToastSerial()); |
290 } | 288 } |
291 | 289 |
292 } // namespace ash | 290 } // namespace ash |
OLD | NEW |