summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 06:14:59 +0000
committeryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 06:14:59 +0000
commit77d555c7a0984ab10edc3d05016246d932cef2e1 (patch)
tree64f3b7379d2f7a4a176edb37d6a2587c590ac12c /ash
parent33dfcf8e932d9b9b6ed8c35d182efa4183a2ba5e (diff)
downloadchromium_src-77d555c7a0984ab10edc3d05016246d932cef2e1.zip
chromium_src-77d555c7a0984ab10edc3d05016246d932cef2e1.tar.gz
chromium_src-77d555c7a0984ab10edc3d05016246d932cef2e1.tar.bz2
Add tests for WarpMouseCursorIfNecessary().
BUG= TEST=try passed Review URL: https://chromiumcodereview.appspot.com/10836145 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150504 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/display/display_controller_unittest.cc86
1 files changed, 83 insertions, 3 deletions
diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc
index 48d2bab..3b739b5 100644
--- a/ash/display/display_controller_unittest.cc
+++ b/ash/display/display_controller_unittest.cc
@@ -6,13 +6,12 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
+#include "ui/aura/display_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
-#include "ui/aura/env.h"
-#include "ui/aura/display_manager.h"
-
namespace ash {
namespace test {
namespace {
@@ -125,5 +124,86 @@ TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) {
EXPECT_EQ("0,700 1000x1000", GetSecondaryDisplay().bounds().ToString());
}
+TEST_F(DisplayControllerTest, WarpMouse) {
+ UpdateDisplay("500x500,500x500");
+
+ ash::internal::DisplayController* controller =
+ Shell::GetInstance()->display_controller();
+ EXPECT_EQ(internal::DisplayController::RIGHT,
+ controller->secondary_display_layout());
+
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
+ gfx::Point(11, 11));
+ EXPECT_FALSE(is_warped);
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
+ gfx::Point(11, 11));
+ EXPECT_FALSE(is_warped);
+
+ // Touch the right edge of the primary root window. Pointer should warp.
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
+ gfx::Point(499, 11));
+ EXPECT_TRUE(is_warped);
+ EXPECT_EQ("501,11", // by 2px.
+ aura::Env::GetInstance()->last_mouse_location().ToString());
+
+ // Touch the left edge of the secondary root window. Pointer should warp.
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
+ gfx::Point(0, 11));
+ EXPECT_TRUE(is_warped);
+ EXPECT_EQ("498,11", // by 2px.
+ aura::Env::GetInstance()->last_mouse_location().ToString());
+
+ // Touch the left edge of the primary root window.
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
+ gfx::Point(0, 11));
+ EXPECT_FALSE(is_warped);
+ // Touch the top edge of the primary root window.
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
+ gfx::Point(11, 0));
+ EXPECT_FALSE(is_warped);
+ // Touch the bottom edge of the primary root window.
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
+ gfx::Point(11, 499));
+ EXPECT_FALSE(is_warped);
+ // Touch the right edge of the secondary root window.
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
+ gfx::Point(499, 11));
+ EXPECT_FALSE(is_warped);
+ // Touch the top edge of the secondary root window.
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
+ gfx::Point(11, 0));
+ EXPECT_FALSE(is_warped);
+ // Touch the bottom edge of the secondary root window.
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
+ gfx::Point(11, 499));
+ EXPECT_FALSE(is_warped);
+}
+
+TEST_F(DisplayControllerTest, SetUnsetDontWarpMousedFlag) {
+ UpdateDisplay("500x500,500x500");
+
+ ash::internal::DisplayController* controller =
+ Shell::GetInstance()->display_controller();
+
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ aura::Env::GetInstance()->SetLastMouseLocation(*root_windows[0],
+ gfx::Point(1, 1));
+
+ controller->set_dont_warp_mouse(true);
+ bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
+ gfx::Point(499, 11));
+ EXPECT_FALSE(is_warped);
+ EXPECT_EQ("1,1",
+ aura::Env::GetInstance()->last_mouse_location().ToString());
+
+ controller->set_dont_warp_mouse(false);
+ is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
+ gfx::Point(499, 11));
+ EXPECT_TRUE(is_warped);
+ EXPECT_EQ("501,11",
+ aura::Env::GetInstance()->last_mouse_location().ToString());
+}
+
} // namespace test
} // namespace ash