OLD | NEW |
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/common/system/web_notification/ash_popup_alignment_delegate.h" | 5 #include "ash/common/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/common/shelf/shelf_types.h" | 10 #include "ash/common/shelf/shelf_types.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 class AshPopupAlignmentDelegateTest : public test::AshTestBase { | 30 class AshPopupAlignmentDelegateTest : public test::AshTestBase { |
31 public: | 31 public: |
32 AshPopupAlignmentDelegateTest() {} | 32 AshPopupAlignmentDelegateTest() {} |
33 ~AshPopupAlignmentDelegateTest() override {} | 33 ~AshPopupAlignmentDelegateTest() override {} |
34 | 34 |
35 void SetUp() override { | 35 void SetUp() override { |
36 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 36 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
37 keyboard::switches::kEnableVirtualKeyboard); | 37 keyboard::switches::kEnableVirtualKeyboard); |
38 test::AshTestBase::SetUp(); | 38 test::AshTestBase::SetUp(); |
39 SetAlignmentDelegate( | 39 SetAlignmentDelegate( |
40 base::WrapUnique(new AshPopupAlignmentDelegate(GetPrimaryShelf()))); | 40 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); |
41 } | 41 } |
42 | 42 |
43 void TearDown() override { | 43 void TearDown() override { |
44 alignment_delegate_.reset(); | 44 alignment_delegate_.reset(); |
45 test::AshTestBase::TearDown(); | 45 test::AshTestBase::TearDown(); |
46 } | 46 } |
47 | 47 |
48 protected: | 48 protected: |
49 enum Position { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, OUTSIDE }; | 49 enum Position { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, OUTSIDE }; |
50 | 50 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 246 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
247 EXPECT_EQ(baseline - kTrayHeight - message_center::kMarginBetweenItems, | 247 EXPECT_EQ(baseline - kTrayHeight - message_center::kMarginBetweenItems, |
248 alignment_delegate()->GetBaseLine()); | 248 alignment_delegate()->GetBaseLine()); |
249 } | 249 } |
250 | 250 |
251 TEST_F(AshPopupAlignmentDelegateTest, Extended) { | 251 TEST_F(AshPopupAlignmentDelegateTest, Extended) { |
252 if (!SupportsMultipleDisplays()) | 252 if (!SupportsMultipleDisplays()) |
253 return; | 253 return; |
254 UpdateDisplay("600x600,800x800"); | 254 UpdateDisplay("600x600,800x800"); |
255 SetAlignmentDelegate( | 255 SetAlignmentDelegate( |
256 base::WrapUnique(new AshPopupAlignmentDelegate(GetPrimaryShelf()))); | 256 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); |
257 | 257 |
258 display::Display second_display = | 258 display::Display second_display = |
259 Shell::GetInstance()->display_manager()->GetDisplayAt(1u); | 259 Shell::GetInstance()->display_manager()->GetDisplayAt(1u); |
260 WmShelf* second_shelf = | 260 WmShelf* second_shelf = |
261 WmLookup::Get() | 261 WmLookup::Get() |
262 ->GetRootWindowControllerWithDisplayId(second_display.id()) | 262 ->GetRootWindowControllerWithDisplayId(second_display.id()) |
263 ->GetShelf(); | 263 ->GetShelf(); |
264 AshPopupAlignmentDelegate for_2nd_display(second_shelf); | 264 AshPopupAlignmentDelegate for_2nd_display(second_shelf); |
265 UpdateWorkArea(&for_2nd_display, second_display); | 265 UpdateWorkArea(&for_2nd_display, second_display); |
266 // Make sure that the toast position on the secondary display is | 266 // Make sure that the toast position on the secondary display is |
267 // positioned correctly. | 267 // positioned correctly. |
268 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10))); | 268 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10))); |
269 EXPECT_LT(700, for_2nd_display.GetBaseLine()); | 269 EXPECT_LT(700, for_2nd_display.GetBaseLine()); |
270 } | 270 } |
271 | 271 |
272 TEST_F(AshPopupAlignmentDelegateTest, Unified) { | 272 TEST_F(AshPopupAlignmentDelegateTest, Unified) { |
273 if (!SupportsMultipleDisplays()) | 273 if (!SupportsMultipleDisplays()) |
274 return; | 274 return; |
275 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 275 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
276 display_manager->SetUnifiedDesktopEnabled(true); | 276 display_manager->SetUnifiedDesktopEnabled(true); |
277 | 277 |
278 // Reset the delegate as the primary display's shelf will be destroyed during | 278 // Reset the delegate as the primary display's shelf will be destroyed during |
279 // transition. | 279 // transition. |
280 SetAlignmentDelegate(nullptr); | 280 SetAlignmentDelegate(nullptr); |
281 | 281 |
282 UpdateDisplay("600x600,800x800"); | 282 UpdateDisplay("600x600,800x800"); |
283 SetAlignmentDelegate( | 283 SetAlignmentDelegate( |
284 base::WrapUnique(new AshPopupAlignmentDelegate(GetPrimaryShelf()))); | 284 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); |
285 | 285 |
286 EXPECT_GT(600, | 286 EXPECT_GT(600, |
287 alignment_delegate()->GetToastOriginX(gfx::Rect(0, 0, 10, 10))); | 287 alignment_delegate()->GetToastOriginX(gfx::Rect(0, 0, 10, 10))); |
288 } | 288 } |
289 | 289 |
290 // Tests that when the keyboard is showing that notifications appear above it, | 290 // Tests that when the keyboard is showing that notifications appear above it, |
291 // and that they return to normal once the keyboard is gone. | 291 // and that they return to normal once the keyboard is gone. |
292 #if defined(OS_WIN) && !defined(USE_ASH) | 292 #if defined(OS_WIN) && !defined(USE_ASH) |
293 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 293 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
294 #define MAYBE_KeyboardShowing DISABLED_KeyboardShowing | 294 #define MAYBE_KeyboardShowing DISABLED_KeyboardShowing |
(...skipping 12 matching lines...) Expand all Loading... |
307 shelf->SetKeyboardBoundsForTesting(keyboard_bounds); | 307 shelf->SetKeyboardBoundsForTesting(keyboard_bounds); |
308 int keyboard_baseline = alignment_delegate()->GetBaseLine(); | 308 int keyboard_baseline = alignment_delegate()->GetBaseLine(); |
309 EXPECT_NE(baseline, keyboard_baseline); | 309 EXPECT_NE(baseline, keyboard_baseline); |
310 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); | 310 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); |
311 | 311 |
312 shelf->SetKeyboardBoundsForTesting(gfx::Rect()); | 312 shelf->SetKeyboardBoundsForTesting(gfx::Rect()); |
313 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 313 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
314 } | 314 } |
315 | 315 |
316 } // namespace ash | 316 } // namespace ash |
OLD | NEW |