| Index: ui/aura/window_unittest.cc
|
| diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
|
| index 386ddaab90976675149a0ef808955e2ba4e5ab00..08668bc5137af548b8d6943ea78de13fc37eb1bf 100644
|
| --- a/ui/aura/window_unittest.cc
|
| +++ b/ui/aura/window_unittest.cc
|
| @@ -13,6 +13,7 @@
|
| #include "ui/aura/desktop_observer.h"
|
| #include "ui/aura/event.h"
|
| #include "ui/aura/focus_manager.h"
|
| +#include "ui/aura/shadow.h"
|
| #include "ui/aura/test/aura_test_base.h"
|
| #include "ui/aura/test/event_generator.h"
|
| #include "ui/aura/test/test_windows.h"
|
| @@ -659,6 +660,65 @@ TEST_F(WindowTest, StopsEventPropagation) {
|
| EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow());
|
| }
|
|
|
| +// Tests that various methods in Window update the Shadow object as expected.
|
| +TEST_F(WindowTest, Shadow) {
|
| + Window* window = new Window(NULL);
|
| + window->SetType(aura::WINDOW_TYPE_NORMAL);
|
| +
|
| + // It should be safe to call this before the window has been initialized.
|
| + window->SetShadowVisible(true);
|
| + window->Init(ui::Layer::LAYER_HAS_TEXTURE);
|
| + window->SetParent(NULL);
|
| +
|
| + // The shadow's layer should have the same parent as the window's.
|
| + const internal::Shadow* shadow = window->shadow();
|
| + ASSERT_TRUE(shadow != NULL);
|
| + EXPECT_EQ(window->parent()->layer(), shadow->layer()->parent());
|
| +
|
| + // The shadow's visibility should be updated along with the window's.
|
| + window->Show();
|
| + 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->SetShadowVisible(false);
|
| + window->Show();
|
| + EXPECT_FALSE(shadow->layer()->visible());
|
| + window->SetShadowVisible(true);
|
| + EXPECT_TRUE(shadow->layer()->visible());
|
| +
|
| + // 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);
|
| + EXPECT_TRUE(shadow->layer()->parent() == NULL);
|
| +}
|
| +
|
| +// Tests that the window's shadow's bounds are updated correctly.
|
| +TEST_F(WindowTest, ShadowBounds) {
|
| + Window* window = new Window(NULL);
|
| + window->SetType(aura::WINDOW_TYPE_NORMAL);
|
| + window->Init(ui::Layer::LAYER_HAS_TEXTURE);
|
| + window->SetParent(NULL);
|
| +
|
| + 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->SetShadowVisible(true);
|
| + const internal::Shadow* shadow = window->shadow();
|
| + ASSERT_TRUE(shadow != NULL);
|
| + EXPECT_EQ(kOldBounds, shadow->content_bounds());
|
| +
|
| + // When we change the window's bounds, the shadow's shoudl be updated too.
|
| + gfx::Rect kNewBounds(50, 60, 500, 400);
|
| + window->SetBounds(kNewBounds);
|
| + EXPECT_EQ(kNewBounds, shadow->content_bounds());
|
| +}
|
| +
|
| // Various assertions for activating/deactivating.
|
| TEST_F(WindowTest, Deactivate) {
|
| TestWindowDelegate d1;
|
|
|