summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2015-12-03 09:38:21 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-03 17:39:23 +0000
commitcabad394cf3cd7cacd97ecc4a4365b651dac69b8 (patch)
tree11e3efef7d248fd6970f32291fe162f078053296 /ash
parent135bcd2349a7d6277d54f6e125bb84571903049b (diff)
downloadchromium_src-cabad394cf3cd7cacd97ecc4a4365b651dac69b8.zip
chromium_src-cabad394cf3cd7cacd97ecc4a4365b651dac69b8.tar.gz
chromium_src-cabad394cf3cd7cacd97ecc4a4365b651dac69b8.tar.bz2
Use WindowTracker when resizing root window as it may delete other window in unit tests.
This so far can happen in the test. The CL https://codereview.chromium.org/1483083003/ changes the timing of animation completion, which led to this state. BUG=None TEST=RootWindowLayoutManagerTest.DeleteChildDuringResize R=sky@chromium.org Review URL: https://codereview.chromium.org/1484383003 Cr-Commit-Position: refs/heads/master@{#363004}
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp1
-rw-r--r--ash/wm/panels/panel_layout_manager.cc6
-rw-r--r--ash/wm/root_window_layout_manager.cc14
-rw-r--r--ash/wm/root_window_layout_manager_unittest.cc46
4 files changed, 58 insertions, 9 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 6686402..1dd7430 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -908,6 +908,7 @@
'wm/panels/panel_layout_manager_unittest.cc',
'wm/panels/panel_window_resizer_unittest.cc',
'wm/resize_shadow_and_cursor_unittest.cc',
+ 'wm/root_window_layout_manager_unittest.cc',
'wm/screen_dimmer_unittest.cc',
'wm/session_state_animator_impl_unittest.cc',
'wm/stacking_controller_unittest.cc',
diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc
index 8e59a7f..412a8d1 100644
--- a/ash/wm/panels/panel_layout_manager.cc
+++ b/ash/wm/panels/panel_layout_manager.cc
@@ -545,9 +545,9 @@ void PanelLayoutManager::WillChangeVisibilityState(
if (restore_windows_on_shelf_visible_) {
scoped_ptr<aura::WindowTracker> restore_windows(
restore_windows_on_shelf_visible_.Pass());
- for (aura::WindowTracker::Windows::const_iterator iter =
- restore_windows->windows().begin(); iter !=
- restore_windows->windows().end(); ++iter) {
+ for (aura::Window::Windows::const_iterator iter =
+ restore_windows->windows().begin();
+ iter != restore_windows->windows().end(); ++iter) {
RestorePanel(*iter);
}
}
diff --git a/ash/wm/root_window_layout_manager.cc b/ash/wm/root_window_layout_manager.cc
index 65b71f4..542bbec 100644
--- a/ash/wm/root_window_layout_manager.cc
+++ b/ash/wm/root_window_layout_manager.cc
@@ -7,6 +7,7 @@
#include "ash/desktop_background/desktop_background_widget_controller.h"
#include "ash/root_window_controller.h"
#include "ui/aura/window_event_dispatcher.h"
+#include "ui/aura/window_tracker.h"
#include "ui/compositor/layer.h"
#include "ui/views/widget/widget.h"
@@ -32,12 +33,13 @@ void RootWindowLayoutManager::OnWindowResized() {
// Resize both our immediate children (the containers-of-containers animated
// by PowerButtonController) and their children (the actual containers).
- aura::Window::Windows::const_iterator i;
- for (i = owner_->children().begin(); i != owner_->children().end(); ++i) {
- (*i)->SetBounds(fullscreen_bounds);
- aura::Window::Windows::const_iterator j;
- for (j = (*i)->children().begin(); j != (*i)->children().end(); ++j)
- (*j)->SetBounds(fullscreen_bounds);
+ aura::WindowTracker children_tracker(owner_->children());
+ while (children_tracker.has_windows()) {
+ aura::Window* child = children_tracker.Pop();
+ child->SetBounds(fullscreen_bounds);
+ aura::WindowTracker grandchildren_tracker(child->children());
+ while (grandchildren_tracker.has_windows())
+ grandchildren_tracker.Pop()->SetBounds(fullscreen_bounds);
}
RootWindowController* root_window_controller =
GetRootWindowController(owner_);
diff --git a/ash/wm/root_window_layout_manager_unittest.cc b/ash/wm/root_window_layout_manager_unittest.cc
new file mode 100644
index 0000000..5769301
--- /dev/null
+++ b/ash/wm/root_window_layout_manager_unittest.cc
@@ -0,0 +1,46 @@
+// Copyright 2015 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 "ash/shell.h"
+#include "ash/shell_window_ids.h"
+#include "ash/test/ash_test_base.h"
+#include "ui/aura/test/test_windows.h"
+#include "ui/aura/window_observer.h"
+
+namespace ash {
+namespace {
+
+class WindowDeleter : public aura::WindowObserver {
+ public:
+ explicit WindowDeleter(aura::Window* window) : target_(window) {}
+
+ // aura::WindowObserver::
+ void OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override {
+ delete target_;
+ }
+
+ private:
+ aura::Window* target_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowDeleter);
+};
+
+} // namespace
+
+using RootWindowLayoutManagerTest = test::AshTestBase;
+
+TEST_F(RootWindowLayoutManagerTest, DeleteChildDuringResize) {
+ aura::Window* parent = Shell::GetPrimaryRootWindow()->GetChildById(
+ kShellWindowId_DesktopBackgroundContainer);
+ aura::Window* w1 = aura::test::CreateTestWindowWithId(1, parent);
+ aura::Window* w2 = aura::test::CreateTestWindowWithId(2, parent);
+ WindowDeleter deleter(w1);
+ w2->AddObserver(&deleter);
+ UpdateDisplay("600x500");
+ w2->RemoveObserver(&deleter);
+}
+
+} // namespace ash