diff --git a/src/tests/kits/game/Jamfile b/src/tests/kits/game/Jamfile index 525f09f454..b39ce3f7bf 100644 --- a/src/tests/kits/game/Jamfile +++ b/src/tests/kits/game/Jamfile @@ -1,4 +1,5 @@ SubDir OBOS_TOP src tests kits game ; SubInclude OBOS_TOP src tests kits game file_game_sound_test ; +SubInclude OBOS_TOP src tests kits game set_mouse_position_test ; diff --git a/src/tests/kits/game/set_mouse_position_test/Jamfile b/src/tests/kits/game/set_mouse_position_test/Jamfile new file mode 100644 index 0000000000..e28a7153bc --- /dev/null +++ b/src/tests/kits/game/set_mouse_position_test/Jamfile @@ -0,0 +1,7 @@ +SubDir OBOS_TOP src tests kits game set_mouse_position_test ; + +SimpleTest set_mouse_position_test + : test_mouse.cpp + : game be root +; + diff --git a/src/tests/kits/game/set_mouse_position_test/test_mouse.cpp b/src/tests/kits/game/set_mouse_position_test/test_mouse.cpp new file mode 100644 index 0000000000..6d9c817227 --- /dev/null +++ b/src/tests/kits/game/set_mouse_position_test/test_mouse.cpp @@ -0,0 +1,112 @@ +/**Test app for set_mouse_position function of the game kit + @author Tim de Jong + @date 09/09/2002 + @version 1.0 + */ +#include +#include +#include +#include +#include + +class TestMouse: public BApplication +{ + public: + TestMouse(int times); + +}; + +//screenheight and screenwidth +int32 height, width; + +void mouse_move_up(int32 x) +{ + for (int32 t = (height); t > 0; t--) + set_mouse_position(x, t); +} + +void mouse_move_down(int32 x) +{ + for (int32 t = 0; t < (height); t++) + set_mouse_position(x,t); +} + +void mouse_move_left(int32 y) +{ + for (int32 t = (width); t > 0; t--) + set_mouse_position(t,y); +} + +void mouse_move_right(int32 y) +{ + for (int32 t = 0; t < (width); t++) + set_mouse_position(t,y); +} + +void mouse_move_diagonal1(int32 x, int32 y) +{ + int32 t1 = x; + double xmin = (double)x/y; + for (int32 t2 = y; t2 > 0; t2--) + { + t1 = int32(t1 - xmin); + set_mouse_position(t1,t2); + } +} + +void mouse_move_diagonal2(int32 x, int32 y) +{ + int32 t1 = x; + double xplus = (double)width/y; + for (int32 t2 = y; t2 > 0; t2--) + { + t1 = int32(t1 + xplus); + set_mouse_position(t1,t2); + } +} + +int main(int argc, char *argv[]) +{ + if (argc != 2) + { + printf("\n Usage: %s param: times, where times is the number of loops \n", argv[0]); + } + else + { + int times = atoi(argv[1]); + if (times > 0) + { + printf("\n times = %d \n", times); + TestMouse test(times); + test.Run(); + } + else printf("\n Error! times must be an integer greater than 0 \n"); + } + return 0; +} + +TestMouse::TestMouse(int times) + :BApplication("application/x-vnd.test_mouse") +{ + + //determine screenBounds + BScreen screen; + BRect screenBounds = screen.Frame(); + //save screenwidth and screenheight in height and width + height = int32(screenBounds.bottom - screenBounds.top) - 5; + width = int32(screenBounds.right - screenBounds.left) - 5; + + for (int t = 0; t < times; t++) + { + //make mouse moves + mouse_move_down(0); + mouse_move_right(height); + mouse_move_diagonal1(width,height); + mouse_move_right(0); + mouse_move_down(width); + mouse_move_left(height); + mouse_move_diagonal2(0,height); + } + //quit app + be_app -> PostMessage(B_QUIT_REQUESTED); +}