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

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: sync and address oshima's comments in patch 6 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/aura_constants.h"
6 #include "ui/aura/desktop.h"
oshima 2011/11/04 20:40:08 i believe you don't need these two.
xiyuan 2011/11/04 22:40:21 Done.
7 #include "ui/aura/test/aura_test_base.h"
8 #include "ui/aura/window.h"
oshima 2011/11/04 20:40:08 you probably don't need this either, although i'm
xiyuan 2011/11/04 22:40:21 We need it because we call on parent() to get cont
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 namespace {
17
18 views::Widget* CreateTestWindow(const views::Widget::InitParams& params) {
19 views::Widget* widget = new views::Widget;
20 widget->Init(params);
21 return widget;
22 }
23
24 aura::Window* DefaultContainer() {
oshima 2011/11/04 20:40:08 GetDefaultContainer/GetAlwaysOnTopContainer
xiyuan 2011/11/04 22:40:21 Done.
25 return Shell::GetInstance()->GetContainer(
26 aura_shell::internal::kShellWindowId_DefaultContainer);
27 }
28
29 aura::Window* AlwaysOnTopContainer() {
30 return Shell::GetInstance()->GetContainer(
31 aura_shell::internal::kShellWindowId_AlwaysOnTopContainer);
32 }
33
34 } // namespace
35
36 class ShellTest : public aura::test::AuraTestBase {
37 public:
38 ShellTest() {}
39 virtual ~ShellTest() {}
40
41 virtual void SetUp() OVERRIDE {
42 aura::test::AuraTestBase::SetUp();
43
44 // Triggers Shell creation and hook with Desktop.
45 aura_shell::Shell::GetInstance();
46 }
47
48 private:
49 DISALLOW_COPY_AND_ASSIGN(ShellTest);
50 };
51
52 TEST_F(ShellTest, CreateAlwaysOnTopWindow) {
53 // Creates an always-on-top window.
54 views::Widget::InitParams widget_params(
55 views::Widget::InitParams::TYPE_WINDOW);
56 widget_params.keep_on_top = true;
57
58 views::Widget* widget = CreateTestWindow(widget_params);
59 widget->Show();
60
61 // It should be put into the always-on-top container.
62 EXPECT_EQ(AlwaysOnTopContainer(), widget->GetNativeWindow()->parent());
63
64 widget->Close();
65 }
66
67 TEST_F(ShellTest, ChangeAlwaysOnTop) {
68 views::Widget::InitParams widget_params(
69 views::Widget::InitParams::TYPE_WINDOW);
70
71 // Creates a normal window
72 views::Widget* widget = CreateTestWindow(widget_params);
73 widget->Show();
74
75 // It should be in default container.
76 EXPECT_EQ(DefaultContainer(), widget->GetNativeWindow()->parent());
77
78 // Flip always-on-top flag.
79 widget->SetAlwaysOnTop(true);
80 // And it should in always on top container now.
81 EXPECT_EQ(AlwaysOnTopContainer(), widget->GetNativeWindow()->parent());
82
83 // Flip always-on-top flag.
84 widget->SetAlwaysOnTop(false);
85 // It should go back to default container.
86 EXPECT_EQ(DefaultContainer(), widget->GetNativeWindow()->parent());
87
88 // Set the same always-on-top flag again.
89 widget->SetAlwaysOnTop(false);
90 // Should have no effect and we are still in the default container.
91 EXPECT_EQ(DefaultContainer(), widget->GetNativeWindow()->parent());
92
93 widget->Close();
94 }
95
96 } // namespace test
97 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/shell.cc ('k') | ui/base/x/x11_util.h » ('j') | ui/base/x/x11_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698