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/launcher/launcher.h"
10 #include "ash/test/ash_test_base.h"
11 #include "ash/wm/shadow.h"
12 #include "ash/wm/shadow_controller.h"
13 #include "ash/wm/shadow_types.h"
14 #include "ash/wm/window_properties.h"
15 #include "ash/wm/window_util.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "ui/aura/client/activation_client.h"
18 #include "ui/aura/root_window.h"
19 #include "ui/aura/window.h"
20 #include "ui/compositor/layer.h"
21 #include "ui/gfx/display.h"
22 #include "ui/gfx/insets.h"
23 #include "ui/gfx/screen.h"
24 #include "ui/views/widget/widget.h"
28 typedef ash::test::AshTestBase DIPTest
;
31 // Windows/Aura doesn't have DIP support in display yet.
32 #define MAYBE_WorkArea DISABLED_WorkArea
34 #define MAYBE_WorkArea WorkArea
37 // Test if the WM sets correct work area under different density.
38 TEST_F(DIPTest
, MAYBE_WorkArea
) {
39 ChangeDisplayConfig(1.0f
, gfx::Rect(0, 0, 1000, 900));
41 aura::RootWindow
* root
= Shell::GetPrimaryRootWindow();
42 const gfx::Display display
=
43 Shell::GetScreen()->GetDisplayNearestWindow(root
);
45 EXPECT_EQ("0,0 1000x900", display
.bounds().ToString());
46 gfx::Rect work_area
= display
.work_area();
47 EXPECT_EQ("0,0 1000x852", work_area
.ToString());
48 EXPECT_EQ("0,0,48,0", display
.bounds().InsetsFrom(work_area
).ToString());
50 ChangeDisplayConfig(2.0f
, gfx::Rect(0, 0, 2000, 1800));
52 const gfx::Display display_2x
=
53 Shell::GetScreen()->GetDisplayNearestWindow(root
);
55 // The |bounds_in_pixel()| should report bounds in pixel coordinate.
56 EXPECT_EQ("0,0 2000x1800", display_2x
.bounds_in_pixel().ToString());
58 // Aura and views coordinates are in DIP, so they their bounds do not change.
59 EXPECT_EQ("0,0 1000x900", display_2x
.bounds().ToString());
60 work_area
= display_2x
.work_area();
61 EXPECT_EQ("0,0 1000x852", work_area
.ToString());
62 EXPECT_EQ("0,0,48,0", display_2x
.bounds().InsetsFrom(work_area
).ToString());
64 // Sanity check if the workarea's inset hight is same as
65 // the launcher's height.
66 Launcher
* launcher
= Shell::GetInstance()->launcher();
68 display_2x
.bounds().InsetsFrom(work_area
).height(),
69 launcher
->widget()->GetNativeView()->layer()->bounds().height());