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

Unified Diff: ui/aura_shell/shadow_controller_unittest.cc

Issue 8555025: aura: Draw drop shadows under browsers and menus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor changes 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/shadow_controller.cc ('k') | ui/aura_shell/shell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/shadow_controller_unittest.cc
diff --git a/ui/aura_shell/shadow_controller_unittest.cc b/ui/aura_shell/shadow_controller_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..523543f9430ca3c99a1023a23d10bb5df81b178a
--- /dev/null
+++ b/ui/aura_shell/shadow_controller_unittest.cc
@@ -0,0 +1,90 @@
+// 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 "base/memory/scoped_ptr.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/shadow_types.h"
+#include "ui/aura/desktop.h"
+#include "ui/aura/window.h"
+#include "ui/aura_shell/shadow.h"
+#include "ui/aura_shell/shadow_controller.h"
+#include "ui/aura_shell/shell.h"
+#include "ui/aura_shell/test/aura_shell_test_base.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::WINDOW_TYPE_NORMAL);
+ window->SetIntProperty(aura::kShadowTypeKey, aura::SHADOW_TYPE_RECTANGULAR);
+ window->Init(ui::Layer::LAYER_HAS_TEXTURE);
+ window->SetParent(NULL);
+
+ // We shouldn't create the shadow before the window is visible.
+ internal::ShadowController::TestApi api(
+ aura_shell::Shell::GetInstance()->shadow_controller());
+ EXPECT_TRUE(api.GetShadowForWindow(window.get()) == NULL);
+
+ // The shadow's visibility should be updated along with the window's.
+ window->Show();
+ const internal::Shadow* shadow = api.GetShadowForWindow(window.get());
+ ASSERT_TRUE(shadow != NULL);
+ EXPECT_TRUE(shadow->layer()->visible());
+ window->Hide();
+ EXPECT_FALSE(shadow->layer()->visible());
+
+ // If the shadow is disabled, it shouldn't be shown even when the window is.
+ window->SetIntProperty(aura::kShadowTypeKey, aura::SHADOW_TYPE_NONE);
+ window->Show();
+ EXPECT_FALSE(shadow->layer()->visible());
+ window->SetIntProperty(aura::kShadowTypeKey, aura::SHADOW_TYPE_RECTANGULAR);
+ EXPECT_TRUE(shadow->layer()->visible());
+
+ // The shadow's layer should have the same parent as the window's.
+ EXPECT_EQ(window->parent()->layer(), shadow->layer()->parent());
+
+ // TODO(derat): Test stacking (after adding additional methods to ui::Layer so
+ // that stacking order can be queried).
+
+ // When we remove the window from the hierarchy, its shadow should be removed
+ // too.
+ window->parent()->RemoveChild(window.get());
+ EXPECT_TRUE(shadow->layer()->parent() == NULL);
+
+ 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::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 bounds.
+ window->SetIntProperty(aura::kShadowTypeKey, aura::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(kOldBounds, shadow->content_bounds());
+
+ // 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(kNewBounds, shadow->content_bounds());
+}
+
+} // namespace test
+} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/shadow_controller.cc ('k') | ui/aura_shell/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698