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

Unified Diff: components/exo/pointer_unittest.cc

Issue 1750633002: components/exo: Extend pointer to use v5 protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed nits Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/exo/pointer_delegate.h ('k') | components/exo/wayland/server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/pointer_unittest.cc
diff --git a/components/exo/pointer_unittest.cc b/components/exo/pointer_unittest.cc
index 4f8ee500d0b2109890c34371339c79341fcaf673..2c060ed5c7ec1513eb23960aa677f71d45f500af 100644
--- a/components/exo/pointer_unittest.cc
+++ b/components/exo/pointer_unittest.cc
@@ -30,7 +30,11 @@ class MockPointerDelegate : public PointerDelegate {
MOCK_METHOD1(OnPointerLeave, void(Surface*));
MOCK_METHOD2(OnPointerMotion, void(base::TimeDelta, const gfx::Point&));
MOCK_METHOD3(OnPointerButton, void(base::TimeDelta, int, bool));
- MOCK_METHOD2(OnPointerWheel, void(base::TimeDelta, const gfx::Vector2d&));
+ MOCK_METHOD3(OnPointerScroll,
+ void(base::TimeDelta, const gfx::Vector2dF&, bool));
+ MOCK_METHOD1(OnPointerScrollCancel, void(base::TimeDelta));
+ MOCK_METHOD1(OnPointerScrollStop, void(base::TimeDelta));
+ MOCK_METHOD0(OnPointerFrame, void());
};
TEST_F(PointerTest, SetCursor) {
@@ -48,6 +52,7 @@ TEST_F(PointerTest, SetCursor) {
EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
.WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(delegate, OnPointerFrame()).Times(1);
EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::Point(), 0));
generator.MoveMouseTo(surface->GetBoundsInScreen().origin());
@@ -85,6 +90,7 @@ TEST_F(PointerTest, OnPointerEnter) {
EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
.WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(delegate, OnPointerFrame()).Times(1);
EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::Point(), 0));
generator.MoveMouseTo(surface->GetBoundsInScreen().origin());
@@ -107,6 +113,7 @@ TEST_F(PointerTest, OnPointerLeave) {
EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
.WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(delegate, OnPointerFrame()).Times(2);
EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::Point(), 0));
generator.MoveMouseTo(surface->GetBoundsInScreen().origin());
@@ -132,6 +139,8 @@ TEST_F(PointerTest, OnPointerMotion) {
EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
.WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(delegate, OnPointerFrame()).Times(4);
+
EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::Point(), 0));
generator.MoveMouseTo(surface->GetBoundsInScreen().origin());
@@ -151,6 +160,7 @@ TEST_F(PointerTest, OnPointerMotion) {
EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(sub_surface.get()))
.WillRepeatedly(testing::Return(true));
+
EXPECT_CALL(delegate, OnPointerLeave(surface.get()));
EXPECT_CALL(delegate, OnPointerEnter(sub_surface.get(), gfx::Point(), 0));
generator.MoveMouseTo(sub_surface->GetBoundsInScreen().origin());
@@ -178,6 +188,8 @@ TEST_F(PointerTest, OnPointerButton) {
EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
.WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(delegate, OnPointerFrame()).Times(3);
+
EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::Point(), 0));
generator.MoveMouseTo(surface->GetBoundsInScreen().origin());
@@ -191,7 +203,7 @@ TEST_F(PointerTest, OnPointerButton) {
pointer.reset();
}
-TEST_F(PointerTest, OnPointerWheel) {
+TEST_F(PointerTest, OnPointerScroll) {
scoped_ptr<Surface> surface(new Surface);
scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
gfx::Size buffer_size(10, 10);
@@ -203,20 +215,31 @@ TEST_F(PointerTest, OnPointerWheel) {
MockPointerDelegate delegate;
scoped_ptr<Pointer> pointer(new Pointer(&delegate));
ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
+ gfx::Point location = surface->GetBoundsInScreen().origin();
EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
.WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(delegate, OnPointerFrame()).Times(4);
+
EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::Point(), 0));
- generator.MoveMouseTo(surface->GetBoundsInScreen().origin());
+ generator.MoveMouseTo(location);
- EXPECT_CALL(delegate, OnPointerWheel(testing::_, gfx::Vector2d(1, 1)));
- generator.MoveMouseWheel(1, 1);
+ {
+ // Expect fling stop followed by scroll and scroll stop.
+ testing::InSequence sequence;
+
+ EXPECT_CALL(delegate, OnPointerScrollCancel(testing::_));
+ EXPECT_CALL(delegate,
+ OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false));
+ EXPECT_CALL(delegate, OnPointerScrollStop(testing::_));
+ }
+ generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
pointer.reset();
}
-TEST_F(PointerTest, OnPointerScroll) {
+TEST_F(PointerTest, OnPointerScrollDiscrete) {
scoped_ptr<Surface> surface(new Surface);
scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
gfx::Size buffer_size(10, 10);
@@ -228,15 +251,17 @@ TEST_F(PointerTest, OnPointerScroll) {
MockPointerDelegate delegate;
scoped_ptr<Pointer> pointer(new Pointer(&delegate));
ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
- gfx::Point location = surface->GetBoundsInScreen().origin();
EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
.WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(delegate, OnPointerFrame()).Times(2);
+
EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::Point(), 0));
- generator.MoveMouseTo(location);
+ generator.MoveMouseTo(surface->GetBoundsInScreen().origin());
- EXPECT_CALL(delegate, OnPointerWheel(testing::_, gfx::Vector2d(1, 1)));
- generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
+ EXPECT_CALL(delegate,
+ OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), true));
+ generator.MoveMouseWheel(1, 1);
EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
pointer.reset();
« no previous file with comments | « components/exo/pointer_delegate.h ('k') | components/exo/wayland/server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698