summaryrefslogtreecommitdiffstats
path: root/ash/wm/shadow_controller_unittest.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-23 01:04:56 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-23 01:04:56 +0000
commit7585967a09c178beb19d154411e16d0bf460b98c (patch)
treecc081a045d88728d3ec1afccdf603278f9a9fd6a /ash/wm/shadow_controller_unittest.cc
parent7d578660a7d482216efbac91434fd30bb122a154 (diff)
downloadchromium_src-7585967a09c178beb19d154411e16d0bf460b98c.zip
chromium_src-7585967a09c178beb19d154411e16d0bf460b98c.tar.gz
chromium_src-7585967a09c178beb19d154411e16d0bf460b98c.tar.bz2
Move some more files into ash... this time seed the window manager dir.
http://crbug.com/108457 TEST=none TBR=sky Review URL: http://codereview.chromium.org/9026017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115655 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/shadow_controller_unittest.cc')
-rw-r--r--ash/wm/shadow_controller_unittest.cc91
1 files changed, 91 insertions, 0 deletions
diff --git a/ash/wm/shadow_controller_unittest.cc b/ash/wm/shadow_controller_unittest.cc
new file mode 100644
index 0000000..f34018c
--- /dev/null
+++ b/ash/wm/shadow_controller_unittest.cc
@@ -0,0 +1,91 @@
+// 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 "ash/wm/shadow_controller.h"
+
+#include <algorithm>
+#include <vector>
+
+#include "ash/wm/shadow.h"
+#include "ash/wm/shadow_types.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/aura_shell/shell.h"
+#include "ui/aura_shell/test/aura_shell_test_base.h"
+#include "ui/aura_shell/window_properties.h"
+#include "ui/gfx/compositor/layer.h"
+
+namespace aura_shell {
+namespace test {
+
+typedef aura_shell::test::AuraShellTestBase ShadowControllerTest;
+
+// Tests that various methods in Window update the Shadow object as expected.
+TEST_F(ShadowControllerTest, Shadow) {
+ scoped_ptr<aura::Window> window(new aura::Window(NULL));
+ window->SetType(aura::client::WINDOW_TYPE_NORMAL);
+ window->Init(ui::Layer::LAYER_HAS_TEXTURE);
+ window->SetParent(NULL);
+
+ // We should create the shadow before the window is visible (the shadow's
+ // layer won't get drawn yet since it's a child of the window's layer).
+ internal::ShadowController::TestApi api(
+ aura_shell::Shell::GetInstance()->shadow_controller());
+ const internal::Shadow* shadow = api.GetShadowForWindow(window.get());
+ ASSERT_TRUE(shadow != NULL);
+ EXPECT_TRUE(shadow->layer()->visible());
+
+ // The shadow should remain visible after window visibility changes.
+ window->Show();
+ EXPECT_TRUE(shadow->layer()->visible());
+ window->Hide();
+ EXPECT_TRUE(shadow->layer()->visible());
+
+ // If the shadow is disabled, it should be hidden.
+ internal::SetShadowType(window.get(), internal::SHADOW_TYPE_NONE);
+ window->Show();
+ EXPECT_FALSE(shadow->layer()->visible());
+ internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR);
+ EXPECT_TRUE(shadow->layer()->visible());
+
+ // The shadow's layer should be a child of the window's layer.
+ EXPECT_EQ(window->layer(), shadow->layer()->parent());
+
+ window->parent()->RemoveChild(window.get());
+ aura::Window* window_ptr = window.get();
+ window.reset();
+ EXPECT_TRUE(api.GetShadowForWindow(window_ptr) == NULL);
+}
+
+// Tests that the window's shadow's bounds are updated correctly.
+TEST_F(ShadowControllerTest, ShadowBounds) {
+ scoped_ptr<aura::Window> window(new aura::Window(NULL));
+ window->SetType(aura::client::WINDOW_TYPE_NORMAL);
+ window->Init(ui::Layer::LAYER_HAS_TEXTURE);
+ window->SetParent(NULL);
+ window->Show();
+
+ const gfx::Rect kOldBounds(20, 30, 400, 300);
+ window->SetBounds(kOldBounds);
+
+ // When the shadow is first created, it should use the window's size (but
+ // remain at the origin, since it's a child of the window's layer).
+ internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR);
+ internal::ShadowController::TestApi api(
+ aura_shell::Shell::GetInstance()->shadow_controller());
+ const internal::Shadow* shadow = api.GetShadowForWindow(window.get());
+ ASSERT_TRUE(shadow != NULL);
+ EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(),
+ shadow->content_bounds().ToString());
+
+ // When we change the window's bounds, the shadow's should be updated too.
+ gfx::Rect kNewBounds(50, 60, 500, 400);
+ window->SetBounds(kNewBounds);
+ EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(),
+ shadow->content_bounds().ToString());
+}
+
+} // namespace test
+} // namespace aura_shell