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

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

Issue 55363004: Enables docked windows by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enables docked windows by default (rebase) Created 7 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
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/wm/workspace_controller.h" 5 #include "ash/wm/workspace_controller.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 1225
1226 // Activate the app. 1226 // Activate the app.
1227 ash::wm::ActivateWindow(app.get()); 1227 ash::wm::ActivateWindow(app.get());
1228 EXPECT_TRUE(wm::IsActiveWindow(app.get())); 1228 EXPECT_TRUE(wm::IsActiveWindow(app.get()));
1229 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent)); 1229 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent));
1230 } 1230 }
1231 1231
1232 namespace { 1232 namespace {
1233 1233
1234 // Used by DragMaximizedNonTrackedWindow to track how many times the window 1234 // Used by DragMaximizedNonTrackedWindow to track how many times the window
1235 // hierarchy changes. 1235 // hierarchy changes affecting specified window.
flackr 2013/11/06 20:02:31 nit:affecting the specified window.
varkha 2013/11/06 21:19:53 Done.
1236 class DragMaximizedNonTrackedWindowObserver 1236 class DragMaximizedNonTrackedWindowObserver
1237 : public aura::WindowObserver { 1237 : public aura::WindowObserver {
1238 public: 1238 public:
1239 DragMaximizedNonTrackedWindowObserver() : change_count_(0) { 1239 DragMaximizedNonTrackedWindowObserver(aura::Window* window)
1240 : change_count_(0),
1241 window_(window) {
1240 } 1242 }
1241 1243
1242 // Number of times OnWindowHierarchyChanged() has been received. 1244 // Number of times OnWindowHierarchyChanged() has been received.
1243 void clear_change_count() { change_count_ = 0; } 1245 void clear_change_count() { change_count_ = 0; }
1244 int change_count() const { 1246 int change_count() const {
1245 return change_count_; 1247 return change_count_;
1246 } 1248 }
1247 1249
1248 // aura::WindowObserver overrides: 1250 // aura::WindowObserver overrides:
1249 // Counts number of times a window is reparented. Ignores reparenting into and 1251 // Counts number of times a window is reparented. Ignores reparenting into and
1250 // from a docked container which is expected when a tab is dragged. 1252 // from a docked container which is expected when a tab is dragged.
1251 virtual void OnWindowHierarchyChanged( 1253 virtual void OnWindowHierarchyChanged(
1252 const HierarchyChangeParams& params) OVERRIDE { 1254 const HierarchyChangeParams& params) OVERRIDE {
1253 if ((params.old_parent->id() == kShellWindowId_DefaultContainer && 1255 if (params.target != window_ ||
1256 (params.old_parent->id() == kShellWindowId_DefaultContainer &&
1254 params.new_parent->id() == kShellWindowId_DockedContainer) || 1257 params.new_parent->id() == kShellWindowId_DockedContainer) ||
1255 (params.old_parent->id() == kShellWindowId_DockedContainer && 1258 (params.old_parent->id() == kShellWindowId_DockedContainer &&
1256 params.new_parent->id() == kShellWindowId_DefaultContainer)) { 1259 params.new_parent->id() == kShellWindowId_DefaultContainer)) {
1257 return; 1260 return;
1258 } 1261 }
1259 change_count_++; 1262 change_count_++;
1260 } 1263 }
1261 1264
1262 private: 1265 private:
1263 int change_count_; 1266 int change_count_;
1267 aura::Window* window_;
1264 1268
1265 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver); 1269 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver);
1266 }; 1270 };
1267 1271
1268 } // namespace 1272 } // namespace
1269 1273
1270 // Verifies setting tracked by workspace to false and then dragging a fullscreen 1274 // Verifies setting tracked by workspace to false and then dragging a fullscreen
1271 // window doesn't result in changing the window hierarchy (which typically 1275 // window doesn't result in changing the window hierarchy (which typically
1272 // indicates new workspaces have been created). 1276 // indicates new workspaces have been created).
1273 TEST_F(WorkspaceControllerTest, DragFullscreenNonTrackedWindow) { 1277 TEST_F(WorkspaceControllerTest, DragFullscreenNonTrackedWindow) {
1274 aura::test::EventGenerator generator( 1278 aura::test::EventGenerator generator(
1275 Shell::GetPrimaryRootWindow(), gfx::Point()); 1279 Shell::GetPrimaryRootWindow(), gfx::Point());
1276 generator.MoveMouseTo(5, 5); 1280 generator.MoveMouseTo(5, 5);
1277 1281
1278 aura::test::TestWindowDelegate delegate; 1282 aura::test::TestWindowDelegate delegate;
1279 delegate.set_window_component(HTCAPTION); 1283 delegate.set_window_component(HTCAPTION);
1280 scoped_ptr<Window> w1( 1284 scoped_ptr<Window> w1(
1281 aura::test::CreateTestWindowWithDelegate(&delegate, 1285 aura::test::CreateTestWindowWithDelegate(&delegate,
1282 aura::client::WINDOW_TYPE_NORMAL, 1286 aura::client::WINDOW_TYPE_NORMAL,
1283 gfx::Rect(5, 6, 7, 8), 1287 gfx::Rect(5, 6, 7, 8),
1284 NULL)); 1288 NULL));
1285 ParentWindowInPrimaryRootWindow(w1.get()); 1289 ParentWindowInPrimaryRootWindow(w1.get());
1286 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1290 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1287 w1->Show(); 1291 w1->Show();
1288 wm::ActivateWindow(w1.get()); 1292 wm::ActivateWindow(w1.get());
1289 DragMaximizedNonTrackedWindowObserver observer; 1293 DragMaximizedNonTrackedWindowObserver observer(w1.get());
1290 w1->parent()->parent()->AddObserver(&observer); 1294 w1->parent()->parent()->AddObserver(&observer);
1291 const gfx::Rect max_bounds(w1->bounds()); 1295 const gfx::Rect max_bounds(w1->bounds());
1292 1296
1293 generator.PressLeftButton(); 1297 generator.PressLeftButton();
1294 generator.MoveMouseTo(100, 100); 1298 generator.MoveMouseTo(100, 100);
1295 // The bounds shouldn't change (drag should result in nothing happening 1299 // The bounds shouldn't change (drag should result in nothing happening
1296 // now. 1300 // now.
1297 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); 1301 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString());
1298 1302
1299 generator.ReleaseLeftButton(); 1303 generator.ReleaseLeftButton();
(...skipping 28 matching lines...) Expand all
1328 delegate.set_window_component(HTCAPTION); 1332 delegate.set_window_component(HTCAPTION);
1329 scoped_ptr<Window> w1( 1333 scoped_ptr<Window> w1(
1330 aura::test::CreateTestWindowWithDelegate(&delegate, 1334 aura::test::CreateTestWindowWithDelegate(&delegate,
1331 aura::client::WINDOW_TYPE_NORMAL, 1335 aura::client::WINDOW_TYPE_NORMAL,
1332 gfx::Rect(5, 6, 7, 8), 1336 gfx::Rect(5, 6, 7, 8),
1333 NULL)); 1337 NULL));
1334 ParentWindowInPrimaryRootWindow(w1.get()); 1338 ParentWindowInPrimaryRootWindow(w1.get());
1335 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1339 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1336 w1->Show(); 1340 w1->Show();
1337 wm::ActivateWindow(w1.get()); 1341 wm::ActivateWindow(w1.get());
1338 DragMaximizedNonTrackedWindowObserver observer; 1342 DragMaximizedNonTrackedWindowObserver observer(w1.get());
1339 w1->parent()->parent()->AddObserver(&observer); 1343 w1->parent()->parent()->AddObserver(&observer);
1340 const gfx::Rect max_bounds(w1->bounds()); 1344 const gfx::Rect max_bounds(w1->bounds());
1341 1345
1342 generator.PressLeftButton(); 1346 generator.PressLeftButton();
1343 generator.MoveMouseTo(100, 100); 1347 generator.MoveMouseTo(100, 100);
1344 // The bounds shouldn't change (drag should result in nothing happening 1348 // The bounds shouldn't change (drag should result in nothing happening
1345 // now. 1349 // now.
1346 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); 1350 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString());
1347 1351
1348 generator.ReleaseLeftButton(); 1352 generator.ReleaseLeftButton();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 scoped_ptr<Window> maximized_window(CreateTestWindow()); 1384 scoped_ptr<Window> maximized_window(CreateTestWindow());
1381 maximized_window->SetProperty( 1385 maximized_window->SetProperty(
1382 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1386 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1383 maximized_window->Show(); 1387 maximized_window->Show();
1384 wm::ActivateWindow(maximized_window.get()); 1388 wm::ActivateWindow(maximized_window.get());
1385 EXPECT_TRUE(maximized_window->IsVisible()); 1389 EXPECT_TRUE(maximized_window->IsVisible());
1386 } 1390 }
1387 1391
1388 } // namespace internal 1392 } // namespace internal
1389 } // namespace ash 1393 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698