summaryrefslogtreecommitdiffstats
path: root/ash/shell_unittest.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-06 04:29:02 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-06 04:29:02 +0000
commit55de57d694ebb3037775d8ae049792123579c049 (patch)
treedc5845952c86c533aa0bd81ea1fc17ca6c475825 /ash/shell_unittest.cc
parent8feb52c0ba8d0136f03321827f9abe2aae1a757d (diff)
downloadchromium_src-55de57d694ebb3037775d8ae049792123579c049.zip
chromium_src-55de57d694ebb3037775d8ae049792123579c049.tar.gz
chromium_src-55de57d694ebb3037775d8ae049792123579c049.tar.bz2
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
Diffstat (limited to 'ash/shell_unittest.cc')
-rw-r--r--ash/shell_unittest.cc62
1 files changed, 61 insertions, 1 deletions
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 <algorithm>
+#include <vector>
+
#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<aura::Window*> BuildPathToRoot(aura::Window* window) {
+ std::vector<aura::Window*> 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<aura::Window*> desktop_parents(BuildPathToRoot(desktop));
+ std::vector<aura::Window*> system_bg_parents(BuildPathToRoot(system_bg));
+
+ for (size_t i = 0; i < system_bg_parents.size(); ++i) {
+ std::vector<aura::Window*>::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<int>(std::find(
+ common_parent->children().begin(),
+ common_parent->children().end(), system_bg_parents[i - 1]) -
+ common_parent->children().begin());
+ int desktop_child = static_cast<int>(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