Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: ash/wm/workspace/workspace_layout_manager_unittest.cc

Issue 11421006: Desktop aura: Break aura::Window::SetParent in two. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: I think the content_unittests timeout on linux_aura is flake, but try to fix it anyway. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/property_util.h" 10 #include "ash/wm/property_util.h"
11 #include "ash/wm/shelf_layout_manager.h" 11 #include "ash/wm/shelf_layout_manager.h"
12 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
13 #include "ui/aura/client/aura_constants.h"
13 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
14 #include "ui/aura/test/test_windows.h" 15 #include "ui/aura/test/test_windows.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/gfx/insets.h" 17 #include "ui/gfx/insets.h"
17 18
18 namespace ash { 19 namespace ash {
19 20
20 namespace { 21 namespace {
21 22
22 class WorkspaceLayoutManagerTest : public test::AshTestBase { 23 class WorkspaceLayoutManagerTest : public test::AshTestBase {
23 public: 24 public:
24 WorkspaceLayoutManagerTest() {} 25 WorkspaceLayoutManagerTest() {}
25 virtual ~WorkspaceLayoutManagerTest() {} 26 virtual ~WorkspaceLayoutManagerTest() {}
26 27
27 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 28 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
28 return aura::test::CreateTestWindowWithBounds(bounds, NULL); 29 aura::Window* window = new aura::Window(NULL);
sky 2012/11/21 23:35:59 Isn't this CreateTestWindowInShellWithBounds ? In
30 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
31 window->Init(ui::LAYER_TEXTURED);
32 window->SetBounds(bounds);
33 window->Show();
34 window->SetProperty(aura::client::kCanMaximizeKey, true);
35 AddToRootWindow(window);
36 return window;
29 } 37 }
30 38
31 private: 39 private:
32 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerTest); 40 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerTest);
33 }; 41 };
34 42
35 // Verifies that a window containing a restore coordinate will be restored to 43 // Verifies that a window containing a restore coordinate will be restored to
36 // to the size prior to minimize, keeping the restore rectangle in tact (if 44 // to the size prior to minimize, keeping the restore rectangle in tact (if
37 // there is one). 45 // there is one).
38 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { 46 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // doesn't effect the restore bounds. 93 // doesn't effect the restore bounds.
86 TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) { 94 TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
87 DontClobberRestoreBoundsWindowObserver window_observer; 95 DontClobberRestoreBoundsWindowObserver window_observer;
88 scoped_ptr<aura::Window> window(new aura::Window(NULL)); 96 scoped_ptr<aura::Window> window(new aura::Window(NULL));
89 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 97 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
90 window->Init(ui::LAYER_TEXTURED); 98 window->Init(ui::LAYER_TEXTURED);
91 window->SetBounds(gfx::Rect(10, 20, 30, 40)); 99 window->SetBounds(gfx::Rect(10, 20, 30, 40));
92 // NOTE: for this test to exercise the failure the observer needs to be added 100 // NOTE: for this test to exercise the failure the observer needs to be added
93 // before the parent set. This mimics what BrowserFrameAura does. 101 // before the parent set. This mimics what BrowserFrameAura does.
94 window->AddObserver(&window_observer); 102 window->AddObserver(&window_observer);
95 window->SetParent(NULL); 103 AddToRootWindow(window.get());
96 window->Show(); 104 window->Show();
97 ash::wm::ActivateWindow(window.get()); 105 ash::wm::ActivateWindow(window.get());
98 106
99 scoped_ptr<aura::Window> window2(CreateTestWindow(gfx::Rect(12, 20, 30, 40))); 107 scoped_ptr<aura::Window> window2(CreateTestWindow(gfx::Rect(12, 20, 30, 40)));
100 window->AddTransientChild(window2.get()); 108 window->AddTransientChild(window2.get());
101 window2->Show(); 109 window2->Show();
102 110
103 window_observer.set_window(window2.get()); 111 window_observer.set_window(window2.get());
104 wm::MaximizeWindow(window.get()); 112 wm::MaximizeWindow(window.get());
105 EXPECT_EQ("10,20 30x40", GetRestoreBoundsInScreen(window.get())->ToString()); 113 EXPECT_EQ("10,20 30x40", GetRestoreBoundsInScreen(window.get())->ToString());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 157
150 // Directly setting the bounds triggers a slightly different code path. Verify 158 // Directly setting the bounds triggers a slightly different code path. Verify
151 // that too. 159 // that too.
152 window->SetBounds(window_bounds); 160 window->SetBounds(window_bounds);
153 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), 161 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
154 window->bounds().ToString()); 162 window->bounds().ToString());
155 } 163 }
156 164
157 } // namespace 165 } // namespace
158 } // namespace ash 166 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698