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 "ui/views/widget/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
12 #include "ui/aura/layout_manager.h" | 12 #include "ui/aura/layout_manager.h" |
13 #include "ui/aura/monitor_manager.h" | 13 #include "ui/aura/monitor_manager.h" |
14 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
15 #include "ui/aura/test/single_monitor_manager.h" | 15 #include "ui/aura/single_monitor_manager.h" |
16 #include "ui/aura/test/test_stacking_client.h" | 16 #include "ui/aura/test/test_stacking_client.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 #include "ui/views/widget/root_view.h" | 18 #include "ui/views/widget/root_view.h" |
19 #include "ui/views/widget/widget_delegate.h" | 19 #include "ui/views/widget/widget_delegate.h" |
20 | 20 |
21 #if defined(USE_ASH) | 21 #if defined(USE_ASH) |
22 #include "ui/aura/test/test_screen.h" | 22 #include "ui/aura/test/test_screen.h" |
23 #endif | 23 #endif |
24 | 24 |
25 namespace views { | 25 namespace views { |
26 namespace { | 26 namespace { |
27 | 27 |
28 NativeWidgetAura* Init(aura::Window* parent, Widget* widget) { | 28 NativeWidgetAura* Init(aura::Window* parent, Widget* widget) { |
29 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | 29 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
30 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 30 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
31 params.parent = parent; | 31 params.parent = parent; |
32 widget->Init(params); | 32 widget->Init(params); |
33 return static_cast<NativeWidgetAura*>(widget->native_widget()); | 33 return static_cast<NativeWidgetAura*>(widget->native_widget()); |
34 } | 34 } |
35 | 35 |
36 class NativeWidgetAuraTest : public testing::Test { | 36 class NativeWidgetAuraTest : public testing::Test { |
37 public: | 37 public: |
38 NativeWidgetAuraTest() {} | 38 NativeWidgetAuraTest() {} |
39 virtual ~NativeWidgetAuraTest() {} | 39 virtual ~NativeWidgetAuraTest() {} |
40 | 40 |
41 // testing::Test overrides: | 41 // testing::Test overrides: |
42 virtual void SetUp() OVERRIDE { | 42 virtual void SetUp() OVERRIDE { |
43 aura::Env::GetInstance()->SetMonitorManager( | 43 aura::Env::GetInstance()->SetMonitorManager(new aura::SingleMonitorManager); |
44 new aura::test::SingleMonitorManager); | |
45 root_window_.reset( | 44 root_window_.reset( |
46 aura::MonitorManager::CreateRootWindowForPrimaryMonitor()); | 45 aura::MonitorManager::CreateRootWindowForPrimaryMonitor()); |
47 #if defined(USE_ASH) | 46 #if defined(USE_ASH) |
48 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); | 47 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); |
49 #endif | 48 #endif |
50 root_window_->SetBounds(gfx::Rect(0, 0, 640, 480)); | 49 root_window_->SetBounds(gfx::Rect(0, 0, 640, 480)); |
51 root_window_->SetHostSize(gfx::Size(640, 480)); | 50 root_window_->SetHostSize(gfx::Size(640, 480)); |
52 test_stacking_client_.reset( | 51 test_stacking_client_.reset( |
53 new aura::test::TestStackingClient(root_window_.get())); | 52 new aura::test::TestStackingClient(root_window_.get())); |
54 } | 53 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // For Aura, client area bounds match window bounds. | 181 // For Aura, client area bounds match window bounds. |
183 gfx::Rect client_bounds = widget->GetClientAreaScreenBounds(); | 182 gfx::Rect client_bounds = widget->GetClientAreaScreenBounds(); |
184 EXPECT_EQ(10, client_bounds.x()); | 183 EXPECT_EQ(10, client_bounds.x()); |
185 EXPECT_EQ(20, client_bounds.y()); | 184 EXPECT_EQ(20, client_bounds.y()); |
186 EXPECT_EQ(300, client_bounds.width()); | 185 EXPECT_EQ(300, client_bounds.width()); |
187 EXPECT_EQ(400, client_bounds.height()); | 186 EXPECT_EQ(400, client_bounds.height()); |
188 } | 187 } |
189 | 188 |
190 } // namespace | 189 } // namespace |
191 } // namespace views | 190 } // namespace views |
OLD | NEW |