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

Unified Diff: ash/wm/workspace/workspace_event_filter_unittest.cc

Issue 10916221: Make ToplevelWindowEventFilter and WorkspaceEventFilter into event handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/workspace/workspace_event_filter_test_helper.cc ('k') | ash/wm/workspace/workspace_event_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_event_filter_unittest.cc
===================================================================
--- ash/wm/workspace/workspace_event_filter_unittest.cc (revision 155914)
+++ ash/wm/workspace/workspace_event_filter_unittest.cc (working copy)
@@ -1,171 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/wm/workspace/workspace_event_filter.h"
-
-#include "ash/shell.h"
-#include "ash/test/ash_test_base.h"
-#include "ash/wm/window_util.h"
-#include "ash/wm/workspace_controller_test_helper.h"
-#include "ash/wm/workspace/workspace_manager.h"
-#include "ash/wm/workspace_controller.h"
-#include "ui/aura/test/event_generator.h"
-#include "ui/aura/test/test_window_delegate.h"
-#include "ui/aura/window.h"
-#include "ui/base/hit_test.h"
-#include "ui/gfx/screen.h"
-
-namespace ash {
-namespace internal {
-
-class WorkspaceEventFilterTest : public test::AshTestBase {
- public:
- WorkspaceEventFilterTest() {}
- virtual ~WorkspaceEventFilterTest() {}
-
- protected:
- aura::Window* CreateTestWindow(aura::WindowDelegate* delegate,
- const gfx::Rect& bounds) {
- aura::Window* window = new aura::Window(delegate);
- window->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window->Init(ui::LAYER_TEXTURED);
- window->SetParent(NULL);
- window->SetBounds(bounds);
- window->Show();
- return window;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WorkspaceEventFilterTest);
-};
-
-TEST_F(WorkspaceEventFilterTest, DoubleClickSingleAxisResizeEdge) {
- // Double clicking the vertical resize edge of a window should maximize it
- // vertically.
- gfx::Rect restored_bounds(10, 10, 50, 50);
- aura::test::TestWindowDelegate wd;
- scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
-
- wm::ActivateWindow(window.get());
-
- gfx::Rect work_area =
- gfx::Screen::GetDisplayNearestWindow(window.get()).work_area();
-
- aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
- window.get());
-
- // Double-click the top resize edge.
- wd.set_window_component(HTTOP);
- // On X a double click actually generates a drag between each press/release.
- // Explicitly trigger this path since we had bugs in dealing with it
- // correctly.
- generator.PressLeftButton();
- generator.ReleaseLeftButton();
- generator.set_flags(ui::EF_IS_DOUBLE_CLICK);
- generator.PressLeftButton();
- generator.MoveMouseTo(generator.current_location(), 1);
- generator.ReleaseLeftButton();
- EXPECT_EQ(work_area.y(), window->bounds().y());
- EXPECT_EQ(work_area.height(), window->bounds().height());
- // Single-axis maximization is not considered real maximization.
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
-
- // Restore.
- generator.DoubleClickLeftButton();
- EXPECT_EQ(restored_bounds.y(), window->bounds().y());
- EXPECT_EQ(restored_bounds.height(), window->bounds().height());
-
- // Double-click the top resize edge again to maximize vertically, then double
- // click again to restore.
- generator.DoubleClickLeftButton();
- wd.set_window_component(HTCAPTION);
- generator.DoubleClickLeftButton();
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
-
- EXPECT_EQ(restored_bounds.y(), window->bounds().y());
- EXPECT_EQ(restored_bounds.height(), window->bounds().height());
-
- // Double clicking the left resize edge should maximize horizontally.
- wd.set_window_component(HTLEFT);
- generator.DoubleClickLeftButton();
- EXPECT_EQ(work_area.x(), window->bounds().x());
- EXPECT_EQ(work_area.width(), window->bounds().width());
- // Single-axis maximization is not considered real maximization.
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
-}
-
-TEST_F(WorkspaceEventFilterTest, DoubleClickCaptionTogglesMaximize) {
- aura::test::TestWindowDelegate wd;
- scoped_ptr<aura::Window> window(CreateTestWindow(&wd, gfx::Rect(1, 2, 3, 4)));
- wd.set_window_component(HTCAPTION);
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
- aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
- window.get());
- generator.DoubleClickLeftButton();
- EXPECT_NE("1,2 3x4", window->bounds().ToString());
-
- EXPECT_TRUE(wm::IsWindowMaximized(window.get()));
- generator.DoubleClickLeftButton();
-
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
- EXPECT_EQ("1,2 3x4", window->bounds().ToString());
-}
-
-TEST_F(WorkspaceEventFilterTest, DoubleTapCaptionTogglesMaximize) {
- aura::test::TestWindowDelegate wd;
- gfx::Rect bounds(10, 20, 30, 40);
- scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
- wd.set_window_component(HTCAPTION);
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
- aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
- window.get());
- generator.GestureTapAt(gfx::Point(25, 25));
- generator.GestureTapAt(gfx::Point(25, 25));
- RunAllPendingInMessageLoop();
- EXPECT_NE(bounds.ToString(), window->bounds().ToString());
- EXPECT_TRUE(wm::IsWindowMaximized(window.get()));
-
- generator.GestureTapAt(gfx::Point(5, 5));
- generator.GestureTapAt(gfx::Point(10, 10));
-
- EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
- EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
-}
-
-// Verifies deleting the window while dragging doesn't crash.
-TEST_F(WorkspaceEventFilterTest, DeleteWhenDragging) {
- // Create a large window in the background. This is necessary so that when we
- // delete |window| WorkspaceEventFilter is still the active EventFilter.
- aura::test::TestWindowDelegate wd2;
- scoped_ptr<aura::Window> window2(
- CreateTestWindow(&wd2, gfx::Rect(0, 0, 500, 500)));
-
- aura::test::TestWindowDelegate wd;
- const gfx::Rect bounds(10, 20, 30, 40);
- scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
- wd.set_window_component(HTCAPTION);
- aura::test::EventGenerator generator(window->GetRootWindow());
- generator.MoveMouseToCenterOf(window.get());
- generator.PressLeftButton();
- generator.MoveMouseTo(generator.current_location().Add(gfx::Point(50, 50)));
- DCHECK_NE(bounds.origin().ToString(), window->bounds().origin().ToString());
- window.reset();
- generator.MoveMouseTo(generator.current_location().Add(gfx::Point(50, 50)));
-}
-
-// Verifies deleting the window while in a run loop doesn't crash.
-TEST_F(WorkspaceEventFilterTest, DeleteWhileInRunLoop) {
- aura::test::TestWindowDelegate wd;
- const gfx::Rect bounds(10, 20, 30, 40);
- scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
- wd.set_window_component(HTCAPTION);
-
- ASSERT_TRUE(aura::client::GetWindowMoveClient(window->parent()));
- MessageLoop::current()->DeleteSoon(FROM_HERE, window.get());
- aura::client::GetWindowMoveClient(window->parent())->RunMoveLoop(
- window.release(), gfx::Point());
-}
-
-} // namespace internal
-} // namespace ash
« no previous file with comments | « ash/wm/workspace/workspace_event_filter_test_helper.cc ('k') | ash/wm/workspace/workspace_event_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698