Revert r196939 "Add Widevine CDM component installer."
[chromium-blink-merge.git] / ash / screen_ash_unittest.cc
blob7ef789b8abd98985a7b8fb1fe6dac5045fcc975d
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 "ash/screen_ash.h"
7 #include "ash/display/display_controller.h"
8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_layout_manager.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_util.h"
14 #include "ui/aura/env.h"
15 #include "ui/aura/root_window.h"
16 #include "ui/aura/window.h"
17 #include "ui/views/widget/widget.h"
18 #include "ui/views/widget/widget_delegate.h"
20 namespace ash {
21 namespace test {
23 typedef test::AshTestBase ScreenAshTest;
25 TEST_F(ScreenAshTest, Bounds) {
26 UpdateDisplay("600x600,500x500");
27 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()->
28 SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
30 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
31 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
32 primary->Show();
33 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
34 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
35 secondary->Show();
37 // Maximized bounds
38 EXPECT_EQ("0,0 600x597",
39 ScreenAsh::GetMaximizedWindowBoundsInParent(
40 primary->GetNativeView()).ToString());
41 if (Shell::IsLauncherPerDisplayEnabled()) {
42 EXPECT_EQ("0,0 500x452",
43 ScreenAsh::GetMaximizedWindowBoundsInParent(
44 secondary->GetNativeView()).ToString());
45 } else {
46 EXPECT_EQ("0,0 500x500",
47 ScreenAsh::GetMaximizedWindowBoundsInParent(
48 secondary->GetNativeView()).ToString());
51 // Display bounds
52 EXPECT_EQ("0,0 600x600",
53 ScreenAsh::GetDisplayBoundsInParent(
54 primary->GetNativeView()).ToString());
55 EXPECT_EQ("0,0 500x500",
56 ScreenAsh::GetDisplayBoundsInParent(
57 secondary->GetNativeView()).ToString());
59 // Work area bounds
60 EXPECT_EQ("0,0 600x597",
61 ScreenAsh::GetDisplayWorkAreaBoundsInParent(
62 primary->GetNativeView()).ToString());
63 if (Shell::IsLauncherPerDisplayEnabled()) {
64 EXPECT_EQ("0,0 500x452",
65 ScreenAsh::GetDisplayWorkAreaBoundsInParent(
66 secondary->GetNativeView()).ToString());
67 } else {
68 EXPECT_EQ("0,0 500x500",
69 ScreenAsh::GetDisplayWorkAreaBoundsInParent(
70 secondary->GetNativeView()).ToString());
74 // Test verifies a stable handling of secondary screen widget changes
75 // (crbug.com/226132).
76 TEST_F(ScreenAshTest, StabilityTest) {
77 UpdateDisplay("600x600,500x500");
78 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
79 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
80 EXPECT_EQ(Shell::GetAllRootWindows()[1],
81 secondary->GetNativeView()->GetRootWindow());
82 secondary->Show();
83 secondary->Maximize();
84 secondary->Show();
85 secondary->SetFullscreen(true);
86 secondary->Hide();
87 secondary->Close();
90 TEST_F(ScreenAshTest, ConvertRect) {
91 UpdateDisplay("600x600,500x500");
93 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
94 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
95 primary->Show();
96 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
97 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
98 secondary->Show();
100 EXPECT_EQ(
101 "0,0 100x100",
102 ScreenAsh::ConvertRectFromScreen(
103 primary->GetNativeView(), gfx::Rect(10, 10, 100, 100)).ToString());
104 EXPECT_EQ(
105 "10,10 100x100",
106 ScreenAsh::ConvertRectFromScreen(
107 secondary->GetNativeView(), gfx::Rect(620, 20, 100, 100)).ToString());
109 EXPECT_EQ(
110 "40,40 100x100",
111 ScreenAsh::ConvertRectToScreen(
112 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString());
113 EXPECT_EQ(
114 "650,50 100x100",
115 ScreenAsh::ConvertRectToScreen(
116 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString());
119 } // namespace test
120 } // namespace ash