| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 aura::Window* root_window() { return GetContext(); } | 48 aura::Window* root_window() { return GetContext(); } |
| 49 aura::RootWindow* dispatcher() { return root_window()->GetDispatcher(); } | 49 aura::RootWindow* dispatcher() { return root_window()->GetDispatcher(); } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); | 52 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { | 55 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { |
| 56 // Make a parent window larger than the host represented by rootwindow. | 56 // Make a parent window larger than the host represented by rootwindow. |
| 57 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 57 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 58 parent->Init(ui::LAYER_NOT_DRAWN); | 58 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 59 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); | 59 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); |
| 60 scoped_ptr<Widget> widget(new Widget()); | 60 scoped_ptr<Widget> widget(new Widget()); |
| 61 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 61 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
| 62 | 62 |
| 63 window->CenterWindow(gfx::Size(100, 100)); | 63 window->CenterWindow(gfx::Size(100, 100)); |
| 64 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, | 64 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, |
| 65 (480 - 100) / 2, | 65 (480 - 100) / 2, |
| 66 100, 100), | 66 100, 100), |
| 67 window->GetNativeWindow()->bounds()); | 67 window->GetNativeWindow()->bounds()); |
| 68 widget->CloseNow(); | 68 widget->CloseNow(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { | 71 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { |
| 72 // Make a parent window smaller than the host represented by rootwindow. | 72 // Make a parent window smaller than the host represented by rootwindow. |
| 73 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 73 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 74 parent->Init(ui::LAYER_NOT_DRAWN); | 74 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 75 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); | 75 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); |
| 76 scoped_ptr<Widget> widget(new Widget()); | 76 scoped_ptr<Widget> widget(new Widget()); |
| 77 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 77 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
| 78 | 78 |
| 79 window->CenterWindow(gfx::Size(100, 100)); | 79 window->CenterWindow(gfx::Size(100, 100)); |
| 80 EXPECT_EQ(gfx::Rect( (480 - 100) / 2, | 80 EXPECT_EQ(gfx::Rect( (480 - 100) / 2, |
| 81 (320 - 100) / 2, | 81 (320 - 100) / 2, |
| 82 100, 100), | 82 100, 100), |
| 83 window->GetNativeWindow()->bounds()); | 83 window->GetNativeWindow()->bounds()); |
| 84 widget->CloseNow(); | 84 widget->CloseNow(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Verifies CenterWindow() constrains to parent size. | 87 // Verifies CenterWindow() constrains to parent size. |
| 88 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParentNotAtOrigin) { | 88 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParentNotAtOrigin) { |
| 89 // Make a parent window smaller than the host represented by rootwindow and | 89 // Make a parent window smaller than the host represented by rootwindow and |
| 90 // offset it slightly from the origin. | 90 // offset it slightly from the origin. |
| 91 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 91 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 92 parent->Init(ui::LAYER_NOT_DRAWN); | 92 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 93 parent->SetBounds(gfx::Rect(20, 40, 480, 320)); | 93 parent->SetBounds(gfx::Rect(20, 40, 480, 320)); |
| 94 scoped_ptr<Widget> widget(new Widget()); | 94 scoped_ptr<Widget> widget(new Widget()); |
| 95 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 95 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
| 96 window->CenterWindow(gfx::Size(500, 600)); | 96 window->CenterWindow(gfx::Size(500, 600)); |
| 97 | 97 |
| 98 // |window| should be no bigger than |parent|. | 98 // |window| should be no bigger than |parent|. |
| 99 EXPECT_EQ("20,40 480x320", window->GetNativeWindow()->bounds().ToString()); | 99 EXPECT_EQ("20,40 480x320", window->GetNativeWindow()->bounds().ToString()); |
| 100 widget->CloseNow(); | 100 widget->CloseNow(); |
| 101 } | 101 } |
| 102 | 102 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 widget->FlashFrame(false); | 384 widget->FlashFrame(false); |
| 385 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); | 385 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); |
| 386 widget->FlashFrame(true); | 386 widget->FlashFrame(true); |
| 387 EXPECT_TRUE(window->GetProperty(aura::client::kDrawAttentionKey)); | 387 EXPECT_TRUE(window->GetProperty(aura::client::kDrawAttentionKey)); |
| 388 widget->Activate(); | 388 widget->Activate(); |
| 389 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); | 389 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); |
| 390 } | 390 } |
| 391 | 391 |
| 392 TEST_F(NativeWidgetAuraTest, NoCrashOnThemeAfterClose) { | 392 TEST_F(NativeWidgetAuraTest, NoCrashOnThemeAfterClose) { |
| 393 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 393 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 394 parent->Init(ui::LAYER_NOT_DRAWN); | 394 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 395 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); | 395 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); |
| 396 scoped_ptr<Widget> widget(new Widget()); | 396 scoped_ptr<Widget> widget(new Widget()); |
| 397 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 397 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
| 398 window->Show(); | 398 window->Show(); |
| 399 window->Close(); | 399 window->Close(); |
| 400 base::MessageLoop::current()->RunUntilIdle(); | 400 base::MessageLoop::current()->RunUntilIdle(); |
| 401 widget->GetNativeTheme(); // Shouldn't crash. | 401 widget->GetNativeTheme(); // Shouldn't crash. |
| 402 } | 402 } |
| 403 | 403 |
| 404 } // namespace | 404 } // namespace |
| 405 } // namespace views | 405 } // namespace views |
| OLD | NEW |