OLD | NEW |
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/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 ui::SHOW_STATE_FULLSCREEN); | 208 ui::SHOW_STATE_FULLSCREEN); |
209 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 209 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
210 EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString()); | 210 EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString()); |
211 | 211 |
212 window_state->Restore(); | 212 window_state->Restore(); |
213 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 213 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
214 EXPECT_EQ("280,0 30x40", window->GetBoundsInScreen().ToString()); | 214 EXPECT_EQ("280,0 30x40", window->GetBoundsInScreen().ToString()); |
215 } | 215 } |
216 | 216 |
217 // WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver. | 217 // WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver. |
218 // This code mirrors what BrowserFrameAura does. In particular when this code | 218 // This code mirrors what BrowserFrameAsh does. In particular when this code |
219 // sees the window was maximized it changes the bounds of a secondary | 219 // sees the window was maximized it changes the bounds of a secondary |
220 // window. The secondary window mirrors the status window. | 220 // window. The secondary window mirrors the status window. |
221 class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver { | 221 class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver { |
222 public: | 222 public: |
223 DontClobberRestoreBoundsWindowObserver() : window_(NULL) {} | 223 DontClobberRestoreBoundsWindowObserver() : window_(NULL) {} |
224 | 224 |
225 void set_window(aura::Window* window) { window_ = window; } | 225 void set_window(aura::Window* window) { window_ = window; } |
226 | 226 |
227 virtual void OnWindowPropertyChanged(aura::Window* window, | 227 virtual void OnWindowPropertyChanged(aura::Window* window, |
228 const void* key, | 228 const void* key, |
(...skipping 22 matching lines...) Expand all Loading... |
251 // Creates a window, maximized the window and from within the maximized | 251 // Creates a window, maximized the window and from within the maximized |
252 // notification sets the bounds of a window to overlap the shelf. Verifies this | 252 // notification sets the bounds of a window to overlap the shelf. Verifies this |
253 // doesn't effect the restore bounds. | 253 // doesn't effect the restore bounds. |
254 TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) { | 254 TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) { |
255 DontClobberRestoreBoundsWindowObserver window_observer; | 255 DontClobberRestoreBoundsWindowObserver window_observer; |
256 scoped_ptr<aura::Window> window(new aura::Window(NULL)); | 256 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
257 window->SetType(aura::client::WINDOW_TYPE_NORMAL); | 257 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
258 window->Init(ui::LAYER_TEXTURED); | 258 window->Init(ui::LAYER_TEXTURED); |
259 window->SetBounds(gfx::Rect(10, 20, 30, 40)); | 259 window->SetBounds(gfx::Rect(10, 20, 30, 40)); |
260 // NOTE: for this test to exercise the failure the observer needs to be added | 260 // NOTE: for this test to exercise the failure the observer needs to be added |
261 // before the parent set. This mimics what BrowserFrameAura does. | 261 // before the parent set. This mimics what BrowserFrameAsh does. |
262 window->AddObserver(&window_observer); | 262 window->AddObserver(&window_observer); |
263 SetDefaultParentByPrimaryRootWindow(window.get()); | 263 SetDefaultParentByPrimaryRootWindow(window.get()); |
264 window->Show(); | 264 window->Show(); |
265 | 265 |
266 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 266 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
267 window_state->Activate(); | 267 window_state->Activate(); |
268 | 268 |
269 scoped_ptr<aura::Window> window2( | 269 scoped_ptr<aura::Window> window2( |
270 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40))); | 270 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40))); |
271 window->AddTransientChild(window2.get()); | 271 window->AddTransientChild(window2.get()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 window->bounds().ToString()); | 373 window->bounds().ToString()); |
374 | 374 |
375 // Directly setting the bounds triggers a slightly different code path. Verify | 375 // Directly setting the bounds triggers a slightly different code path. Verify |
376 // that too. | 376 // that too. |
377 window->SetBounds(window_bounds); | 377 window->SetBounds(window_bounds); |
378 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 378 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
379 window->bounds().ToString()); | 379 window->bounds().ToString()); |
380 } | 380 } |
381 | 381 |
382 } // namespace ash | 382 } // namespace ash |
OLD | NEW |