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

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

Issue 2103603002: mash: Remove StatusAreaWidget references from system tray classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments, rename SetSystemTrayHeight to SetTrayBubbleHeight Created 4 years, 5 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/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/shelf_types.h" 10 #include "ash/common/shelf/shelf_types.h"
11 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/shell_window_ids.h" 12 #include "ash/common/shell_window_ids.h"
13 #include "ash/common/wm_lookup.h" 13 #include "ash/common/wm_lookup.h"
14 #include "ash/common/wm_root_window_controller.h" 14 #include "ash/common/wm_root_window_controller.h"
15 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
16 #include "ash/common/wm_window.h" 16 #include "ash/common/wm_window.h"
17 #include "ash/display/display_manager.h" 17 #include "ash/display/display_manager.h"
18 #include "ash/screen_util.h"
19 #include "ash/shell.h" 18 #include "ash/shell.h"
20 #include "ash/test/ash_test_base.h" 19 #include "ash/test/ash_test_base.h"
21 #include "base/command_line.h" 20 #include "base/command_line.h"
22 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
23 #include "ui/display/screen.h" 22 #include "ui/display/screen.h"
24 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
25 #include "ui/keyboard/keyboard_switches.h" 24 #include "ui/keyboard/keyboard_switches.h"
26 #include "ui/keyboard/keyboard_util.h" 25 #include "ui/keyboard/keyboard_util.h"
27 #include "ui/message_center/message_center_style.h" 26 #include "ui/message_center/message_center_style.h"
28 27
29 namespace ash { 28 namespace ash {
30 29
30 // TODO(jamescook): Move this to //ash/common. http://crbug.com/620955
31 class AshPopupAlignmentDelegateTest : public test::AshTestBase { 31 class AshPopupAlignmentDelegateTest : public test::AshTestBase {
32 public: 32 public:
33 AshPopupAlignmentDelegateTest() {} 33 AshPopupAlignmentDelegateTest() {}
34 ~AshPopupAlignmentDelegateTest() override {} 34 ~AshPopupAlignmentDelegateTest() override {}
35 35
36 void SetUp() override { 36 void SetUp() override {
37 base::CommandLine::ForCurrentProcess()->AppendSwitch( 37 base::CommandLine::ForCurrentProcess()->AppendSwitch(
38 keyboard::switches::kEnableVirtualKeyboard); 38 keyboard::switches::kEnableVirtualKeyboard);
39 test::AshTestBase::SetUp(); 39 test::AshTestBase::SetUp();
40 SetAlignmentDelegate( 40 SetAlignmentDelegate(
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 EXPECT_LT(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); 248 EXPECT_LT(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
249 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine()); 249 EXPECT_LT(baseline, alignment_delegate()->GetBaseLine());
250 } 250 }
251 251
252 TEST_F(AshPopupAlignmentDelegateTest, TrayHeight) { 252 TEST_F(AshPopupAlignmentDelegateTest, TrayHeight) {
253 const gfx::Rect toast_size(0, 0, 10, 10); 253 const gfx::Rect toast_size(0, 0, 10, 10);
254 UpdateDisplay("600x600"); 254 UpdateDisplay("600x600");
255 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); 255 int origin_x = alignment_delegate()->GetToastOriginX(toast_size);
256 int baseline = alignment_delegate()->GetBaseLine(); 256 int baseline = alignment_delegate()->GetBaseLine();
257 257
258 // Simulate the system tray bubble being open.
258 const int kTrayHeight = 100; 259 const int kTrayHeight = 100;
259 alignment_delegate()->SetSystemTrayHeight(kTrayHeight); 260 alignment_delegate()->SetTrayBubbleHeight(kTrayHeight);
260 261
261 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); 262 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
262 EXPECT_EQ(baseline - kTrayHeight - message_center::kMarginBetweenItems, 263 EXPECT_EQ(baseline - kTrayHeight - message_center::kMarginBetweenItems,
263 alignment_delegate()->GetBaseLine()); 264 alignment_delegate()->GetBaseLine());
264 } 265 }
265 266
266 TEST_F(AshPopupAlignmentDelegateTest, Extended) { 267 TEST_F(AshPopupAlignmentDelegateTest, Extended) {
267 if (!SupportsMultipleDisplays()) 268 if (!SupportsMultipleDisplays())
268 return; 269 return;
269 UpdateDisplay("600x600,800x800"); 270 UpdateDisplay("600x600,800x800");
270 SetAlignmentDelegate( 271 SetAlignmentDelegate(
271 base::WrapUnique(new AshPopupAlignmentDelegate(GetPrimaryShelf()))); 272 base::WrapUnique(new AshPopupAlignmentDelegate(GetPrimaryShelf())));
272 273
273 display::Display second_display = ScreenUtil::GetSecondaryDisplay(); 274 display::Display second_display =
275 Shell::GetInstance()->display_manager()->GetDisplayAt(1u);
274 WmShelf* second_shelf = 276 WmShelf* second_shelf =
275 WmLookup::Get() 277 WmLookup::Get()
276 ->GetRootWindowControllerWithDisplayId(second_display.id()) 278 ->GetRootWindowControllerWithDisplayId(second_display.id())
277 ->GetShelf(); 279 ->GetShelf();
278 AshPopupAlignmentDelegate for_2nd_display(second_shelf); 280 AshPopupAlignmentDelegate for_2nd_display(second_shelf);
279 UpdateWorkArea(&for_2nd_display, second_display); 281 UpdateWorkArea(&for_2nd_display, second_display);
280 // Make sure that the toast position on the secondary display is 282 // Make sure that the toast position on the secondary display is
281 // positioned correctly. 283 // positioned correctly.
282 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10))); 284 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10)));
283 EXPECT_LT(700, for_2nd_display.GetBaseLine()); 285 EXPECT_LT(700, for_2nd_display.GetBaseLine());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 shelf->SetKeyboardBoundsForTesting(keyboard_bounds); 323 shelf->SetKeyboardBoundsForTesting(keyboard_bounds);
322 int keyboard_baseline = alignment_delegate()->GetBaseLine(); 324 int keyboard_baseline = alignment_delegate()->GetBaseLine();
323 EXPECT_NE(baseline, keyboard_baseline); 325 EXPECT_NE(baseline, keyboard_baseline);
324 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); 326 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline);
325 327
326 shelf->SetKeyboardBoundsForTesting(gfx::Rect()); 328 shelf->SetKeyboardBoundsForTesting(gfx::Rect());
327 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); 329 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
328 } 330 }
329 331
330 } // namespace ash 332 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/ash_popup_alignment_delegate.cc ('k') | ash/system/web_notification/web_notification_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698