Back to index

unity  6.0.0
Classes | Functions | Variables
test_gesture_engine.cpp File Reference
#include <gtest/gtest.h>
#include <compiz_mock/core/core.h>
#include "GestureEngine.h"

Go to the source code of this file.

Classes

class  GestureEngineTest

Functions

 TEST_F (GestureEngineTest, ThreeFingersDragMovesWindow)
 TEST_F (GestureEngineTest, ThreeFingersDragDoesntMoveStaticWindow)
 TEST_F (GestureEngineTest, ThreeFingersPinchMaximizesWindow)
 TEST_F (GestureEngineTest, ThreeFingersPinchRestoresWindow)
 TEST_F (GestureEngineTest, MinimalThreeFingersPinchDoesNothing)
 TEST_F (GestureEngineTest, DragGrabCheck)
int main (int argc, char **argv)

Variables

CompScreenMock concrete_screen_mock
CompScreenMockscreen_mock = &concrete_screen_mock
int pointerX_mock = 0
int pointerY_mock = 0

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 244 of file test_gesture_engine.cpp.

{
  ::testing::InitGoogleTest(&argc, argv);

  int ret = RUN_ALL_TESTS();

  return ret;
}
TEST_F ( GestureEngineTest  ,
ThreeFingersDragMovesWindow   
)

Definition at line 114 of file test_gesture_engine.cpp.

{
  GestureEngine gestureEngine(screen_mock);
  CompWindowMock *middle_window = screen_mock->_client_list_stacking[1];

  GeisAdapterMock::GeisTouchData touch_data;
  touch_data.id = 1;
  touch_data.touches = 3;
  touch_data.window = 123;
  touch_data.focus_x = 100; /* hits the middle window */
  touch_data.focus_y = 100;
  gestureEngine.OnTouchStart(&touch_data);

  GeisAdapterMock::GeisDragData drag_data;
  drag_data.id = 1;
  drag_data.touches = 3;
  drag_data.window = 123;
  drag_data.focus_x = 100; /* hits the middle window */
  drag_data.focus_y = 100;
  gestureEngine.OnDragStart(&drag_data);

  ASSERT_FALSE(middle_window->_moved);

  touch_data.focus_x += 10;
  touch_data.focus_y += 20;
  gestureEngine.OnTouchUpdate(&touch_data);

  drag_data.delta_x = 10;
  drag_data.delta_y = 20;
  drag_data.focus_x += drag_data.delta_x;
  drag_data.focus_y += drag_data.delta_x;
  gestureEngine.OnDragUpdate(&drag_data);

  ASSERT_TRUE(middle_window->_moved);
  ASSERT_EQ(drag_data.delta_x, middle_window->_movement_x);
  ASSERT_EQ(drag_data.delta_y, middle_window->_movement_y);
}

Here is the call graph for this function:

TEST_F ( GestureEngineTest  ,
ThreeFingersDragDoesntMoveStaticWindow   
)

Definition at line 152 of file test_gesture_engine.cpp.

{
  GestureEngine gestureEngine(screen_mock);
  CompWindowMock *middle_window = screen_mock->_client_list_stacking[1];

  /* can't be moved */
  middle_window->_actions = 0;

  GeisAdapterMock::GeisTouchData touch_data;
  touch_data.id = 1;
  touch_data.touches = 3;
  touch_data.window = 123;
  touch_data.focus_x = 100; /* hits the middle window */
  touch_data.focus_y = 100;
  gestureEngine.OnTouchStart(&touch_data);

  GeisAdapterMock::GeisDragData drag_data;
  drag_data.id = 1;
  drag_data.touches = 3;
  drag_data.window = 123;
  drag_data.focus_x = 100; /* hits the middle window */
  drag_data.focus_y = 100;
  gestureEngine.OnDragStart(&drag_data);

  ASSERT_FALSE(middle_window->_moved);

  touch_data.focus_x += 10;
  touch_data.focus_y += 20;
  gestureEngine.OnTouchUpdate(&touch_data);

  drag_data.delta_x = 10;
  drag_data.delta_y = 20;
  drag_data.focus_x += drag_data.delta_x;
  drag_data.focus_y += drag_data.delta_x;
  gestureEngine.OnDragUpdate(&drag_data);

  ASSERT_FALSE(middle_window->_moved);
}

Here is the call graph for this function:

TEST_F ( GestureEngineTest  ,
ThreeFingersPinchMaximizesWindow   
)

Definition at line 191 of file test_gesture_engine.cpp.

{
  GestureEngine gesture_engine(screen_mock);
  CompWindowMock *middle_window = screen_mock->_client_list_stacking[1];

  PerformPinch(gesture_engine, 2.0);

  ASSERT_EQ(1, middle_window->_maximize_count);
  ASSERT_EQ(MAXIMIZE_STATE, middle_window->_maximize_state);
}
TEST_F ( GestureEngineTest  ,
ThreeFingersPinchRestoresWindow   
)

Definition at line 202 of file test_gesture_engine.cpp.

{
  GestureEngine gesture_engine(screen_mock);
  CompWindowMock *middle_window = screen_mock->_client_list_stacking[1];

  PerformPinch(gesture_engine, 0.3);

  ASSERT_EQ(1, middle_window->_maximize_count);
  ASSERT_EQ(0, middle_window->_maximize_state);
}
TEST_F ( GestureEngineTest  ,
MinimalThreeFingersPinchDoesNothing   
)

Definition at line 213 of file test_gesture_engine.cpp.

{
  GestureEngine gesture_engine(screen_mock);
  CompWindowMock *middle_window = screen_mock->_client_list_stacking[1];

  PerformPinch(gesture_engine, 1.1);

  ASSERT_EQ(0, middle_window->_maximize_count);
}
TEST_F ( GestureEngineTest  ,
DragGrabCheck   
)

Definition at line 225 of file test_gesture_engine.cpp.

{
  screen_mock->_grab_count = 0;

  GestureEngine gesture_engine(screen_mock);

  GeisAdapterMock::GeisDragData drag_data;
  drag_data.id = 0;
  drag_data.touches = 3;
  drag_data.window = 123;
  drag_data.focus_x = 100; /* hits the middle window */
  drag_data.focus_y = 100;
  gesture_engine.OnDragStart(&drag_data);

  gesture_engine.OnDragFinish(&drag_data);

  ASSERT_EQ(0, screen_mock->_grab_count);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 25 of file test_gesture_engine.cpp.

int pointerX_mock = 0

Definition at line 27 of file test_gesture_engine.cpp.

int pointerY_mock = 0

Definition at line 28 of file test_gesture_engine.cpp.

Definition at line 26 of file test_gesture_engine.cpp.