| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/aura_shell/default_container_layout_manager.h" | 5 #include "ui/aura_shell/default_container_layout_manager.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
| 11 #include "ui/aura/desktop.h" | 11 #include "ui/aura/desktop.h" |
| 12 #include "ui/aura/screen_aura.h" | 12 #include "ui/aura/screen_aura.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/aura_shell/workspace/workspace_manager.h" | 14 #include "ui/aura_shell/workspace/workspace_controller.h" |
| 15 #include "ui/base/view_prop.h" | 15 #include "ui/base/view_prop.h" |
| 16 #include "views/widget/native_widget_aura.h" | 16 #include "views/widget/native_widget_aura.h" |
| 17 | 17 |
| 18 namespace aura_shell { | 18 namespace aura_shell { |
| 19 namespace test { | 19 namespace test { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 using views::Widget; | 23 using views::Widget; |
| 24 using aura_shell::internal::DefaultContainerLayoutManager; | 24 using aura_shell::internal::DefaultContainerLayoutManager; |
| 25 | 25 |
| 26 class DefaultContainerLayoutManagerTest : public aura::test::AuraTestBase { | 26 class DefaultContainerLayoutManagerTest : public aura::test::AuraTestBase { |
| 27 public: | 27 public: |
| 28 DefaultContainerLayoutManagerTest() {} | 28 DefaultContainerLayoutManagerTest() {} |
| 29 virtual ~DefaultContainerLayoutManagerTest() {} | 29 virtual ~DefaultContainerLayoutManagerTest() {} |
| 30 | 30 |
| 31 virtual void SetUp() OVERRIDE { | 31 virtual void SetUp() OVERRIDE { |
| 32 aura::test::AuraTestBase::SetUp(); | 32 aura::test::AuraTestBase::SetUp(); |
| 33 aura::Desktop* desktop = aura::Desktop::GetInstance(); | 33 aura::Desktop* desktop = aura::Desktop::GetInstance(); |
| 34 container_.reset( | 34 container_.reset( |
| 35 CreateTestWindow(gfx::Rect(0, 0, 500, 400), desktop)); | 35 CreateTestWindow(gfx::Rect(0, 0, 500, 400), desktop)); |
| 36 workspace_manager_.reset(new WorkspaceManager(container_.get())); | 36 workspace_controller_.reset( |
| 37 new internal::WorkspaceController(container_.get())); |
| 37 | 38 |
| 38 desktop->SetHostSize(gfx::Size(500, 400)); | 39 desktop->SetHostSize(gfx::Size(500, 400)); |
| 39 default_container_layout_manager_ = new DefaultContainerLayoutManager( | |
| 40 container_.get(), workspace_manager_.get()); | |
| 41 // draggable area is 0,0 500x400. | |
| 42 container_->SetLayoutManager(default_container_layout_manager_); | |
| 43 } | 40 } |
| 44 | 41 |
| 45 aura::Window* CreateTestWindowWithType(const gfx::Rect& bounds, | 42 aura::Window* CreateTestWindowWithType(const gfx::Rect& bounds, |
| 46 aura::Window* parent, | 43 aura::Window* parent, |
| 47 Widget::InitParams::Type type) { | 44 Widget::InitParams::Type type) { |
| 48 aura::Window* window = new aura::Window(NULL); | 45 aura::Window* window = new aura::Window(NULL); |
| 49 props_.push_back(new ui::ViewProp( | 46 props_.push_back(new ui::ViewProp( |
| 50 window, views::NativeWidgetAura::kWindowTypeKey, | 47 window, views::NativeWidgetAura::kWindowTypeKey, |
| 51 reinterpret_cast<void*>(type))); | 48 reinterpret_cast<void*>(type))); |
| 52 window->SetType(type); | 49 window->SetType(type); |
| 53 window->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 50 window->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
| 54 window->SetBounds(bounds); | 51 window->SetBounds(bounds); |
| 55 window->Show(); | 52 window->Show(); |
| 56 window->SetParent(parent); | 53 window->SetParent(parent); |
| 57 return window; | 54 return window; |
| 58 } | 55 } |
| 59 | 56 |
| 60 aura::Window* CreateTestWindow(const gfx::Rect& bounds, | 57 aura::Window* CreateTestWindow(const gfx::Rect& bounds, |
| 61 aura::Window* parent) { | 58 aura::Window* parent) { |
| 62 return CreateTestWindowWithType(bounds, | 59 return CreateTestWindowWithType(bounds, |
| 63 parent, | 60 parent, |
| 64 Widget::InitParams::TYPE_WINDOW); | 61 Widget::InitParams::TYPE_WINDOW); |
| 65 } | 62 } |
| 66 | 63 |
| 67 aura::Window* container() { return container_.get(); } | 64 aura::Window* container() { return container_.get(); } |
| 68 | 65 |
| 69 DefaultContainerLayoutManager* default_container_layout_manager() { | 66 DefaultContainerLayoutManager* default_container_layout_manager() { |
| 70 return default_container_layout_manager_; | 67 return workspace_controller_->layout_manager(); |
| 71 } | 68 } |
| 72 | 69 |
| 73 | |
| 74 private: | 70 private: |
| 75 scoped_ptr<aura::Window> container_; | 71 scoped_ptr<aura::Window> container_; |
| 76 ScopedVector<ui::ViewProp> props_; | 72 ScopedVector<ui::ViewProp> props_; |
| 77 scoped_ptr<aura_shell::WorkspaceManager> workspace_manager_; | 73 scoped_ptr<aura_shell::internal::WorkspaceController> workspace_controller_; |
| 78 DefaultContainerLayoutManager* default_container_layout_manager_; | |
| 79 | 74 |
| 80 DISALLOW_COPY_AND_ASSIGN(DefaultContainerLayoutManagerTest); | 75 DISALLOW_COPY_AND_ASSIGN(DefaultContainerLayoutManagerTest); |
| 81 }; | 76 }; |
| 82 | 77 |
| 83 } // namespace | 78 } // namespace |
| 84 | 79 |
| 85 #if !defined(OS_WIN) | 80 #if !defined(OS_WIN) |
| 86 TEST_F(DefaultContainerLayoutManagerTest, SetBounds) { | 81 TEST_F(DefaultContainerLayoutManagerTest, SetBounds) { |
| 87 // Layout Manager moves the window to (0,0) to fit to draggable area. | 82 // Layout Manager moves the window to (0,0) to fit to draggable area. |
| 88 scoped_ptr<aura::Window> child( | 83 scoped_ptr<aura::Window> child( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 popup->SetBounds(gfx::Rect(-100, 0, 100, 100)); | 131 popup->SetBounds(gfx::Rect(-100, 0, 100, 100)); |
| 137 EXPECT_EQ("-100,0 100x100", popup->bounds().ToString()); | 132 EXPECT_EQ("-100,0 100x100", popup->bounds().ToString()); |
| 138 | 133 |
| 139 // A popup window can be resized to the size bigger than draggable area. | 134 // A popup window can be resized to the size bigger than draggable area. |
| 140 popup->SetBounds(gfx::Rect(0, 0, 1000, 1000)); | 135 popup->SetBounds(gfx::Rect(0, 0, 1000, 1000)); |
| 141 EXPECT_EQ("0,0 1000x1000", popup->bounds().ToString()); | 136 EXPECT_EQ("0,0 1000x1000", popup->bounds().ToString()); |
| 142 } | 137 } |
| 143 | 138 |
| 144 } // namespace test | 139 } // namespace test |
| 145 } // namespace aura_shell | 140 } // namespace aura_shell |
| OLD | NEW |