OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "athena/util/fill_layout_manager.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 #include "ui/aura/window.h" | |
9 #include "ui/wm/public/window_types.h" | |
10 | |
11 namespace athena { | |
12 | |
13 TEST(FillLayoutManagerTest, ChildWindowSizedCorrectly) { | |
14 scoped_ptr<aura::Window> parent(new aura::Window(nullptr)); | |
15 parent->SetBounds(gfx::Rect(10, 20, 30, 40)); | |
16 parent->SetLayoutManager(new FillLayoutManager(parent.get())); | |
17 | |
18 scoped_ptr<aura::Window> child(new aura::Window(nullptr)); | |
19 child->SetBounds(gfx::Rect(0, 0, 5, 10)); | |
20 | |
21 EXPECT_NE(parent->bounds().size().ToString(), | |
22 child->bounds().size().ToString()); | |
23 | |
24 parent->AddChild(child.get()); | |
25 EXPECT_EQ(parent->bounds().size().ToString(), | |
26 child->bounds().size().ToString()); | |
27 | |
28 parent->SetBounds(gfx::Rect(0, 0, 100, 200)); | |
29 EXPECT_EQ(parent->bounds().size().ToString(), | |
30 child->bounds().size().ToString()); | |
31 | |
32 // Menu, tooltip, and popup should not be filled. | |
33 scoped_ptr<aura::Window> menu(new aura::Window(nullptr)); | |
34 menu->SetType(ui::wm::WINDOW_TYPE_MENU); | |
35 menu->SetBounds(gfx::Rect(0, 0, 5, 10)); | |
36 | |
37 EXPECT_EQ("0,0 5x10", menu->bounds().ToString()); | |
38 parent->AddChild(menu.get()); | |
39 EXPECT_EQ("0,0 5x10", menu->bounds().ToString()); | |
40 menu->SetBounds(gfx::Rect(0, 0, 100, 200)); | |
41 EXPECT_EQ("0,0 100x200", menu->bounds().ToString()); | |
42 | |
43 scoped_ptr<aura::Window> tooltip(new aura::Window(nullptr)); | |
44 tooltip->SetType(ui::wm::WINDOW_TYPE_TOOLTIP); | |
45 tooltip->SetBounds(gfx::Rect(0, 0, 5, 10)); | |
46 | |
47 EXPECT_EQ("0,0 5x10", tooltip->bounds().ToString()); | |
48 parent->AddChild(tooltip.get()); | |
49 EXPECT_EQ("0,0 5x10", tooltip->bounds().ToString()); | |
50 tooltip->SetBounds(gfx::Rect(0, 0, 100, 200)); | |
51 EXPECT_EQ("0,0 100x200", tooltip->bounds().ToString()); | |
52 | |
53 scoped_ptr<aura::Window> popup(new aura::Window(nullptr)); | |
54 popup->SetType(ui::wm::WINDOW_TYPE_POPUP); | |
55 popup->SetBounds(gfx::Rect(0, 0, 5, 10)); | |
56 | |
57 EXPECT_EQ("0,0 5x10", popup->bounds().ToString()); | |
58 parent->AddChild(popup.get()); | |
59 EXPECT_EQ("0,0 5x10", popup->bounds().ToString()); | |
60 popup->SetBounds(gfx::Rect(0, 0, 100, 200)); | |
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()); | |
83 } | |
84 | |
85 } // namespace athena | |
OLD | NEW |