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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 // Create a window, otherwise autohide doesn't work. | 146 // Create a window, otherwise autohide doesn't work. |
147 std::unique_ptr<views::Widget> widget = CreateTestWidget( | 147 std::unique_ptr<views::Widget> widget = CreateTestWidget( |
148 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 50, 50)); | 148 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 50, 50)); |
149 WmShelf* shelf = GetPrimaryShelf(); | 149 WmShelf* shelf = GetPrimaryShelf(); |
150 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 150 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
151 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 151 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
152 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); | 152 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); |
153 } | 153 } |
154 | 154 |
155 // Verify that docked window doesn't affect the popup alignment. | |
156 TEST_F(AshPopupAlignmentDelegateTest, DockedWindow) { | |
157 const gfx::Rect toast_size(0, 0, 10, 10); | |
158 UpdateDisplay("600x600"); | |
159 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); | |
160 int baseline = alignment_delegate()->GetBaseLine(); | |
161 | |
162 std::unique_ptr<views::Widget> widget = CreateTestWidget( | |
163 nullptr, kShellWindowId_DockedContainer, gfx::Rect(0, 0, 50, 50)); | |
164 | |
165 // Left-side dock should not affect popup alignment | |
166 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | |
167 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | |
168 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | |
169 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | |
170 | |
171 // Force dock to right-side | |
172 WmShelf* shelf = GetPrimaryShelf(); | |
173 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | |
174 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | |
175 | |
176 // Right-side dock should not affect popup alignment | |
177 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | |
178 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | |
179 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | |
180 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | |
181 } | |
182 | |
183 TEST_F(AshPopupAlignmentDelegateTest, DisplayResize) { | 155 TEST_F(AshPopupAlignmentDelegateTest, DisplayResize) { |
184 const gfx::Rect toast_size(0, 0, 10, 10); | 156 const gfx::Rect toast_size(0, 0, 10, 10); |
185 UpdateDisplay("600x600"); | 157 UpdateDisplay("600x600"); |
186 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); | 158 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); |
187 int baseline = alignment_delegate()->GetBaseLine(); | 159 int baseline = alignment_delegate()->GetBaseLine(); |
188 | 160 |
189 UpdateDisplay("800x800"); | 161 UpdateDisplay("800x800"); |
190 EXPECT_LT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 162 EXPECT_LT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
191 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); | 163 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); |
192 | 164 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds); | 248 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds); |
277 int keyboard_baseline = alignment_delegate()->GetBaseLine(); | 249 int keyboard_baseline = alignment_delegate()->GetBaseLine(); |
278 EXPECT_NE(baseline, keyboard_baseline); | 250 EXPECT_NE(baseline, keyboard_baseline); |
279 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); | 251 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); |
280 | 252 |
281 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect()); | 253 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect()); |
282 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 254 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
283 } | 255 } |
284 | 256 |
285 } // namespace ash | 257 } // namespace ash |
OLD | NEW |