test/testautomation_mouse.c
changeset 6921 9a29af9de577
parent 6822 18f6818ba281
child 7144 c700de9c8ed4
equal deleted inserted replaced
6920:a966229b4107 6921:9a29af9de577
   411 
   411 
   412 #define MOUSE_TESTWINDOW_WIDTH	320
   412 #define MOUSE_TESTWINDOW_WIDTH	320
   413 #define MOUSE_TESTWINDOW_HEIGHT 200
   413 #define MOUSE_TESTWINDOW_HEIGHT 200
   414 
   414 
   415 /**
   415 /**
   416  * Create s test window
   416  * Creates a test window
   417  */
   417  */
   418 SDL_Window *_createTestWindow()
   418 SDL_Window *_createMouseSuiteTestWindow()
   419 {
   419 {
   420   int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT;
   420   int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT;
   421   SDL_Window *window;
   421   SDL_Window *window;
   422   window = SDL_CreateWindow("mouse_createTestWindow", posX, posY, width, height, 0);
   422   window = SDL_CreateWindow("mouse_createMouseSuiteTestWindow", posX, posY, width, height, 0);
   423   SDLTest_AssertPass("SDL_CreateWindow()");
   423   SDLTest_AssertPass("SDL_CreateWindow()");
   424   SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result");
   424   SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result");
   425   return window;
   425   return window;
   426 }
   426 }
   427 
   427 
   428 /*
   428 /*
   429  * Destroy test window  
   429  * Destroy test window  
   430  */
   430  */
   431 void _destroyTestWindow(SDL_Window *window)
   431 void _destroyMouseSuiteTestWindow(SDL_Window *window)
   432 {
   432 {
   433   if (window != NULL) {  
   433   if (window != NULL) {  
   434      SDL_DestroyWindow(window);
   434      SDL_DestroyWindow(window);
   435      window = NULL;
   435      window = NULL;
   436      SDLTest_AssertPass("SDL_DestroyWindow");
   436      SDLTest_AssertPass("SDL_DestroyWindow()");
   437   }
   437   }
   438 }
   438 }
   439 
   439 
   440 /**
   440 /**
   441  * @brief Check call to SDL_WarpMouseInWindow
   441  * @brief Check call to SDL_WarpMouseInWindow
   451   	int yPositions[] = {-1, 0, 1, h-1, h, h+1 };
   451   	int yPositions[] = {-1, 0, 1, h-1, h, h+1 };
   452 	int x, y, i, j;
   452 	int x, y, i, j;
   453 	SDL_Window *window;
   453 	SDL_Window *window;
   454 	
   454 	
   455 	/* Create test window */
   455 	/* Create test window */
   456 	window = _createTestWindow();
   456 	window = _createMouseSuiteTestWindow();
   457 	if (window == NULL) return TEST_ABORTED;
   457 	if (window == NULL) return TEST_ABORTED;
   458 
   458 
   459 	/* Mouse to random position inside window */	
   459 	/* Mouse to random position inside window */	
   460 	x = SDLTest_RandomIntegerInRange(1, w-1);
   460 	x = SDLTest_RandomIntegerInRange(1, w-1);
   461 	y = SDLTest_RandomIntegerInRange(1, h-1);
   461 	y = SDLTest_RandomIntegerInRange(1, h-1);
   480 	  }
   480 	  }
   481 	}
   481 	}
   482 	
   482 	
   483 
   483 
   484         /* Clean up test window */	
   484         /* Clean up test window */	
   485 	_destroyTestWindow(window);
   485 	_destroyMouseSuiteTestWindow(window);
   486 	
   486 	
   487 	return TEST_COMPLETED;
   487 	return TEST_COMPLETED;
   488 }
   488 }
   489 
   489 
   490 /**
   490 /**
   503 	/* Get focus - focus non-deterministic */
   503 	/* Get focus - focus non-deterministic */
   504 	focusWindow = SDL_GetMouseFocus();
   504 	focusWindow = SDL_GetMouseFocus();
   505 	SDLTest_AssertPass("SDL_GetMouseFocus()");
   505 	SDLTest_AssertPass("SDL_GetMouseFocus()");
   506 
   506 
   507         /* Create test window */	
   507         /* Create test window */	
   508 	window = _createTestWindow();
   508 	window = _createMouseSuiteTestWindow();
   509 	if (window == NULL) return TEST_ABORTED;
   509 	if (window == NULL) return TEST_ABORTED;
   510 
   510 
   511 	/* Mouse to random position inside window */	
   511 	/* Mouse to random position inside window */	
   512 	x = SDLTest_RandomIntegerInRange(1, w-1);
   512 	x = SDLTest_RandomIntegerInRange(1, w-1);
   513 	y = SDLTest_RandomIntegerInRange(1, h-1);
   513 	y = SDLTest_RandomIntegerInRange(1, h-1);
   529 	y = SDLTest_RandomIntegerInRange(-9, -1);
   529 	y = SDLTest_RandomIntegerInRange(-9, -1);
   530 	SDL_WarpMouseInWindow(window, x, y);
   530 	SDL_WarpMouseInWindow(window, x, y);
   531 	SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
   531 	SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
   532 
   532 
   533         /* Clean up test window */	
   533         /* Clean up test window */	
   534 	_destroyTestWindow(window);
   534 	_destroyMouseSuiteTestWindow(window);
   535 
   535 
   536 	/* Pump events to update focus state */
   536 	/* Pump events to update focus state */
   537 	SDL_PumpEvents();
   537 	SDL_PumpEvents();
   538 	SDLTest_AssertPass("SDL_PumpEvents()");
   538 	SDLTest_AssertPass("SDL_PumpEvents()");
   539 
   539