Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc

Issue 2732573002: chromeos: moves more ash tests to run on mash (Closed)
Patch Set: fix bug ref Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "ash/common/wm_lookup.h" 11 #include "ash/common/wm_lookup.h"
12 #include "ash/common/wm_shell.h"
12 #include "ash/common/wm_window.h" 13 #include "ash/common/wm_window.h"
13 #include "ash/public/cpp/shelf_types.h" 14 #include "ash/public/cpp/shelf_types.h"
14 #include "ash/public/cpp/shell_window_ids.h" 15 #include "ash/public/cpp/shell_window_ids.h"
15 #include "ash/root_window_controller.h" 16 #include "ash/root_window_controller.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
18 #include "base/command_line.h" 19 #include "base/command_line.h"
19 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
20 #include "ui/display/manager/display_manager.h" 21 #include "ui/display/manager/display_manager.h"
21 #include "ui/display/screen.h" 22 #include "ui/display/screen.h"
22 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
23 #include "ui/keyboard/keyboard_switches.h" 24 #include "ui/keyboard/keyboard_switches.h"
24 #include "ui/keyboard/keyboard_util.h" 25 #include "ui/keyboard/keyboard_util.h"
25 #include "ui/message_center/message_center_style.h" 26 #include "ui/message_center/message_center_style.h"
26 27
27 namespace ash { 28 namespace ash {
28 29
29 // TODO(jamescook): Move this to //ash/common. http://crbug.com/620955
30 class AshPopupAlignmentDelegateTest : public test::AshTestBase { 30 class AshPopupAlignmentDelegateTest : public test::AshTestBase {
31 public: 31 public:
32 AshPopupAlignmentDelegateTest() {} 32 AshPopupAlignmentDelegateTest() {}
33 ~AshPopupAlignmentDelegateTest() override {} 33 ~AshPopupAlignmentDelegateTest() override {}
34 34
35 void SetUp() override { 35 void SetUp() override {
36 base::CommandLine::ForCurrentProcess()->AppendSwitch( 36 base::CommandLine::ForCurrentProcess()->AppendSwitch(
37 keyboard::switches::kEnableVirtualKeyboard); 37 keyboard::switches::kEnableVirtualKeyboard);
38 test::AshTestBase::SetUp(); 38 test::AshTestBase::SetUp();
39 SetAlignmentDelegate( 39 SetAlignmentDelegate(
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // TODO: needs unified mode. http://crbug.com/698024.
200 if (WmShell::Get()->IsRunningInMash())
201 return;
202
199 const gfx::Rect toast_size(0, 0, 10, 10); 203 const gfx::Rect toast_size(0, 0, 10, 10);
200 UpdateDisplay("600x600"); 204 UpdateDisplay("600x600");
201 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); 205 int origin_x = alignment_delegate()->GetToastOriginX(toast_size);
202 int baseline = alignment_delegate()->GetBaseLine(); 206 int baseline = alignment_delegate()->GetBaseLine();
203 207
204 // Emulate the docked mode; enter to an extended mode, then invoke 208 // Emulate the docked mode; enter to an extended mode, then invoke
205 // OnNativeDisplaysChanged() with the info for the secondary display only. 209 // OnNativeDisplaysChanged() with the info for the secondary display only.
206 UpdateDisplay("600x600,800x800"); 210 UpdateDisplay("600x600,800x800");
207 211
208 std::vector<display::ManagedDisplayInfo> new_info; 212 std::vector<display::ManagedDisplayInfo> new_info;
(...skipping 18 matching lines...) Expand all
227 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); 231 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
228 EXPECT_EQ(baseline - kTrayHeight - message_center::kMarginBetweenItems, 232 EXPECT_EQ(baseline - kTrayHeight - message_center::kMarginBetweenItems,
229 alignment_delegate()->GetBaseLine()); 233 alignment_delegate()->GetBaseLine());
230 } 234 }
231 235
232 TEST_F(AshPopupAlignmentDelegateTest, Extended) { 236 TEST_F(AshPopupAlignmentDelegateTest, Extended) {
233 UpdateDisplay("600x600,800x800"); 237 UpdateDisplay("600x600,800x800");
234 SetAlignmentDelegate( 238 SetAlignmentDelegate(
235 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); 239 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf()));
236 240
237 display::Display second_display = display_manager()->GetDisplayAt(1u); 241 display::Display second_display = GetSecondaryDisplay();
238 WmShelf* second_shelf = 242 WmShelf* second_shelf =
239 WmLookup::Get() 243 WmLookup::Get()
240 ->GetRootWindowControllerWithDisplayId(second_display.id()) 244 ->GetRootWindowControllerWithDisplayId(second_display.id())
241 ->GetShelf(); 245 ->GetShelf();
242 AshPopupAlignmentDelegate for_2nd_display(second_shelf); 246 AshPopupAlignmentDelegate for_2nd_display(second_shelf);
243 UpdateWorkArea(&for_2nd_display, second_display); 247 UpdateWorkArea(&for_2nd_display, second_display);
244 // Make sure that the toast position on the secondary display is 248 // Make sure that the toast position on the secondary display is
245 // positioned correctly. 249 // positioned correctly.
246 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10))); 250 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10)));
247 EXPECT_LT(700, for_2nd_display.GetBaseLine()); 251 EXPECT_LT(700, for_2nd_display.GetBaseLine());
248 } 252 }
249 253
250 TEST_F(AshPopupAlignmentDelegateTest, Unified) { 254 TEST_F(AshPopupAlignmentDelegateTest, Unified) {
255 // TODO: needs unified mode. http://crbug.com/698024.
256 if (WmShell::Get()->IsRunningInMash())
257 return;
258
251 display_manager()->SetUnifiedDesktopEnabled(true); 259 display_manager()->SetUnifiedDesktopEnabled(true);
252 260
253 // Reset the delegate as the primary display's shelf will be destroyed during 261 // Reset the delegate as the primary display's shelf will be destroyed during
254 // transition. 262 // transition.
255 SetAlignmentDelegate(nullptr); 263 SetAlignmentDelegate(nullptr);
256 264
257 UpdateDisplay("600x600,800x800"); 265 UpdateDisplay("600x600,800x800");
258 SetAlignmentDelegate( 266 SetAlignmentDelegate(
259 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf())); 267 base::MakeUnique<AshPopupAlignmentDelegate>(GetPrimaryShelf()));
260 268
(...skipping 15 matching lines...) Expand all
276 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds); 284 shelf->SetVirtualKeyboardBoundsForTesting(keyboard_bounds);
277 int keyboard_baseline = alignment_delegate()->GetBaseLine(); 285 int keyboard_baseline = alignment_delegate()->GetBaseLine();
278 EXPECT_NE(baseline, keyboard_baseline); 286 EXPECT_NE(baseline, keyboard_baseline);
279 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); 287 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline);
280 288
281 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect()); 289 shelf->SetVirtualKeyboardBoundsForTesting(gfx::Rect());
282 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); 290 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
283 } 291 }
284 292
285 } // namespace ash 293 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/toast/toast_manager_unittest.cc ('k') | ash/system/web_notification/web_notification_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698