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