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

Side by Side Diff: ash/wm/workspace_controller_unittest.cc

Issue 2700433002: cros: Fix minimized snapped window may not restore to the snapped bounds (Closed)
Patch Set: TEST_P to TEST_F Created 3 years, 10 months 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
« no previous file with comments | « ash/common/wm/default_state.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/wm/workspace_controller.h" 5 #include "ash/common/wm/workspace_controller.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "ash/common/session/session_controller.h" 9 #include "ash/common/session/session_controller.h"
10 #include "ash/common/shelf/shelf_layout_manager.h" 10 #include "ash/common/shelf/shelf_layout_manager.h"
11 #include "ash/common/shelf/shelf_widget.h" 11 #include "ash/common/shelf/shelf_widget.h"
12 #include "ash/common/shelf/wm_shelf.h" 12 #include "ash/common/shelf/wm_shelf.h"
13 #include "ash/common/system/status_area_widget.h" 13 #include "ash/common/system/status_area_widget.h"
14 #include "ash/common/test/test_shelf_delegate.h" 14 #include "ash/common/test/test_shelf_delegate.h"
15 #include "ash/common/wm/panels/panel_layout_manager.h" 15 #include "ash/common/wm/panels/panel_layout_manager.h"
16 #include "ash/common/wm/window_state.h" 16 #include "ash/common/wm/window_state.h"
17 #include "ash/common/wm/wm_event.h"
17 #include "ash/common/wm/workspace/workspace_window_resizer.h" 18 #include "ash/common/wm/workspace/workspace_window_resizer.h"
18 #include "ash/common/wm_shell.h" 19 #include "ash/common/wm_shell.h"
19 #include "ash/common/wm_window.h" 20 #include "ash/common/wm_window.h"
20 #include "ash/public/cpp/shell_window_ids.h" 21 #include "ash/public/cpp/shell_window_ids.h"
21 #include "ash/screen_util.h" 22 #include "ash/screen_util.h"
22 #include "ash/shell.h" 23 #include "ash/shell.h"
23 #include "ash/test/ash_test_base.h" 24 #include "ash/test/ash_test_base.h"
24 #include "ash/test/shell_test_api.h" 25 #include "ash/test/shell_test_api.h"
25 #include "ash/wm/window_state_aura.h" 26 #include "ash/wm/window_state_aura.h"
26 #include "ash/wm/window_util.h" 27 #include "ash/wm/window_util.h"
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 // a difference. 1304 // a difference.
1304 app->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 1305 app->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
1305 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent)); 1306 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent));
1306 1307
1307 // Activate the app. 1308 // Activate the app.
1308 ash::wm::ActivateWindow(app.get()); 1309 ash::wm::ActivateWindow(app.get());
1309 EXPECT_TRUE(wm::IsActiveWindow(app.get())); 1310 EXPECT_TRUE(wm::IsActiveWindow(app.get()));
1310 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent)); 1311 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent));
1311 } 1312 }
1312 1313
1314 // Test that minimizing and restoring a snapped window should restore to the
1315 // snapped bounds. When a window is created and snapped, it must be a
1316 // user-initiated operation, no need to do rearrangement for restoring this
1317 // window (crbug.com/692175).
1318 TEST_F(WorkspaceControllerTest, RestoreMinimizedSnappedWindow) {
1319 // Create an auto-positioned window.
1320 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
1321 wm::WindowState* window_state = wm::GetWindowState(window.get());
1322 window_state->set_window_position_managed(true);
1323 window->SetBounds(gfx::Rect(10, 20, 100, 200));
1324 window->Show();
1325
1326 // Left snap |window|.
1327 EXPECT_FALSE(window_state->bounds_changed_by_user());
1328 const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT);
1329 window_state->OnWMEvent(&snap_left);
1330 const gfx::Rect work_area =
1331 display::Screen::GetScreen()
1332 ->GetDisplayNearestPoint(window->bounds().origin())
1333 .work_area();
1334 gfx::Rect snapped_bounds(work_area.x(), work_area.y(), work_area.width() / 2,
1335 work_area.height());
1336 EXPECT_EQ(snapped_bounds, window->bounds());
1337 EXPECT_TRUE(window_state->bounds_changed_by_user());
1338
1339 // Minimize and Restore |window|, the restored bounds should be equal to the
1340 // bounds of left snapped state.
1341 window_state->Minimize();
1342 window_state->Restore();
1343 EXPECT_EQ(snapped_bounds, window->bounds());
1344 }
1345
1313 namespace { 1346 namespace {
1314 1347
1315 // Used by DragMaximizedNonTrackedWindow to track how many times the window 1348 // Used by DragMaximizedNonTrackedWindow to track how many times the window
1316 // hierarchy changes affecting the specified window. 1349 // hierarchy changes affecting the specified window.
1317 class DragMaximizedNonTrackedWindowObserver : public aura::WindowObserver { 1350 class DragMaximizedNonTrackedWindowObserver : public aura::WindowObserver {
1318 public: 1351 public:
1319 DragMaximizedNonTrackedWindowObserver(aura::Window* window) 1352 DragMaximizedNonTrackedWindowObserver(aura::Window* window)
1320 : change_count_(0), window_(window) {} 1353 : change_count_(0), window_(window) {}
1321 1354
1322 // Number of times OnWindowHierarchyChanged() has been received. 1355 // Number of times OnWindowHierarchyChanged() has been received.
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 ui::EventTimeForNow()); 1637 ui::EventTimeForNow());
1605 target = targeter->FindTargetForEvent(root, &touch); 1638 target = targeter->FindTargetForEvent(root, &touch);
1606 if (points[i].is_target_hit) 1639 if (points[i].is_target_hit)
1607 EXPECT_EQ(window.get(), target); 1640 EXPECT_EQ(window.get(), target);
1608 else 1641 else
1609 EXPECT_NE(window.get(), target); 1642 EXPECT_NE(window.get(), target);
1610 } 1643 }
1611 } 1644 }
1612 1645
1613 } // namespace ash 1646 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/default_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698