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

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 update comment per ben 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
« no previous file with comments | « ui/aura_shell/shell.cc ('k') | ui/aura_shell/stacking_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/aura_shell/test/aura_shell_test_base.h"
10 #include "views/widget/widget.h"
11
12 namespace aura_shell {
13 namespace test {
14
15 namespace {
16
17 views::Widget* CreateTestWindow(const views::Widget::InitParams& params) {
18 views::Widget* widget = new views::Widget;
19 widget->Init(params);
20 return widget;
21 }
22
23 aura::Window* GetDefaultContainer() {
24 return Shell::GetInstance()->GetContainer(
25 aura_shell::internal::kShellWindowId_DefaultContainer);
26 }
27
28 aura::Window* GetAlwaysOnTopContainer() {
29 return Shell::GetInstance()->GetContainer(
30 aura_shell::internal::kShellWindowId_AlwaysOnTopContainer);
31 }
32
33 void TestCreateWindow(views::Widget::InitParams::Type type,
34 bool always_on_top,
35 aura::Window* expected_container) {
36 views::Widget::InitParams widget_params(type);
37 widget_params.keep_on_top = always_on_top;
38
39 views::Widget* widget = CreateTestWindow(widget_params);
40 widget->Show();
41
42 EXPECT_EQ(expected_container, widget->GetNativeWindow()->parent()) <<
43 "TestCreateWindow: type=" << type << ", always_on_top=" << always_on_top;
44
45 widget->Close();
46 }
47
48 } // namespace
49
50 class ShellTest : public AuraShellTestBase {
51 public:
52 ShellTest() {}
53 virtual ~ShellTest() {}
54
55 private:
56 DISALLOW_COPY_AND_ASSIGN(ShellTest);
57 };
58
59 TEST_F(ShellTest, CreateWindow) {
60 // Normal window should be created in default container.
61 TestCreateWindow(views::Widget::InitParams::TYPE_WINDOW,
62 false, // always_on_top
63 GetDefaultContainer());
64 TestCreateWindow(views::Widget::InitParams::TYPE_POPUP,
65 false, // always_on_top
66 GetDefaultContainer());
67
68 // Always-on-top window and popup are created in always-on-top container.
69 TestCreateWindow(views::Widget::InitParams::TYPE_WINDOW,
70 true, // always_on_top
71 GetAlwaysOnTopContainer());
72 TestCreateWindow(views::Widget::InitParams::TYPE_POPUP,
73 true, // always_on_top
74 GetAlwaysOnTopContainer());
75 }
76
77 TEST_F(ShellTest, ChangeAlwaysOnTop) {
78 views::Widget::InitParams widget_params(
79 views::Widget::InitParams::TYPE_WINDOW);
80
81 // Creates a normal window
82 views::Widget* widget = CreateTestWindow(widget_params);
83 widget->Show();
84
85 // It should be in default container.
86 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
87
88 // Flip always-on-top flag.
89 widget->SetAlwaysOnTop(true);
90 // And it should in always on top container now.
91 EXPECT_EQ(GetAlwaysOnTopContainer(), widget->GetNativeWindow()->parent());
92
93 // Flip always-on-top flag.
94 widget->SetAlwaysOnTop(false);
95 // It should go back to default container.
96 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
97
98 // Set the same always-on-top flag again.
99 widget->SetAlwaysOnTop(false);
100 // Should have no effect and we are still in the default container.
101 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
102
103 widget->Close();
104 }
105
106 } // namespace test
107 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/shell.cc ('k') | ui/aura_shell/stacking_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698