| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/util/fill_layout_manager.h" | 5 #include "athena/util/fill_layout_manager.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/wm/public/window_types.h" | 9 #include "ui/wm/public/window_types.h" |
| 10 | 10 |
| 11 namespace athena { | 11 namespace athena { |
| 12 | 12 |
| 13 TEST(FillLayoutManagerTest, ChildWindowSizedCorrectly) { | 13 TEST(FillLayoutManagerTest, ChildWindowSizedCorrectly) { |
| 14 scoped_ptr<aura::Window> parent(new aura::Window(nullptr)); | 14 scoped_ptr<aura::Window> parent(new aura::Window(nullptr)); |
| 15 parent->SetBounds(gfx::Rect(10, 20, 30, 40)); | 15 parent->SetBounds(gfx::Rect(10, 20, 30, 40)); |
| 16 parent->SetLayoutManager(new FillLayoutManager(parent.get())); | 16 parent->SetLayoutManager(new FillLayoutManager(parent.get())); |
| 17 | 17 |
| 18 scoped_ptr<aura::Window> child(new aura::Window(nullptr)); | 18 scoped_ptr<aura::Window> child(new aura::Window(nullptr)); |
| 19 child->SetBounds(gfx::Rect(0, 0, 5, 10)); | 19 child->SetBounds(gfx::Rect(0, 0, 5, 10)); |
| 20 | 20 |
| 21 EXPECT_NE(child->bounds().size().ToString(), | 21 EXPECT_NE(parent->bounds().size().ToString(), |
| 22 parent->bounds().size().ToString()); | 22 child->bounds().size().ToString()); |
| 23 | 23 |
| 24 parent->AddChild(child.get()); | 24 parent->AddChild(child.get()); |
| 25 EXPECT_EQ(child->bounds().size().ToString(), | 25 EXPECT_EQ(parent->bounds().size().ToString(), |
| 26 parent->bounds().size().ToString()); | 26 child->bounds().size().ToString()); |
| 27 | 27 |
| 28 parent->SetBounds(gfx::Rect(0, 0, 100, 200)); | 28 parent->SetBounds(gfx::Rect(0, 0, 100, 200)); |
| 29 EXPECT_EQ(child->bounds().size().ToString(), | 29 EXPECT_EQ(parent->bounds().size().ToString(), |
| 30 parent->bounds().size().ToString()); | 30 child->bounds().size().ToString()); |
| 31 | 31 |
| 32 // Menu, tooltip, and popup should not be filled. | 32 // Menu, tooltip, and popup should not be filled. |
| 33 scoped_ptr<aura::Window> menu(new aura::Window(nullptr)); | 33 scoped_ptr<aura::Window> menu(new aura::Window(nullptr)); |
| 34 menu->SetType(ui::wm::WINDOW_TYPE_MENU); | 34 menu->SetType(ui::wm::WINDOW_TYPE_MENU); |
| 35 menu->SetBounds(gfx::Rect(0, 0, 5, 10)); | 35 menu->SetBounds(gfx::Rect(0, 0, 5, 10)); |
| 36 | 36 |
| 37 EXPECT_EQ(menu->bounds().ToString(), "0,0 5x10"); | 37 EXPECT_EQ("0,0 5x10", menu->bounds().ToString()); |
| 38 parent->AddChild(menu.get()); | 38 parent->AddChild(menu.get()); |
| 39 EXPECT_EQ(menu->bounds().ToString(), "0,0 5x10"); | 39 EXPECT_EQ("0,0 5x10", menu->bounds().ToString()); |
| 40 menu->SetBounds(gfx::Rect(0, 0, 100, 200)); | 40 menu->SetBounds(gfx::Rect(0, 0, 100, 200)); |
| 41 EXPECT_EQ(menu->bounds().ToString(), "0,0 100x200"); | 41 EXPECT_EQ("0,0 100x200", menu->bounds().ToString()); |
| 42 | 42 |
| 43 scoped_ptr<aura::Window> tooltip(new aura::Window(nullptr)); | 43 scoped_ptr<aura::Window> tooltip(new aura::Window(nullptr)); |
| 44 tooltip->SetType(ui::wm::WINDOW_TYPE_TOOLTIP); | 44 tooltip->SetType(ui::wm::WINDOW_TYPE_TOOLTIP); |
| 45 tooltip->SetBounds(gfx::Rect(0, 0, 5, 10)); | 45 tooltip->SetBounds(gfx::Rect(0, 0, 5, 10)); |
| 46 | 46 |
| 47 EXPECT_EQ(tooltip->bounds().ToString(), "0,0 5x10"); | 47 EXPECT_EQ("0,0 5x10", tooltip->bounds().ToString()); |
| 48 parent->AddChild(tooltip.get()); | 48 parent->AddChild(tooltip.get()); |
| 49 EXPECT_EQ(tooltip->bounds().ToString(), "0,0 5x10"); | 49 EXPECT_EQ("0,0 5x10", tooltip->bounds().ToString()); |
| 50 tooltip->SetBounds(gfx::Rect(0, 0, 100, 200)); | 50 tooltip->SetBounds(gfx::Rect(0, 0, 100, 200)); |
| 51 EXPECT_EQ(tooltip->bounds().ToString(), "0,0 100x200"); | 51 EXPECT_EQ("0,0 100x200", tooltip->bounds().ToString()); |
| 52 | 52 |
| 53 scoped_ptr<aura::Window> popup(new aura::Window(nullptr)); | 53 scoped_ptr<aura::Window> popup(new aura::Window(nullptr)); |
| 54 popup->SetType(ui::wm::WINDOW_TYPE_POPUP); | 54 popup->SetType(ui::wm::WINDOW_TYPE_POPUP); |
| 55 popup->SetBounds(gfx::Rect(0, 0, 5, 10)); | 55 popup->SetBounds(gfx::Rect(0, 0, 5, 10)); |
| 56 | 56 |
| 57 EXPECT_EQ(popup->bounds().ToString(), "0,0 5x10"); | 57 EXPECT_EQ("0,0 5x10", popup->bounds().ToString()); |
| 58 parent->AddChild(popup.get()); | 58 parent->AddChild(popup.get()); |
| 59 EXPECT_EQ(popup->bounds().ToString(), "0,0 5x10"); | 59 EXPECT_EQ("0,0 5x10", popup->bounds().ToString()); |
| 60 popup->SetBounds(gfx::Rect(0, 0, 100, 200)); | 60 popup->SetBounds(gfx::Rect(0, 0, 100, 200)); |
| 61 EXPECT_EQ(popup->bounds().ToString(), "0,0 100x200"); | 61 EXPECT_EQ("0,0 100x200", popup->bounds().ToString()); |
| 62 |
| 63 // Frameless window is TYPE_POPUP, but some frameless window may want to be |
| 64 // filled with the specific key. |
| 65 scoped_ptr<aura::Window> frameless(new aura::Window(nullptr)); |
| 66 frameless->SetType(ui::wm::WINDOW_TYPE_POPUP); |
| 67 frameless->SetBounds(gfx::Rect(0, 0, 5, 10)); |
| 68 |
| 69 EXPECT_EQ("0,0 5x10", frameless->bounds().ToString()); |
| 70 |
| 71 // Adding frameless to |parent|, then set the flag. This order respects |
| 72 // the actual order of creating a views::Widget. |
| 73 parent->AddChild(frameless.get()); |
| 74 FillLayoutManager::SetAlwaysFill(frameless.get()); |
| 75 frameless->Show(); |
| 76 |
| 77 EXPECT_EQ(parent->bounds().size().ToString(), |
| 78 frameless->bounds().size().ToString()); |
| 79 |
| 80 frameless->SetBounds(gfx::Rect(0, 0, 10, 20)); |
| 81 EXPECT_EQ(parent->bounds().size().ToString(), |
| 82 frameless->bounds().size().ToString()); |
| 62 } | 83 } |
| 63 | 84 |
| 64 } // namespace athena | 85 } // namespace athena |
| OLD | NEW |