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