1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "ash/display/display_manager.h"
9 #include "ash/launcher/launcher.h"
10 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h"
12 #include "ash/test/ash_test_base.h"
13 #include "ash/wm/window_properties.h"
14 #include "ash/wm/window_util.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "ui/aura/client/activation_client.h"
17 #include "ui/aura/root_window.h"
18 #include "ui/aura/window.h"
19 #include "ui/compositor/layer.h"
20 #include "ui/gfx/display.h"
21 #include "ui/gfx/insets.h"
22 #include "ui/gfx/screen.h"
23 #include "ui/views/corewm/shadow.h"
24 #include "ui/views/corewm/shadow_controller.h"
25 #include "ui/views/corewm/shadow_types.h"
26 #include "ui/views/widget/widget.h"
30 typedef ash::test::AshTestBase DIPTest
;
32 // Test if the WM sets correct work area under different density.
33 TEST_F(DIPTest
, WorkArea
) {
34 UpdateDisplay("1000x900*1.0f");
36 aura::RootWindow
* root
= Shell::GetPrimaryRootWindow();
37 const gfx::Display display
=
38 Shell::GetScreen()->GetDisplayNearestWindow(root
);
40 EXPECT_EQ("0,0 1000x900", display
.bounds().ToString());
41 gfx::Rect work_area
= display
.work_area();
42 EXPECT_EQ("0,0 1000x852", work_area
.ToString());
43 EXPECT_EQ("0,0,48,0", display
.bounds().InsetsFrom(work_area
).ToString());
45 UpdateDisplay("2000x1800*2.0f");
46 gfx::Screen
* screen
= Shell::GetScreen();
48 const gfx::Display display_2x
= screen
->GetDisplayNearestWindow(root
);
49 const internal::DisplayInfo display_info_2x
=
50 Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x
.id());
52 // The |bounds_in_pixel()| should report bounds in pixel coordinate.
53 EXPECT_EQ("1,1 2000x1800",
54 display_info_2x
.bounds_in_pixel().ToString());
56 // Aura and views coordinates are in DIP, so they their bounds do not change.
57 EXPECT_EQ("0,0 1000x900", display_2x
.bounds().ToString());
58 work_area
= display_2x
.work_area();
59 EXPECT_EQ("0,0 1000x852", work_area
.ToString());
60 EXPECT_EQ("0,0,48,0", display_2x
.bounds().InsetsFrom(work_area
).ToString());
62 // Sanity check if the workarea's inset hight is same as
63 // the launcher's height.
64 Launcher
* launcher
= Launcher::ForPrimaryDisplay();
66 display_2x
.bounds().InsetsFrom(work_area
).height(),
67 launcher
->shelf_widget()->GetNativeView()->layer()->bounds().height());