Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / athena / util / fill_layout_manager_unittest.cc
blob9f312200154d257571b8cca0379a73359debc402
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.
5 #include "athena/util/fill_layout_manager.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/aura/window.h"
9 #include "ui/wm/public/window_types.h"
11 namespace athena {
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()));
18 scoped_ptr<aura::Window> child(new aura::Window(nullptr));
19 child->SetBounds(gfx::Rect(0, 0, 5, 10));
21 EXPECT_NE(parent->bounds().size().ToString(),
22 child->bounds().size().ToString());
24 parent->AddChild(child.get());
25 EXPECT_EQ(parent->bounds().size().ToString(),
26 child->bounds().size().ToString());
28 parent->SetBounds(gfx::Rect(0, 0, 100, 200));
29 EXPECT_EQ(parent->bounds().size().ToString(),
30 child->bounds().size().ToString());
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));
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());
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));
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());
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));
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());
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));
69 EXPECT_EQ("0,0 5x10", frameless->bounds().ToString());
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();
77 EXPECT_EQ(parent->bounds().size().ToString(),
78 frameless->bounds().size().ToString());
80 frameless->SetBounds(gfx::Rect(0, 0, 10, 20));
81 EXPECT_EQ(parent->bounds().size().ToString(),
82 frameless->bounds().size().ToString());
85 } // namespace athena