OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/aura/aura_constants.h" | |
6 #include "ui/aura/desktop.h" | |
7 #include "ui/aura/test/aura_test_base.h" | |
8 #include "ui/aura/window.h" | |
9 #include "ui/aura_shell/shell.h" | |
10 #include "ui/aura_shell/shell_window_ids.h" | |
11 #include "views/widget/widget.h" | |
12 | |
13 namespace aura_shell { | |
14 namespace test { | |
15 | |
16 class ShellTest : public aura::test::AuraTestBase { | |
17 public: | |
18 ShellTest() : shell_(NULL) {} | |
19 virtual ~ShellTest() {} | |
20 | |
21 virtual void SetUp() OVERRIDE { | |
22 aura::test::AuraTestBase::SetUp(); | |
23 | |
24 // Triggers Shell creation and hook with Desktop. | |
25 shell_ = aura_shell::Shell::GetInstance(); | |
26 } | |
27 | |
28 views::Widget* CreateTestWindow(const views::Widget::InitParams& params) { | |
oshima
2011/11/04 18:14:11
const or maybe static
xiyuan
2011/11/04 18:39:31
Moved to anonymous namespace.
| |
29 views::Widget* widget = new views::Widget; | |
30 widget->Init(params); | |
31 widget->SetContentsView(new views::View); | |
oshima
2011/11/04 18:14:11
do you need this? If so, include views.h. (I wonde
xiyuan
2011/11/04 18:39:31
Removed SetContentsView.
| |
32 return widget; | |
33 } | |
34 | |
35 private: | |
36 aura_shell::Shell* shell_; | |
oshima
2011/11/04 18:14:11
do you need this?
xiyuan
2011/11/04 18:39:31
Removed.
| |
37 | |
38 DISALLOW_COPY_AND_ASSIGN(ShellTest); | |
39 }; | |
40 | |
41 TEST_F(ShellTest, CreateAlwaysOnTopWindow) { | |
42 // Creates an always-on-top window. | |
43 views::Widget::InitParams widget_params( | |
44 views::Widget::InitParams::TYPE_WINDOW); | |
45 widget_params.keep_on_top = true; | |
46 | |
47 views::Widget* widget = CreateTestWindow(widget_params); | |
48 widget->Show(); | |
49 | |
50 // It should be put into the always-on-top container. | |
51 EXPECT_EQ( | |
52 Shell::GetInstance()->GetContainer( | |
53 aura_shell::internal::kShellWindowId_AlwaysOnTopContainer), | |
54 widget->GetNativeWindow()->parent()); | |
55 | |
56 widget->Close(); | |
57 } | |
58 | |
59 TEST_F(ShellTest, ChangeAlwaysOnTop) { | |
60 views::Widget::InitParams widget_params( | |
61 views::Widget::InitParams::TYPE_WINDOW); | |
62 | |
63 // Creates a normal window | |
64 views::Widget* widget = CreateTestWindow(widget_params); | |
65 widget->Show(); | |
66 | |
67 // It should be in default container. | |
68 EXPECT_EQ( | |
69 Shell::GetInstance()->GetContainer( | |
70 aura_shell::internal::kShellWindowId_DefaultContainer), | |
oshima
2011/11/04 18:14:11
Add method (like default_container()) to get conta
xiyuan
2011/11/04 18:39:31
Done. Added helper functions to get default contai
| |
71 widget->GetNativeWindow()->parent()); | |
72 | |
73 // Flip always-on-top flag. | |
74 widget->SetAlwaysOnTop(true); | |
75 // And it should in always on top container now. | |
76 EXPECT_EQ( | |
77 Shell::GetInstance()->GetContainer( | |
78 aura_shell::internal::kShellWindowId_AlwaysOnTopContainer), | |
79 widget->GetNativeWindow()->parent()); | |
80 | |
81 // Flip always-on-top flag. | |
82 widget->SetAlwaysOnTop(false); | |
83 // It should go back to default container. | |
84 EXPECT_EQ( | |
85 Shell::GetInstance()->GetContainer( | |
86 aura_shell::internal::kShellWindowId_DefaultContainer), | |
87 widget->GetNativeWindow()->parent()); | |
88 | |
89 // Set the same always-on-top flag again. | |
90 widget->SetAlwaysOnTop(false); | |
91 // Should have no effect and we are still in the default container. | |
92 EXPECT_EQ( | |
93 Shell::GetInstance()->GetContainer( | |
94 aura_shell::internal::kShellWindowId_DefaultContainer), | |
95 widget->GetNativeWindow()->parent()); | |
96 | |
97 widget->Close(); | |
98 } | |
99 | |
100 } // namespace test | |
101 } // namespace aura_shell | |
OLD | NEW |