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

Unified Diff: ui/aura_shell/shell_unittest.cc

Issue 8638013: [cros Aura] Added modal container for screen lock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small fix 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
« no previous file with comments | « ui/aura_shell/shell.cc ('k') | ui/aura_shell/shell_window_ids.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/shell_unittest.cc
diff --git a/ui/aura_shell/shell_unittest.cc b/ui/aura_shell/shell_unittest.cc
index 9fecd883abb3bb48cfa16ace254284d3f31ea1ea..1be14e77a3291ff9ad86105700ca321cc353cd67 100644
--- a/ui/aura_shell/shell_unittest.cc
+++ b/ui/aura_shell/shell_unittest.cc
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/utf_string_conversions.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 "ui/aura_shell/test/aura_shell_test_base.h"
#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
namespace aura_shell {
namespace test {
@@ -45,6 +47,29 @@ void TestCreateWindow(views::Widget::InitParams::Type type,
widget->Close();
}
+class ModalWindow : public views::WidgetDelegateView {
+ public:
+ ModalWindow() {}
+ virtual ~ModalWindow() {}
+
+ // Overridden from views::WidgetDelegate:
+ virtual views::View* GetContentsView() OVERRIDE {
+ return this;
+ }
+ virtual bool CanResize() const OVERRIDE {
+ return true;
+ }
+ virtual string16 GetWindowTitle() const OVERRIDE {
+ return ASCIIToUTF16("Modal Window");
+ }
+ virtual bool IsModal() const OVERRIDE {
+ return true;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ModalWindow);
+};
+
} // namespace
class ShellTest : public AuraShellTestBase {
@@ -103,5 +128,80 @@ TEST_F(ShellTest, ChangeAlwaysOnTop) {
widget->Close();
}
+TEST_F(ShellTest, CreateModalWindow) {
+ views::Widget::InitParams widget_params(
+ views::Widget::InitParams::TYPE_WINDOW);
+
+ // Create a normal window.
+ views::Widget* widget = CreateTestWindow(widget_params);
+ widget->Show();
+
+ // It should be in default container.
+ EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
+
+ // Create a modal window.
+ views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
+ new ModalWindow(), widget->GetNativeView());
+ modal_widget->Show();
+
+ // It should be in modal container.
+ aura::Window* modal_container = Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_ModalContainer);
+ EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent());
+
+ modal_widget->Close();
+ widget->Close();
+}
+
+TEST_F(ShellTest, CreateLockScreenModalWindow) {
+ views::Widget::InitParams widget_params(
+ views::Widget::InitParams::TYPE_WINDOW);
+
+ // Create a normal window.
+ views::Widget* widget = CreateTestWindow(widget_params);
+ widget->Show();
+
+ // It should be in default container.
+ EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
+
+ // Create a LockScreen window.
+ views::Widget* lock_widget = CreateTestWindow(widget_params);
+ aura_shell::Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_LockScreenContainer)->
+ AddChild(lock_widget->GetNativeView());
+ lock_widget->Show();
+
+ // It should be in LockScreen container.
+ aura::Window* lock_screen = Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_LockScreenContainer);
+ EXPECT_EQ(lock_screen, lock_widget->GetNativeWindow()->parent());
+
+ // Create a modal window with a lock window as parent.
+ views::Widget* lock_modal_widget = views::Widget::CreateWindowWithParent(
+ new ModalWindow(), lock_widget->GetNativeView());
+ lock_modal_widget->Show();
+
+ // It should be in LockScreen modal container.
+ aura::Window* lock_modal_container = Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_LockModalContainer);
+ EXPECT_EQ(lock_modal_container,
+ lock_modal_widget->GetNativeWindow()->parent());
+
+ // Create a modal window with a normal window as parent.
+ views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
+ new ModalWindow(), widget->GetNativeView());
+ modal_widget->Show();
+
+ // It should be in non-LockScreen modal container.
+ aura::Window* modal_container = Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_ModalContainer);
+ EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent());
+
+ modal_widget->Close();
+ lock_modal_widget->Close();
+ lock_widget->Close();
+ widget->Close();
+}
+
} // namespace test
} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/shell.cc ('k') | ui/aura_shell/shell_window_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698