summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/root_window_controller.cc6
-rw-r--r--ash/shell_unittest.cc62
2 files changed, 64 insertions, 4 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 28132ea..8155f35 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -140,6 +140,9 @@ void CreateContainersInRootWindow(aura::RootWindow* root_window) {
// container (moved back on unlock). We want to make sure that there's an
// opaque layer occluding the non-lock-screen layers.
+ CreateContainer(internal::kShellWindowId_SystemBackgroundContainer,
+ "SystemBackgroundContainer", root_window);
+
aura::Window* desktop_background_containers = CreateContainer(
internal::kShellWindowId_DesktopBackgroundContainer,
"DesktopBackgroundContainer",
@@ -170,9 +173,6 @@ void CreateContainersInRootWindow(aura::RootWindow* root_window) {
"UnparentedControlContainer",
non_lock_screen_containers);
- CreateContainer(internal::kShellWindowId_SystemBackgroundContainer,
- "SystemBackgroundContainer", non_lock_screen_containers);
-
aura::Window* default_container = CreateContainer(
internal::kShellWindowId_DefaultContainer,
"DefaultContainer",
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