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/test/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_AURA) |
22 #include "ui/aura/test/test_screen.h" | 22 #include "ui/aura/test/test_screen.h" |
| 23 #include "ui/gfx/screen.h" |
23 #endif | 24 #endif |
24 | 25 |
25 namespace views { | 26 namespace views { |
26 namespace { | 27 namespace { |
27 | 28 |
28 NativeWidgetAura* Init(aura::Window* parent, Widget* widget) { | 29 NativeWidgetAura* Init(aura::Window* parent, Widget* widget) { |
29 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | 30 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
30 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 31 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
31 params.parent = parent; | 32 params.parent = parent; |
32 widget->Init(params); | 33 widget->Init(params); |
33 return static_cast<NativeWidgetAura*>(widget->native_widget()); | 34 return static_cast<NativeWidgetAura*>(widget->native_widget()); |
34 } | 35 } |
35 | 36 |
36 class NativeWidgetAuraTest : public testing::Test { | 37 class NativeWidgetAuraTest : public testing::Test { |
37 public: | 38 public: |
38 NativeWidgetAuraTest() {} | 39 NativeWidgetAuraTest() {} |
39 virtual ~NativeWidgetAuraTest() {} | 40 virtual ~NativeWidgetAuraTest() {} |
40 | 41 |
41 // testing::Test overrides: | 42 // testing::Test overrides: |
42 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() OVERRIDE { |
43 aura::Env::GetInstance()->SetMonitorManager( | 44 aura::Env::GetInstance()->SetMonitorManager( |
44 new aura::test::SingleMonitorManager); | 45 new aura::test::SingleMonitorManager); |
45 root_window_.reset( | 46 root_window_.reset( |
46 aura::MonitorManager::CreateRootWindowForPrimaryMonitor()); | 47 aura::MonitorManager::CreateRootWindowForPrimaryMonitor()); |
47 #if defined(USE_ASH) | 48 #if defined(USE_AURA) |
48 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); | 49 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); |
49 #endif | 50 #endif |
50 root_window_->SetBounds(gfx::Rect(0, 0, 640, 480)); | 51 root_window_->SetBounds(gfx::Rect(0, 0, 640, 480)); |
51 root_window_->SetHostSize(gfx::Size(640, 480)); | 52 root_window_->SetHostSize(gfx::Size(640, 480)); |
52 test_stacking_client_.reset( | 53 test_stacking_client_.reset( |
53 new aura::test::TestStackingClient(root_window_.get())); | 54 new aura::test::TestStackingClient(root_window_.get())); |
54 } | 55 } |
55 virtual void TearDown() OVERRIDE { | 56 virtual void TearDown() OVERRIDE { |
56 message_loop_.RunAllPending(); | 57 message_loop_.RunAllPending(); |
57 test_stacking_client_.reset(); | 58 test_stacking_client_.reset(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // For Aura, client area bounds match window bounds. | 183 // For Aura, client area bounds match window bounds. |
183 gfx::Rect client_bounds = widget->GetClientAreaScreenBounds(); | 184 gfx::Rect client_bounds = widget->GetClientAreaScreenBounds(); |
184 EXPECT_EQ(10, client_bounds.x()); | 185 EXPECT_EQ(10, client_bounds.x()); |
185 EXPECT_EQ(20, client_bounds.y()); | 186 EXPECT_EQ(20, client_bounds.y()); |
186 EXPECT_EQ(300, client_bounds.width()); | 187 EXPECT_EQ(300, client_bounds.width()); |
187 EXPECT_EQ(400, client_bounds.height()); | 188 EXPECT_EQ(400, client_bounds.height()); |
188 } | 189 } |
189 | 190 |
190 } // namespace | 191 } // namespace |
191 } // namespace views | 192 } // namespace views |
OLD | NEW |