| 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/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 UpdateDisplay("800x800"); | 189 UpdateDisplay("800x800"); |
| 190 EXPECT_LT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 190 EXPECT_LT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
| 191 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); | 191 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); |
| 192 | 192 |
| 193 UpdateDisplay("400x400"); | 193 UpdateDisplay("400x400"); |
| 194 EXPECT_GT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 194 EXPECT_GT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
| 195 EXPECT_GT(baseline, alignment_delegate()->GetBaseLine()); | 195 EXPECT_GT(baseline, alignment_delegate()->GetBaseLine()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 TEST_F(AshPopupAlignmentDelegateTest, DockedMode) { | 198 TEST_F(AshPopupAlignmentDelegateTest, DockedMode) { |
| 199 if (!SupportsMultipleDisplays()) | |
| 200 return; | |
| 201 | |
| 202 const gfx::Rect toast_size(0, 0, 10, 10); | 199 const gfx::Rect toast_size(0, 0, 10, 10); |
| 203 UpdateDisplay("600x600"); | 200 UpdateDisplay("600x600"); |
| 204 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); | 201 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); |
| 205 int baseline = alignment_delegate()->GetBaseLine(); | 202 int baseline = alignment_delegate()->GetBaseLine(); |
| 206 | 203 |
| 207 // Emulate the docked mode; enter to an extended mode, then invoke | 204 // Emulate the docked mode; enter to an extended mode, then invoke |
| 208 // OnNativeDisplaysChanged() with the info for the secondary display only. | 205 // OnNativeDisplaysChanged() with the info for the secondary display only. |
| 209 UpdateDisplay("600x600,800x800"); | 206 UpdateDisplay("600x600,800x800"); |
| 210 | 207 |
| 211 std::vector<display::ManagedDisplayInfo> new_info; | 208 std::vector<display::ManagedDisplayInfo> new_info; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 226 // Simulate the system tray bubble being open. | 223 // Simulate the system tray bubble being open. |
| 227 const int kTrayHeight = 100; | 224 const int kTrayHeight = 100; |
| 228 alignment_delegate()->SetTrayBubbleHeight(kTrayHeight); | 225 alignment_delegate()->SetTrayBubbleHeight(kTrayHeight); |
| 229 | 226 |
| 230 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 227 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
| 231 EXPECT_EQ(baseline - kTrayHeight - message_center::kMarginBetweenItems, | 228 EXPECT_EQ(baseline - kTrayHeight - message_center::kMarginBetweenItems, |
| 232 alignment_delegate()->GetBaseLine()); | 229 alignment_delegate()->GetBaseLine()); |
| 233 } | 230 } |
| 234 | 231 |
| 235 TEST_F(AshPopupAlignmentDelegateTest, Extended) { | 232 TEST_F(AshPopupAlignmentDelegateTest, Extended) { |
| 236 if (!SupportsMultipleDisplays()) | |
| 237 return; | |
| 238 UpdateDisplay("600x600,800x800"); | 233 UpdateDisplay("600x600,800x800"); |
| 239 SetAlignmentDelegate( | 234 SetAlignmentDelegate( |
| 240 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); | 235 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); |
| 241 | 236 |
| 242 display::Display second_display = display_manager()->GetDisplayAt(1u); | 237 display::Display second_display = display_manager()->GetDisplayAt(1u); |
| 243 WmShelf* second_shelf = | 238 WmShelf* second_shelf = |
| 244 WmLookup::Get() | 239 WmLookup::Get() |
| 245 ->GetRootWindowControllerWithDisplayId(second_display.id()) | 240 ->GetRootWindowControllerWithDisplayId(second_display.id()) |
| 246 ->GetShelf(); | 241 ->GetShelf(); |
| 247 AshPopupAlignmentDelegate for_2nd_display(second_shelf); | 242 AshPopupAlignmentDelegate for_2nd_display(second_shelf); |
| 248 UpdateWorkArea(&for_2nd_display, second_display); | 243 UpdateWorkArea(&for_2nd_display, second_display); |
| 249 // Make sure that the toast position on the secondary display is | 244 // Make sure that the toast position on the secondary display is |
| 250 // positioned correctly. | 245 // positioned correctly. |
| 251 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10))); | 246 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10))); |
| 252 EXPECT_LT(700, for_2nd_display.GetBaseLine()); | 247 EXPECT_LT(700, for_2nd_display.GetBaseLine()); |
| 253 } | 248 } |
| 254 | 249 |
| 255 TEST_F(AshPopupAlignmentDelegateTest, Unified) { | 250 TEST_F(AshPopupAlignmentDelegateTest, Unified) { |
| 256 if (!SupportsMultipleDisplays()) | |
| 257 return; | |
| 258 display_manager()->SetUnifiedDesktopEnabled(true); | 251 display_manager()->SetUnifiedDesktopEnabled(true); |
| 259 | 252 |
| 260 // Reset the delegate as the primary display's shelf will be destroyed during | 253 // Reset the delegate as the primary display's shelf will be destroyed during |
| 261 // transition. | 254 // transition. |
| 262 SetAlignmentDelegate(nullptr); | 255 SetAlignmentDelegate(nullptr); |
| 263 | 256 |
| 264 UpdateDisplay("600x600,800x800"); | 257 UpdateDisplay("600x600,800x800"); |
| 265 SetAlignmentDelegate( | 258 SetAlignmentDelegate( |
| 266 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); | 259 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); |
| 267 | 260 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 283 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds); | 276 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds); |
| 284 int keyboard_baseline = alignment_delegate()->GetBaseLine(); | 277 int keyboard_baseline = alignment_delegate()->GetBaseLine(); |
| 285 EXPECT_NE(baseline, keyboard_baseline); | 278 EXPECT_NE(baseline, keyboard_baseline); |
| 286 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); | 279 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); |
| 287 | 280 |
| 288 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect()); | 281 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect()); |
| 289 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 282 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
| 290 } | 283 } |
| 291 | 284 |
| 292 } // namespace ash | 285 } // namespace ash |
| OLD | NEW |