| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); | 50 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { | 53 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { |
| 54 // Make a parent window larger than the host represented by | 54 // Make a parent window larger than the host represented by |
| 55 // WindowEventDispatcher. | 55 // WindowEventDispatcher. |
| 56 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 56 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 57 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 57 parent->Init(ui::LAYER_NOT_DRAWN); |
| 58 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); | 58 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); |
| 59 scoped_ptr<Widget> widget(new Widget()); | 59 scoped_ptr<Widget> widget(new Widget()); |
| 60 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 60 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
| 61 | 61 |
| 62 window->CenterWindow(gfx::Size(100, 100)); | 62 window->CenterWindow(gfx::Size(100, 100)); |
| 63 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, | 63 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, |
| 64 (480 - 100) / 2, | 64 (480 - 100) / 2, |
| 65 100, 100), | 65 100, 100), |
| 66 window->GetNativeWindow()->bounds()); | 66 window->GetNativeWindow()->bounds()); |
| 67 widget->CloseNow(); | 67 widget->CloseNow(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { | 70 TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) { |
| 71 // Make a parent window smaller than the host represented by | 71 // Make a parent window smaller than the host represented by |
| 72 // WindowEventDispatcher. | 72 // WindowEventDispatcher. |
| 73 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 73 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 74 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 74 parent->Init(ui::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 | 89 // Make a parent window smaller than the host represented by |
| 90 // WindowEventDispatcher and offset it slightly from the origin. | 90 // WindowEventDispatcher and 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(aura::WINDOW_LAYER_NOT_DRAWN); | 92 parent->Init(ui::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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 widget->FlashFrame(false); | 415 widget->FlashFrame(false); |
| 416 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); | 416 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); |
| 417 widget->FlashFrame(true); | 417 widget->FlashFrame(true); |
| 418 EXPECT_TRUE(window->GetProperty(aura::client::kDrawAttentionKey)); | 418 EXPECT_TRUE(window->GetProperty(aura::client::kDrawAttentionKey)); |
| 419 widget->Activate(); | 419 widget->Activate(); |
| 420 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); | 420 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); |
| 421 } | 421 } |
| 422 | 422 |
| 423 TEST_F(NativeWidgetAuraTest, NoCrashOnThemeAfterClose) { | 423 TEST_F(NativeWidgetAuraTest, NoCrashOnThemeAfterClose) { |
| 424 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); | 424 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); |
| 425 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 425 parent->Init(ui::LAYER_NOT_DRAWN); |
| 426 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); | 426 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); |
| 427 scoped_ptr<Widget> widget(new Widget()); | 427 scoped_ptr<Widget> widget(new Widget()); |
| 428 Init(parent.get(), widget.get()); | 428 Init(parent.get(), widget.get()); |
| 429 widget->Show(); | 429 widget->Show(); |
| 430 widget->Close(); | 430 widget->Close(); |
| 431 base::MessageLoop::current()->RunUntilIdle(); | 431 base::MessageLoop::current()->RunUntilIdle(); |
| 432 widget->GetNativeTheme(); // Shouldn't crash. | 432 widget->GetNativeTheme(); // Shouldn't crash. |
| 433 } | 433 } |
| 434 | 434 |
| 435 // Used to track calls to WidgetDelegate::OnWidgetMove(). | 435 // Used to track calls to WidgetDelegate::OnWidgetMove(). |
| (...skipping 29 matching lines...) Expand all Loading... |
| 465 delegate->ClearGotMove(); | 465 delegate->ClearGotMove(); |
| 466 // Simulate a maximize with animation. | 466 // Simulate a maximize with animation. |
| 467 delete widget->GetNativeView()->RecreateLayer().release(); | 467 delete widget->GetNativeView()->RecreateLayer().release(); |
| 468 widget->SetBounds(gfx::Rect(0, 0, 500, 500)); | 468 widget->SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 469 EXPECT_TRUE(delegate->got_move()); | 469 EXPECT_TRUE(delegate->got_move()); |
| 470 widget->CloseNow(); | 470 widget->CloseNow(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace | 473 } // namespace |
| 474 } // namespace views | 474 } // namespace views |
| OLD | NEW |