| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 gfx::Rect GetWorkArea() { return alignment_delegate_->work_area_; } | 88 gfx::Rect GetWorkArea() { return alignment_delegate_->work_area_; } |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 std::unique_ptr<AshPopupAlignmentDelegate> alignment_delegate_; | 91 std::unique_ptr<AshPopupAlignmentDelegate> alignment_delegate_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(AshPopupAlignmentDelegateTest); | 93 DISALLOW_COPY_AND_ASSIGN(AshPopupAlignmentDelegateTest); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 #if defined(OS_WIN) && !defined(USE_ASH) | 96 TEST_F(AshPopupAlignmentDelegateTest, ShelfAlignment) { |
| 97 // TODO(msw): Broken on Windows. http://crbug.com/584038 | |
| 98 #define MAYBE_ShelfAlignment DISABLED_ShelfAlignment | |
| 99 #else | |
| 100 #define MAYBE_ShelfAlignment ShelfAlignment | |
| 101 #endif | |
| 102 TEST_F(AshPopupAlignmentDelegateTest, MAYBE_ShelfAlignment) { | |
| 103 const gfx::Rect toast_size(0, 0, 10, 10); | 97 const gfx::Rect toast_size(0, 0, 10, 10); |
| 104 UpdateDisplay("600x600"); | 98 UpdateDisplay("600x600"); |
| 105 gfx::Point toast_point; | 99 gfx::Point toast_point; |
| 106 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); | 100 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); |
| 107 toast_point.set_y(alignment_delegate()->GetBaseLine()); | 101 toast_point.set_y(alignment_delegate()->GetBaseLine()); |
| 108 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); | 102 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); |
| 109 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 103 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 110 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | 104 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); |
| 111 | 105 |
| 112 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 106 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 173 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 180 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 174 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 181 | 175 |
| 182 // Right-side dock should not affect popup alignment | 176 // Right-side dock should not affect popup alignment |
| 183 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 177 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
| 184 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 178 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
| 185 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 179 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 186 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | 180 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); |
| 187 } | 181 } |
| 188 | 182 |
| 189 #if defined(OS_WIN) && !defined(USE_ASH) | 183 TEST_F(AshPopupAlignmentDelegateTest, DisplayResize) { |
| 190 // TODO(msw): Broken on Windows. http://crbug.com/584038 | |
| 191 #define MAYBE_DisplayResize DISABLED_DisplayResize | |
| 192 #else | |
| 193 #define MAYBE_DisplayResize DisplayResize | |
| 194 #endif | |
| 195 TEST_F(AshPopupAlignmentDelegateTest, MAYBE_DisplayResize) { | |
| 196 const gfx::Rect toast_size(0, 0, 10, 10); | 184 const gfx::Rect toast_size(0, 0, 10, 10); |
| 197 UpdateDisplay("600x600"); | 185 UpdateDisplay("600x600"); |
| 198 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); | 186 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); |
| 199 int baseline = alignment_delegate()->GetBaseLine(); | 187 int baseline = alignment_delegate()->GetBaseLine(); |
| 200 | 188 |
| 201 UpdateDisplay("800x800"); | 189 UpdateDisplay("800x800"); |
| 202 EXPECT_LT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 190 EXPECT_LT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
| 203 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); | 191 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); |
| 204 | 192 |
| 205 UpdateDisplay("400x400"); | 193 UpdateDisplay("400x400"); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 UpdateDisplay("600x600,800x800"); | 264 UpdateDisplay("600x600,800x800"); |
| 277 SetAlignmentDelegate( | 265 SetAlignmentDelegate( |
| 278 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); | 266 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); |
| 279 | 267 |
| 280 EXPECT_GT(600, | 268 EXPECT_GT(600, |
| 281 alignment_delegate()->GetToastOriginX(gfx::Rect(0, 0, 10, 10))); | 269 alignment_delegate()->GetToastOriginX(gfx::Rect(0, 0, 10, 10))); |
| 282 } | 270 } |
| 283 | 271 |
| 284 // Tests that when the keyboard is showing that notifications appear above it, | 272 // Tests that when the keyboard is showing that notifications appear above it, |
| 285 // and that they return to normal once the keyboard is gone. | 273 // and that they return to normal once the keyboard is gone. |
| 286 #if defined(OS_WIN) && !defined(USE_ASH) | 274 TEST_F(AshPopupAlignmentDelegateTest, KeyboardShowing) { |
| 287 // TODO(msw): Broken on Windows. http://crbug.com/584038 | |
| 288 #define MAYBE_KeyboardShowing DISABLED_KeyboardShowing | |
| 289 #else | |
| 290 #define MAYBE_KeyboardShowing KeyboardShowing | |
| 291 #endif | |
| 292 TEST_F(AshPopupAlignmentDelegateTest, MAYBE_KeyboardShowing) { | |
| 293 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); | 275 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); |
| 294 ASSERT_TRUE(keyboard::IsKeyboardOverscrollEnabled()); | 276 ASSERT_TRUE(keyboard::IsKeyboardOverscrollEnabled()); |
| 295 | 277 |
| 296 UpdateDisplay("600x600"); | 278 UpdateDisplay("600x600"); |
| 297 int baseline = alignment_delegate()->GetBaseLine(); | 279 int baseline = alignment_delegate()->GetBaseLine(); |
| 298 | 280 |
| 299 WmShelf* shelf = GetPrimaryShelf(); | 281 WmShelf* shelf = GetPrimaryShelf(); |
| 300 gfx::Rect keyboard_bounds(0, 300, 600, 300); | 282 gfx::Rect keyboard_bounds(0, 300, 600, 300); |
| 301 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds); | 283 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds); |
| 302 int keyboard_baseline = alignment_delegate()->GetBaseLine(); | 284 int keyboard_baseline = alignment_delegate()->GetBaseLine(); |
| 303 EXPECT_NE(baseline, keyboard_baseline); | 285 EXPECT_NE(baseline, keyboard_baseline); |
| 304 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); | 286 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); |
| 305 | 287 |
| 306 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect()); | 288 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect()); |
| 307 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 289 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
| 308 } | 290 } |
| 309 | 291 |
| 310 } // namespace ash | 292 } // namespace ash |
| OLD | NEW |