Add Stubbed implementation of WebContentDecryptionModule* interfaces for unprefixed...
[chromium-blink-merge.git] / ash / screen_ash_unittest.cc
blobf5faf3b04edb90a086d8365877a6f4ec0d7fd7b8
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 if (!SupportsMultipleDisplays())
27 return;
29 UpdateDisplay("600x600,500x500");
30 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()->
31 SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
33 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
34 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
35 primary->Show();
36 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
37 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
38 secondary->Show();
40 // Maximized bounds
41 EXPECT_EQ("0,0 600x597",
42 ScreenAsh::GetMaximizedWindowBoundsInParent(
43 primary->GetNativeView()).ToString());
44 EXPECT_EQ("0,0 500x452",
45 ScreenAsh::GetMaximizedWindowBoundsInParent(
46 secondary->GetNativeView()).ToString());
48 // Display bounds
49 EXPECT_EQ("0,0 600x600",
50 ScreenAsh::GetDisplayBoundsInParent(
51 primary->GetNativeView()).ToString());
52 EXPECT_EQ("0,0 500x500",
53 ScreenAsh::GetDisplayBoundsInParent(
54 secondary->GetNativeView()).ToString());
56 // Work area bounds
57 EXPECT_EQ("0,0 600x597",
58 ScreenAsh::GetDisplayWorkAreaBoundsInParent(
59 primary->GetNativeView()).ToString());
60 EXPECT_EQ("0,0 500x452",
61 ScreenAsh::GetDisplayWorkAreaBoundsInParent(
62 secondary->GetNativeView()).ToString());
65 // Test verifies a stable handling of secondary screen widget changes
66 // (crbug.com/226132).
67 TEST_F(ScreenAshTest, StabilityTest) {
68 if (!SupportsMultipleDisplays())
69 return;
71 UpdateDisplay("600x600,500x500");
72 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
73 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
74 EXPECT_EQ(Shell::GetAllRootWindows()[1],
75 secondary->GetNativeView()->GetRootWindow());
76 secondary->Show();
77 secondary->Maximize();
78 secondary->Show();
79 secondary->SetFullscreen(true);
80 secondary->Hide();
81 secondary->Close();
84 TEST_F(ScreenAshTest, ConvertRect) {
85 if (!SupportsMultipleDisplays())
86 return;
88 UpdateDisplay("600x600,500x500");
90 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds(
91 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100));
92 primary->Show();
93 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds(
94 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100));
95 secondary->Show();
97 EXPECT_EQ(
98 "0,0 100x100",
99 ScreenAsh::ConvertRectFromScreen(
100 primary->GetNativeView(), gfx::Rect(10, 10, 100, 100)).ToString());
101 EXPECT_EQ(
102 "10,10 100x100",
103 ScreenAsh::ConvertRectFromScreen(
104 secondary->GetNativeView(), gfx::Rect(620, 20, 100, 100)).ToString());
106 EXPECT_EQ(
107 "40,40 100x100",
108 ScreenAsh::ConvertRectToScreen(
109 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString());
110 EXPECT_EQ(
111 "650,50 100x100",
112 ScreenAsh::ConvertRectToScreen(
113 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString());
116 } // namespace test
117 } // namespace ash