| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 MessageLoopForUI message_loop_; | 43 MessageLoopForUI message_loop_; |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); | 45 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { | 48 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { |
| 49 // Make a parent window larger than the host represented by rootwindow. | 49 // Make a parent window larger than the host represented by rootwindow. |
| 50 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 50 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 51 parent->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 51 parent->Init(ui::Layer::LAYER_NOT_DRAWN); |
| 52 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); | 52 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); |
| 53 scoped_ptr<Widget> widget(new Widget()); | 53 scoped_ptr<Widget> widget(new Widget()); |
| 54 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 54 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
| 55 | 55 |
| 56 window->CenterWindow(gfx::Size(100, 100)); | 56 window->CenterWindow(gfx::Size(100, 100)); |
| 57 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, | 57 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, |
| 58 (480 - 100) / 2, | 58 (480 - 100) / 2, |
| 59 100, 100), | 59 100, 100), |
| 60 window->GetNativeWindow()->bounds()); | 60 window->GetNativeWindow()->bounds()); |
| 61 widget->CloseNow(); | 61 widget->CloseNow(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { | 64 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { |
| 65 // Make a parent window smaller than the host represented by rootwindow. | 65 // Make a parent window smaller than the host represented by rootwindow. |
| 66 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 66 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 67 parent->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 67 parent->Init(ui::Layer::LAYER_NOT_DRAWN); |
| 68 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); | 68 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); |
| 69 scoped_ptr<Widget> widget(new Widget()); | 69 scoped_ptr<Widget> widget(new Widget()); |
| 70 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 70 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
| 71 | 71 |
| 72 window->CenterWindow(gfx::Size(100, 100)); | 72 window->CenterWindow(gfx::Size(100, 100)); |
| 73 EXPECT_EQ(gfx::Rect( (480 - 100) / 2, | 73 EXPECT_EQ(gfx::Rect( (480 - 100) / 2, |
| 74 (320 - 100) / 2, | 74 (320 - 100) / 2, |
| 75 100, 100), | 75 100, 100), |
| 76 window->GetNativeWindow()->bounds()); | 76 window->GetNativeWindow()->bounds()); |
| 77 widget->CloseNow(); | 77 widget->CloseNow(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // For Aura, client area bounds match window bounds. | 159 // For Aura, client area bounds match window bounds. |
| 160 gfx::Rect client_bounds = widget->GetClientAreaScreenBounds(); | 160 gfx::Rect client_bounds = widget->GetClientAreaScreenBounds(); |
| 161 EXPECT_EQ(10, client_bounds.x()); | 161 EXPECT_EQ(10, client_bounds.x()); |
| 162 EXPECT_EQ(20, client_bounds.y()); | 162 EXPECT_EQ(20, client_bounds.y()); |
| 163 EXPECT_EQ(300, client_bounds.width()); | 163 EXPECT_EQ(300, client_bounds.width()); |
| 164 EXPECT_EQ(400, client_bounds.height()); | 164 EXPECT_EQ(400, client_bounds.height()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace | 167 } // namespace |
| 168 } // namespace views | 168 } // namespace views |
| OLD | NEW |