Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Side by Side Diff: ui/aura_shell/shell_unittest.cc

Issue 8387043: [Aura] Support always-on-top top level window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move always-on-top handling code from shell into a controller Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/test/aura_test_base.h"
6 #include "ui/aura/window.h"
7 #include "ui/aura_shell/shell.h"
8 #include "ui/aura_shell/shell_window_ids.h"
9 #include "views/widget/widget.h"
10
11 namespace aura_shell {
12 namespace test {
13
14 namespace {
15
16 views::Widget* CreateTestWindow(const views::Widget::InitParams& params) {
17 views::Widget* widget = new views::Widget;
18 widget->Init(params);
19 return widget;
20 }
21
22 aura::Window* GetDefaultContainer() {
23 return Shell::GetInstance()->GetContainer(
24 aura_shell::internal::kShellWindowId_DefaultContainer);
25 }
26
27 aura::Window* GetAlwaysOnTopContainer() {
28 return Shell::GetInstance()->GetContainer(
29 aura_shell::internal::kShellWindowId_AlwaysOnTopContainer);
30 }
31
32 } // namespace
33
34 class ShellTest : public aura::test::AuraTestBase {
35 public:
36 ShellTest() {}
37 virtual ~ShellTest() {}
38
39 virtual void SetUp() OVERRIDE {
40 aura::test::AuraTestBase::SetUp();
41
42 // Triggers Shell creation and hook with Desktop.
43 aura_shell::Shell::GetInstance();
44 }
45
46 private:
47 DISALLOW_COPY_AND_ASSIGN(ShellTest);
48 };
49
50 TEST_F(ShellTest, CreateAlwaysOnTopWindow) {
51 // Creates an always-on-top window.
52 views::Widget::InitParams widget_params(
53 views::Widget::InitParams::TYPE_WINDOW);
54 widget_params.keep_on_top = true;
55
56 views::Widget* widget = CreateTestWindow(widget_params);
57 widget->Show();
58
59 // It should be put into the always-on-top container.
60 EXPECT_EQ(GetAlwaysOnTopContainer(), widget->GetNativeWindow()->parent());
oshima 2011/11/08 23:34:24 can you add a few more test cases such as keep_on_
xiyuan 2011/11/09 17:42:18 Done.
61
62 widget->Close();
63 }
64
65 TEST_F(ShellTest, ChangeAlwaysOnTop) {
66 views::Widget::InitParams widget_params(
67 views::Widget::InitParams::TYPE_WINDOW);
68
69 // Creates a normal window
70 views::Widget* widget = CreateTestWindow(widget_params);
71 widget->Show();
72
73 // It should be in default container.
74 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
75
76 // Flip always-on-top flag.
77 widget->SetAlwaysOnTop(true);
78 // And it should in always on top container now.
79 EXPECT_EQ(GetAlwaysOnTopContainer(), 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(GetDefaultContainer(), widget->GetNativeWindow()->parent());
85
86 // Set the same always-on-top flag again.
87 widget->SetAlwaysOnTop(false);
88 // Should have no effect and we are still in the default container.
89 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
90
91 widget->Close();
92 }
93
94 } // namespace test
95 } // namespace aura_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698