From 55de57d694ebb3037775d8ae049792123579c049 Mon Sep 17 00:00:00 2001 From: "sky@chromium.org" Date: Thu, 6 Sep 2012 04:29:02 +0000 Subject: A recent patched moved the desktop background beneath the system background, which breaks workspace animations. This makes the z-order as we want it (system background underneath desktop background) and adds a test. BUG=137342 TEST=covered by tests. R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10913100 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155123 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/shell_unittest.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'ash/shell_unittest.cc') diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc index d6b0d59..e9e7554 100644 --- a/ash/shell_unittest.cc +++ b/ash/shell_unittest.cc @@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/shell.h" + +#include +#include + #include "ash/ash_switches.h" #include "ash/desktop_background/desktop_background_widget_controller.h" #include "ash/launcher/launcher.h" -#include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" @@ -49,6 +53,8 @@ void ExpectAllContainers() { EXPECT_TRUE(Shell::GetContainer( root_window, internal::kShellWindowId_DesktopBackgroundContainer)); EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_SystemBackgroundContainer)); + EXPECT_TRUE(Shell::GetContainer( root_window, internal::kShellWindowId_DefaultContainer)); EXPECT_TRUE(Shell::GetContainer( root_window, internal::kShellWindowId_AlwaysOnTopContainer)); @@ -330,6 +336,60 @@ TEST_F(ShellTest, FullscreenWindowHidesShelf) { widget->Close(); } +namespace { + +// Builds the list of parents from |window| to the root. The returned vector is +// in reverse order (|window| is first). +std::vector BuildPathToRoot(aura::Window* window) { + std::vector results; + while (window) { + results.push_back(window); + window = window->parent(); + } + return results; +} + +} // namespace + +// The SystemBackgroundContainer needs to be behind the +// DesktopBackgroundContainer, otherwise workspace animations don't line up. +TEST_F(ShellTest, SystemBackgroundBehindDesktopBackground) { + aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); + aura::Window* desktop = Shell::GetContainer( + root_window, internal::kShellWindowId_DesktopBackgroundContainer); + ASSERT_TRUE(desktop != NULL); + aura::Window* system_bg = Shell::GetContainer( + root_window, internal::kShellWindowId_SystemBackgroundContainer); + ASSERT_TRUE(system_bg != NULL); + + std::vector desktop_parents(BuildPathToRoot(desktop)); + std::vector system_bg_parents(BuildPathToRoot(system_bg)); + + for (size_t i = 0; i < system_bg_parents.size(); ++i) { + std::vector::iterator desktop_i = + std::find(desktop_parents.begin(), desktop_parents.end(), + system_bg_parents[i]); + if (desktop_i != desktop_parents.end()) { + // Found the common parent. + ASSERT_NE(0u, i); + ASSERT_TRUE(desktop_i != desktop_parents.begin()); + aura::Window* common_parent = system_bg_parents[i]; + int system_child = static_cast(std::find( + common_parent->children().begin(), + common_parent->children().end(), system_bg_parents[i - 1]) - + common_parent->children().begin()); + int desktop_child = static_cast(std::find( + common_parent->children().begin(), + common_parent->children().end(), *(desktop_i - 1)) - + common_parent->children().begin()); + EXPECT_LT(system_child, desktop_child); + return; + } + } + EXPECT_TRUE(false) << + "system background and desktop background need to have a common parent"; +} + // This verifies WindowObservers are removed when a window is destroyed after // the Shell is destroyed. This scenario (aura::Windows being deleted after the // Shell) occurs if someone is holding a reference to an unparented Window, as -- cgit v1.1