Removed 'anonymous' from namespace, added whitespace in thread_restrictions.cc
[chromium-blink-merge.git] / ash / dip_unittest.cc
bloba922da4200f2a29ce96aea4d504664dc919b5cc5
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.
5 #include <algorithm>
6 #include <vector>
8 #include "ash/ash_switches.h"
9 #include "ash/display/display_manager.h"
10 #include "ash/shelf/shelf.h"
11 #include "ash/shelf/shelf_widget.h"
12 #include "ash/shell.h"
13 #include "ash/test/ash_test_base.h"
14 #include "ash/wm/window_properties.h"
15 #include "ash/wm/window_util.h"
16 #include "base/command_line.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "ui/aura/window.h"
19 #include "ui/aura/window_event_dispatcher.h"
20 #include "ui/compositor/layer.h"
21 #include "ui/gfx/display.h"
22 #include "ui/gfx/geometry/insets.h"
23 #include "ui/gfx/screen.h"
24 #include "ui/views/widget/widget.h"
25 #include "ui/wm/core/shadow.h"
26 #include "ui/wm/core/shadow_controller.h"
27 #include "ui/wm/core/shadow_types.h"
28 #include "ui/wm/public/activation_client.h"
30 namespace ash {
32 typedef ash::test::AshTestBase DIPTest;
34 // Test if the WM sets correct work area under different density.
35 TEST_F(DIPTest, WorkArea) {
36 UpdateDisplay("1000x900*1.0f");
38 aura::Window* root = Shell::GetPrimaryRootWindow();
39 const gfx::Display display =
40 Shell::GetScreen()->GetDisplayNearestWindow(root);
42 EXPECT_EQ("0,0 1000x900", display.bounds().ToString());
43 gfx::Rect work_area = display.work_area();
44 EXPECT_EQ("0,0 1000x853", work_area.ToString());
45 EXPECT_EQ("0,0,47,0", display.bounds().InsetsFrom(work_area).ToString());
47 UpdateDisplay("2000x1800*2.0f");
48 gfx::Screen* screen = Shell::GetScreen();
50 const gfx::Display display_2x = screen->GetDisplayNearestWindow(root);
51 const DisplayInfo display_info_2x =
52 Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x.id());
54 // The |bounds_in_pixel()| should report bounds in pixel coordinate.
55 EXPECT_EQ("1,1 2000x1800",
56 display_info_2x.bounds_in_native().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 1000x853", work_area.ToString());
62 EXPECT_EQ("0,0,47,0", display_2x.bounds().InsetsFrom(work_area).ToString());
64 // Sanity check if the workarea's inset hight is same as
65 // the shelf's height.
66 Shelf* shelf = Shelf::ForPrimaryDisplay();
67 EXPECT_EQ(
68 display_2x.bounds().InsetsFrom(work_area).height(),
69 shelf->shelf_widget()->GetNativeView()->layer()->bounds().height());
72 } // namespace ash