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

Unified 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: fix win_aura bot 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura_shell/shell_unittest.cc
diff --git a/ui/aura_shell/shell_unittest.cc b/ui/aura_shell/shell_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e70a6007dac2fb4366cb5f76f38be114dfbf1320
--- /dev/null
+++ b/ui/aura_shell/shell_unittest.cc
@@ -0,0 +1,101 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/aura_constants.h"
+#include "ui/aura/desktop.h"
+#include "ui/aura/test/aura_test_base.h"
+#include "ui/aura/window.h"
+#include "ui/aura_shell/shell.h"
+#include "ui/aura_shell/shell_window_ids.h"
+#include "views/widget/widget.h"
+
+namespace aura_shell {
+namespace test {
+
+class ShellTest : public aura::test::AuraTestBase {
+ public:
+ ShellTest() : shell_(NULL) {}
+ virtual ~ShellTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ aura::test::AuraTestBase::SetUp();
+
+ // Triggers Shell creation and hook with Desktop.
+ shell_ = aura_shell::Shell::GetInstance();
+ }
+
+ 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.
+ views::Widget* widget = new views::Widget;
+ widget->Init(params);
+ 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.
+ return widget;
+ }
+
+ private:
+ aura_shell::Shell* shell_;
oshima 2011/11/04 18:14:11 do you need this?
xiyuan 2011/11/04 18:39:31 Removed.
+
+ DISALLOW_COPY_AND_ASSIGN(ShellTest);
+};
+
+TEST_F(ShellTest, CreateAlwaysOnTopWindow) {
+ // Creates an always-on-top window.
+ views::Widget::InitParams widget_params(
+ views::Widget::InitParams::TYPE_WINDOW);
+ widget_params.keep_on_top = true;
+
+ views::Widget* widget = CreateTestWindow(widget_params);
+ widget->Show();
+
+ // It should be put into the always-on-top container.
+ EXPECT_EQ(
+ Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_AlwaysOnTopContainer),
+ widget->GetNativeWindow()->parent());
+
+ widget->Close();
+}
+
+TEST_F(ShellTest, ChangeAlwaysOnTop) {
+ views::Widget::InitParams widget_params(
+ views::Widget::InitParams::TYPE_WINDOW);
+
+ // Creates a normal window
+ views::Widget* widget = CreateTestWindow(widget_params);
+ widget->Show();
+
+ // It should be in default container.
+ EXPECT_EQ(
+ Shell::GetInstance()->GetContainer(
+ 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
+ widget->GetNativeWindow()->parent());
+
+ // Flip always-on-top flag.
+ widget->SetAlwaysOnTop(true);
+ // And it should in always on top container now.
+ EXPECT_EQ(
+ Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_AlwaysOnTopContainer),
+ widget->GetNativeWindow()->parent());
+
+ // Flip always-on-top flag.
+ widget->SetAlwaysOnTop(false);
+ // It should go back to default container.
+ EXPECT_EQ(
+ Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_DefaultContainer),
+ widget->GetNativeWindow()->parent());
+
+ // Set the same always-on-top flag again.
+ widget->SetAlwaysOnTop(false);
+ // Should have no effect and we are still in the default container.
+ EXPECT_EQ(
+ Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_DefaultContainer),
+ widget->GetNativeWindow()->parent());
+
+ widget->Close();
+}
+
+} // namespace test
+} // namespace aura_shell
« ui/aura_shell/shell.cc ('K') | « ui/aura_shell/shell.cc ('k') | ui/base/x/x11_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698