| 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/system/web_notification/ash_popup_alignment_delegate.h" | 5 #include "ash/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/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 11 #include "ash/common/wm/wm_globals.h" | 12 #include "ash/common/wm/wm_globals.h" |
| 12 #include "ash/common/wm/wm_root_window_controller.h" | 13 #include "ash/common/wm/wm_root_window_controller.h" |
| 13 #include "ash/common/wm/wm_window.h" | 14 #include "ash/common/wm/wm_window.h" |
| 14 #include "ash/display/display_manager.h" | 15 #include "ash/display/display_manager.h" |
| 15 #include "ash/screen_util.h" | 16 #include "ash/screen_util.h" |
| 16 #include "ash/shelf/shelf.h" | 17 #include "ash/shelf/shelf.h" |
| 17 #include "ash/shelf/shelf_layout_manager.h" | 18 #include "ash/shelf/shelf_layout_manager.h" |
| 18 #include "ash/shelf/shelf_types.h" | |
| 19 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 20 #include "ash/test/ash_test_base.h" | 20 #include "ash/test/ash_test_base.h" |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
| 23 #include "ui/display/screen.h" | 23 #include "ui/display/screen.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
| 25 #include "ui/keyboard/keyboard_switches.h" | 25 #include "ui/keyboard/keyboard_switches.h" |
| 26 #include "ui/keyboard/keyboard_util.h" | 26 #include "ui/keyboard/keyboard_util.h" |
| 27 #include "ui/message_center/message_center_style.h" | 27 #include "ui/message_center/message_center_style.h" |
| 28 | 28 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 TEST_F(AshPopupAlignmentDelegateTest, MAYBE_ShelfAlignment) { | 130 TEST_F(AshPopupAlignmentDelegateTest, MAYBE_ShelfAlignment) { |
| 131 const gfx::Rect toast_size(0, 0, 10, 10); | 131 const gfx::Rect toast_size(0, 0, 10, 10); |
| 132 UpdateDisplay("600x600"); | 132 UpdateDisplay("600x600"); |
| 133 gfx::Point toast_point; | 133 gfx::Point toast_point; |
| 134 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); | 134 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); |
| 135 toast_point.set_y(alignment_delegate()->GetBaseLine()); | 135 toast_point.set_y(alignment_delegate()->GetBaseLine()); |
| 136 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); | 136 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); |
| 137 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 137 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 138 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | 138 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); |
| 139 | 139 |
| 140 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); | 140 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 141 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); | 141 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); |
| 142 toast_point.set_y(alignment_delegate()->GetBaseLine()); | 142 toast_point.set_y(alignment_delegate()->GetBaseLine()); |
| 143 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); | 143 EXPECT_EQ(BOTTOM_RIGHT, GetPositionInDisplay(toast_point)); |
| 144 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 144 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 145 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | 145 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); |
| 146 | 146 |
| 147 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 147 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 148 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); | 148 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); |
| 149 toast_point.set_y(alignment_delegate()->GetBaseLine()); | 149 toast_point.set_y(alignment_delegate()->GetBaseLine()); |
| 150 EXPECT_EQ(BOTTOM_LEFT, GetPositionInDisplay(toast_point)); | 150 EXPECT_EQ(BOTTOM_LEFT, GetPositionInDisplay(toast_point)); |
| 151 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 151 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 152 EXPECT_TRUE(alignment_delegate()->IsFromLeft()); | 152 EXPECT_TRUE(alignment_delegate()->IsFromLeft()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 TEST_F(AshPopupAlignmentDelegateTest, LockScreen) { | 155 TEST_F(AshPopupAlignmentDelegateTest, LockScreen) { |
| 156 if (!SupportsHostWindowResize()) | 156 if (!SupportsHostWindowResize()) |
| 157 return; | 157 return; |
| 158 | 158 |
| 159 const gfx::Rect toast_size(0, 0, 10, 10); | 159 const gfx::Rect toast_size(0, 0, 10, 10); |
| 160 | 160 |
| 161 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 161 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 162 gfx::Point toast_point; | 162 gfx::Point toast_point; |
| 163 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); | 163 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); |
| 164 toast_point.set_y(alignment_delegate()->GetBaseLine()); | 164 toast_point.set_y(alignment_delegate()->GetBaseLine()); |
| 165 EXPECT_EQ(BOTTOM_LEFT, GetPositionInDisplay(toast_point)); | 165 EXPECT_EQ(BOTTOM_LEFT, GetPositionInDisplay(toast_point)); |
| 166 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 166 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 167 EXPECT_TRUE(alignment_delegate()->IsFromLeft()); | 167 EXPECT_TRUE(alignment_delegate()->IsFromLeft()); |
| 168 | 168 |
| 169 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); | 169 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); |
| 170 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); | 170 toast_point.set_x(alignment_delegate()->GetToastOriginX(toast_size)); |
| 171 toast_point.set_y(alignment_delegate()->GetBaseLine()); | 171 toast_point.set_y(alignment_delegate()->GetBaseLine()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 200 std::unique_ptr<views::Widget> widget = | 200 std::unique_ptr<views::Widget> widget = |
| 201 CreateTestWidget(kShellWindowId_DockedContainer); | 201 CreateTestWidget(kShellWindowId_DockedContainer); |
| 202 | 202 |
| 203 // Left-side dock should not affect popup alignment | 203 // Left-side dock should not affect popup alignment |
| 204 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 204 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
| 205 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 205 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
| 206 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 206 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 207 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | 207 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); |
| 208 | 208 |
| 209 // Force dock to right-side | 209 // Force dock to right-side |
| 210 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); | 210 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 211 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM); | 211 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 212 | 212 |
| 213 // Right-side dock should not affect popup alignment | 213 // Right-side dock should not affect popup alignment |
| 214 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 214 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
| 215 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 215 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
| 216 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 216 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 217 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | 217 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 #if defined(OS_WIN) && !defined(USE_ASH) | 220 #if defined(OS_WIN) && !defined(USE_ASH) |
| 221 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 221 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 SetKeyboardBounds(keyboard_bounds); | 329 SetKeyboardBounds(keyboard_bounds); |
| 330 int keyboard_baseline = alignment_delegate()->GetBaseLine(); | 330 int keyboard_baseline = alignment_delegate()->GetBaseLine(); |
| 331 EXPECT_NE(baseline, keyboard_baseline); | 331 EXPECT_NE(baseline, keyboard_baseline); |
| 332 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); | 332 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); |
| 333 | 333 |
| 334 SetKeyboardBounds(gfx::Rect()); | 334 SetKeyboardBounds(gfx::Rect()); |
| 335 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 335 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
| 336 } | 336 } |
| 337 | 337 |
| 338 } // namespace ash | 338 } // namespace ash |
| OLD | NEW |