| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/screen_ash.h" | 5 #include "ash/screen_ash.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 12 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 13 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 #include "ui/views/widget/widget_delegate.h" | 16 #include "ui/views/widget/widget_delegate.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 namespace test { | 19 namespace test { |
| 20 | 20 |
| 21 typedef test::AshTestBase ScreenAshTest; | 21 typedef test::AshTestBase ScreenAshTest; |
| 22 | 22 |
| 23 TEST_F(ScreenAshTest, Bounds) { | 23 TEST_F(ScreenAshTest, Bounds) { |
| 24 UpdateDisplay("600x600,500x500"); | 24 UpdateDisplay("600x600,500x500"); |
| 25 Shell::GetPrimaryRootWindowController()->SetShelfAutoHideBehavior( | 25 Shell::GetPrimaryRootWindowController()->SetShelfAutoHideBehavior( |
| 26 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 26 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 27 | 27 |
| 28 views::Widget* primary = | 28 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( |
| 29 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100)); | 29 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); |
| 30 primary->Show(); | 30 primary->Show(); |
| 31 views::Widget* secondary = | 31 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( |
| 32 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100)); | 32 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); |
| 33 secondary->Show(); | 33 secondary->Show(); |
| 34 | 34 |
| 35 // Maximized bounds | 35 // Maximized bounds |
| 36 EXPECT_EQ("0,0 600x597", | 36 EXPECT_EQ("0,0 600x597", |
| 37 ScreenAsh::GetMaximizedWindowBoundsInParent( | 37 ScreenAsh::GetMaximizedWindowBoundsInParent( |
| 38 primary->GetNativeView()).ToString()); | 38 primary->GetNativeView()).ToString()); |
| 39 EXPECT_EQ("0,0 500x500", | 39 EXPECT_EQ("0,0 500x500", |
| 40 ScreenAsh::GetMaximizedWindowBoundsInParent( | 40 ScreenAsh::GetMaximizedWindowBoundsInParent( |
| 41 secondary->GetNativeView()).ToString()); | 41 secondary->GetNativeView()).ToString()); |
| 42 | 42 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 53 ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 53 ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 54 primary->GetNativeView()).ToString()); | 54 primary->GetNativeView()).ToString()); |
| 55 EXPECT_EQ("0,0 500x500", | 55 EXPECT_EQ("0,0 500x500", |
| 56 ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 56 ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 57 secondary->GetNativeView()).ToString()); | 57 secondary->GetNativeView()).ToString()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 TEST_F(ScreenAshTest, ConvertRect) { | 60 TEST_F(ScreenAshTest, ConvertRect) { |
| 61 UpdateDisplay("600x600,500x500"); | 61 UpdateDisplay("600x600,500x500"); |
| 62 | 62 |
| 63 views::Widget* primary = | 63 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( |
| 64 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100)); | 64 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); |
| 65 primary->Show(); | 65 primary->Show(); |
| 66 views::Widget* secondary = | 66 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( |
| 67 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100)); | 67 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); |
| 68 secondary->Show(); | 68 secondary->Show(); |
| 69 | 69 |
| 70 EXPECT_EQ( | 70 EXPECT_EQ( |
| 71 "0,0 100x100", | 71 "0,0 100x100", |
| 72 ScreenAsh::ConvertRectFromScreen( | 72 ScreenAsh::ConvertRectFromScreen( |
| 73 primary->GetNativeView(), gfx::Rect(10, 10, 100, 100)).ToString()); | 73 primary->GetNativeView(), gfx::Rect(10, 10, 100, 100)).ToString()); |
| 74 EXPECT_EQ( | 74 EXPECT_EQ( |
| 75 "10,10 100x100", | 75 "10,10 100x100", |
| 76 ScreenAsh::ConvertRectFromScreen( | 76 ScreenAsh::ConvertRectFromScreen( |
| 77 secondary->GetNativeView(), gfx::Rect(620, 20, 100, 100)).ToString()); | 77 secondary->GetNativeView(), gfx::Rect(620, 20, 100, 100)).ToString()); |
| 78 | 78 |
| 79 EXPECT_EQ( | 79 EXPECT_EQ( |
| 80 "40,40 100x100", | 80 "40,40 100x100", |
| 81 ScreenAsh::ConvertRectToScreen( | 81 ScreenAsh::ConvertRectToScreen( |
| 82 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); | 82 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); |
| 83 EXPECT_EQ( | 83 EXPECT_EQ( |
| 84 "650,50 100x100", | 84 "650,50 100x100", |
| 85 ScreenAsh::ConvertRectToScreen( | 85 ScreenAsh::ConvertRectToScreen( |
| 86 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); | 86 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace test | 89 } // namespace test |
| 90 } // namespace ash | 90 } // namespace ash |
| OLD | NEW |