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

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

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: Use panel in test 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
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"
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 EXPECT_EQ(snapped_bounds, window->bounds()); 1336 EXPECT_EQ(snapped_bounds, window->bounds());
1337 EXPECT_TRUE(window_state->bounds_changed_by_user()); 1337 EXPECT_TRUE(window_state->bounds_changed_by_user());
1338 1338
1339 // Minimize and Restore |window|, the restored bounds should be equal to the 1339 // Minimize and Restore |window|, the restored bounds should be equal to the
1340 // bounds of left snapped state. 1340 // bounds of left snapped state.
1341 window_state->Minimize(); 1341 window_state->Minimize();
1342 window_state->Restore(); 1342 window_state->Restore();
1343 EXPECT_EQ(snapped_bounds, window->bounds()); 1343 EXPECT_EQ(snapped_bounds, window->bounds());
1344 } 1344 }
1345 1345
1346 namespace {
1347
1348 // Used by DragMaximizedNonTrackedWindow to track how many times the window
1349 // hierarchy changes affecting the specified window.
1350 class DragMaximizedNonTrackedWindowObserver : public aura::WindowObserver {
1351 public:
1352 DragMaximizedNonTrackedWindowObserver(aura::Window* window)
1353 : change_count_(0), window_(window) {}
1354
1355 // Number of times OnWindowHierarchyChanged() has been received.
1356 void clear_change_count() { change_count_ = 0; }
1357 int change_count() const { return change_count_; }
1358
1359 // aura::WindowObserver overrides:
1360 // Counts number of times a window is reparented. Ignores reparenting into and
1361 // from a docked container which is expected when a tab is dragged.
1362 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override {
1363 if (params.target != window_ ||
1364 (params.old_parent->id() == kShellWindowId_DefaultContainer &&
1365 params.new_parent->id() == kShellWindowId_DockedContainer) ||
1366 (params.old_parent->id() == kShellWindowId_DockedContainer &&
1367 params.new_parent->id() == kShellWindowId_DefaultContainer)) {
1368 return;
1369 }
1370 change_count_++;
1371 }
1372
1373 private:
1374 int change_count_;
1375 aura::Window* window_;
1376
1377 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver);
1378 };
1379
1380 } // namespace
1381
1382 // Verifies that a new maximized window becomes visible after its activation 1346 // Verifies that a new maximized window becomes visible after its activation
1383 // is requested, even though it does not become activated because a system 1347 // is requested, even though it does not become activated because a system
1384 // modal window is active. 1348 // modal window is active.
1385 TEST_F(WorkspaceControllerTest, SwitchFromModal) { 1349 TEST_F(WorkspaceControllerTest, SwitchFromModal) {
1386 std::unique_ptr<Window> modal_window(CreateTestWindowUnparented()); 1350 std::unique_ptr<Window> modal_window(CreateTestWindowUnparented());
1387 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); 1351 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22));
1388 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 1352 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
1389 ParentWindowInPrimaryRootWindow(modal_window.get()); 1353 ParentWindowInPrimaryRootWindow(modal_window.get());
1390 modal_window->Show(); 1354 modal_window->Show();
1391 wm::ActivateWindow(modal_window.get()); 1355 wm::ActivateWindow(modal_window.get());
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, location, 0, 1554 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, location, 0,
1591 ui::EventTimeForNow()); 1555 ui::EventTimeForNow());
1592 ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch); 1556 ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch);
1593 if (points[i].is_target_hit) 1557 if (points[i].is_target_hit)
1594 EXPECT_EQ(window.get(), target); 1558 EXPECT_EQ(window.get(), target);
1595 else 1559 else
1596 EXPECT_NE(window.get(), target); 1560 EXPECT_NE(window.get(), target);
1597 } 1561 }
1598 } 1562 }
1599 1563
1600 // Verifies events targeting just outside the window edges for docked windows.
1601 TEST_F(WorkspaceControllerTest, WindowEdgeHitTestDocked) {
1602 aura::test::TestWindowDelegate delegate;
1603 // Make window smaller than the minimum docked area so that the window edges
1604 // are exposed.
1605 delegate.set_maximum_size(gfx::Size(180, 200));
1606 std::unique_ptr<Window> window(aura::test::CreateTestWindowWithDelegate(
1607 &delegate, 123, gfx::Rect(20, 10, 100, 50), NULL));
1608 ParentWindowInPrimaryRootWindow(window.get());
1609 aura::Window* docked_container = Shell::GetContainer(
1610 window->GetRootWindow(), kShellWindowId_DockedContainer);
1611 docked_container->AddChild(window.get());
1612 window->Show();
1613 aura::Window* root = window->GetRootWindow();
1614 ui::EventTargeter* targeter =
1615 root->GetHost()->dispatcher()->GetDefaultEventTargeter();
1616 const gfx::Rect bounds = window->bounds();
1617 const int kNumPoints = 5;
1618 struct {
1619 const char* direction;
1620 gfx::Point location;
1621 bool is_target_hit;
1622 } points[kNumPoints] = {
1623 {"left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true},
1624 {"top", gfx::Point(bounds.x() + 10, bounds.y() - 2), true},
1625 {"right", gfx::Point(bounds.right() + 2, bounds.y() + 10), true},
1626 {"bottom", gfx::Point(bounds.x() + 10, bounds.bottom() + 2), true},
1627 {"outside", gfx::Point(bounds.x() + 10, bounds.y() - 31), false},
1628 };
1629 for (int i = 0; i < kNumPoints; ++i) {
1630 SCOPED_TRACE(points[i].direction);
1631 const gfx::Point& location = points[i].location;
1632 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, location, location,
1633 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
1634 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
1635 if (points[i].is_target_hit)
1636 EXPECT_EQ(window.get(), target);
1637 else
1638 EXPECT_NE(window.get(), target);
1639
1640 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, location, 0,
1641 ui::EventTimeForNow());
1642 target = targeter->FindTargetForEvent(root, &touch);
1643 if (points[i].is_target_hit)
1644 EXPECT_EQ(window.get(), target);
1645 else
1646 EXPECT_NE(window.get(), target);
1647 }
1648 }
1649
1650 } // namespace ash 1564 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698