testautomation_clipboard.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /**
  2. * New/updated tests: aschiffler at ferzkopp dot net
  3. */
  4. #include <SDL3/SDL.h>
  5. #include <SDL3/SDL_test.h>
  6. #include "testautomation_suites.h"
  7. /* ================= Test Case Implementation ================== */
  8. static int clipboard_update_count;
  9. static int ClipboardEventWatch(void *userdata, SDL_Event *event)
  10. {
  11. if (event->type == SDL_EVENT_CLIPBOARD_UPDATE) {
  12. ++clipboard_update_count;
  13. }
  14. return 0;
  15. }
  16. enum
  17. {
  18. TEST_MIME_TYPE_TEXT,
  19. TEST_MIME_TYPE_CUSTOM_TEXT,
  20. TEST_MIME_TYPE_DATA,
  21. NUM_TEST_MIME_TYPES
  22. };
  23. static const char *test_mime_types[] = {
  24. "text/plain;charset=utf-8",
  25. "test/text",
  26. "test/data"
  27. };
  28. SDL_COMPILE_TIME_ASSERT(test_mime_types, SDL_arraysize(test_mime_types) == NUM_TEST_MIME_TYPES);
  29. typedef struct
  30. {
  31. const void *data;
  32. size_t data_size;
  33. } TestClipboardData;
  34. static int clipboard_callback_count;
  35. static const void *ClipboardDataCallback(void *userdata, const char *mime_type, size_t *length)
  36. {
  37. TestClipboardData *test_data = (TestClipboardData *)userdata;
  38. ++clipboard_callback_count;
  39. if (SDL_strcmp(mime_type, test_mime_types[TEST_MIME_TYPE_TEXT]) == 0) {
  40. /* We're returning the string "TEST", with no termination */
  41. static const char *test_text = "XXX TEST XXX";
  42. *length = 4;
  43. return test_text + 4;
  44. }
  45. if (SDL_strcmp(mime_type, test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT]) == 0) {
  46. /* We're returning the string "CUSTOM", with no termination */
  47. static const char *custom_text = "XXX CUSTOM XXX";
  48. *length = 6;
  49. return custom_text + 4;
  50. }
  51. if (SDL_strcmp(mime_type, test_mime_types[TEST_MIME_TYPE_DATA]) == 0) {
  52. *length = test_data->data_size;
  53. return test_data->data;
  54. }
  55. return NULL;
  56. }
  57. static int clipboard_cleanup_count;
  58. static void ClipboardCleanupCallback(void *userdata)
  59. {
  60. ++clipboard_cleanup_count;
  61. }
  62. /* Test case functions */
  63. /**
  64. * End-to-end test of SDL_xyzClipboardData functions
  65. * \sa SDL_HasClipboardData
  66. * \sa SDL_GetClipboardData
  67. * \sa SDL_SetClipboardData
  68. */
  69. static int clipboard_testClipboardDataFunctions(void *arg)
  70. {
  71. int result = -1;
  72. SDL_bool boolResult;
  73. int last_clipboard_update_count;
  74. int last_clipboard_callback_count;
  75. int last_clipboard_cleanup_count;
  76. const void *data;
  77. size_t size;
  78. const char *text;
  79. const char *expected_text;
  80. TestClipboardData test_data1 = {
  81. &test_data1,
  82. sizeof(test_data1)
  83. };
  84. TestClipboardData test_data2 = {
  85. &last_clipboard_callback_count,
  86. sizeof(last_clipboard_callback_count)
  87. };
  88. SDL_AddEventWatch(ClipboardEventWatch, NULL);
  89. /* Test clearing clipboard data */
  90. result = SDL_ClearClipboardData();
  91. SDLTest_AssertCheck(
  92. result == 0,
  93. "Validate SDL_ClearClipboardData result, expected 0, got %i",
  94. result);
  95. /* Test clearing clipboard data when it's already clear */
  96. last_clipboard_update_count = clipboard_update_count;
  97. result = SDL_ClearClipboardData();
  98. SDLTest_AssertCheck(
  99. result == 0,
  100. "Validate SDL_ClearClipboardData result, expected 0, got %i",
  101. result);
  102. SDLTest_AssertCheck(
  103. clipboard_update_count == last_clipboard_update_count,
  104. "Verify clipboard update unchanged, got %d",
  105. clipboard_update_count - last_clipboard_update_count);
  106. /* Validate error handling */
  107. last_clipboard_update_count = clipboard_update_count;
  108. result = SDL_SetClipboardData(NULL, NULL, NULL, test_mime_types, SDL_arraysize(test_mime_types));
  109. SDLTest_AssertCheck(
  110. result == -1,
  111. "Validate SDL_SetClipboardData(invalid) result, expected -1, got %i",
  112. result);
  113. SDLTest_AssertCheck(
  114. clipboard_update_count == last_clipboard_update_count,
  115. "Verify clipboard update count unchanged, got %d",
  116. clipboard_update_count - last_clipboard_update_count);
  117. last_clipboard_update_count = clipboard_update_count;
  118. result = SDL_SetClipboardData(ClipboardDataCallback, ClipboardCleanupCallback, NULL, NULL, 0);
  119. SDLTest_AssertCheck(
  120. result == -1,
  121. "Validate SDL_SetClipboardData(invalid) result, expected -1, got %i",
  122. result);
  123. SDLTest_AssertCheck(
  124. clipboard_update_count == last_clipboard_update_count,
  125. "Verify clipboard update count unchanged, got %d",
  126. clipboard_update_count - last_clipboard_update_count);
  127. /* Test setting and getting clipboard data */
  128. last_clipboard_update_count = clipboard_update_count;
  129. last_clipboard_callback_count = clipboard_callback_count;
  130. last_clipboard_cleanup_count = clipboard_cleanup_count;
  131. result = SDL_SetClipboardData(ClipboardDataCallback, ClipboardCleanupCallback, &test_data1, test_mime_types, SDL_arraysize(test_mime_types));
  132. SDLTest_AssertCheck(
  133. result == 0,
  134. "Validate SDL_SetClipboardData(test_data1) result, expected 0, got %i",
  135. result);
  136. SDLTest_AssertCheck(
  137. clipboard_update_count == last_clipboard_update_count + 1,
  138. "Verify clipboard update count incremented by 1, got %d",
  139. clipboard_update_count - last_clipboard_update_count);
  140. SDLTest_AssertCheck(
  141. clipboard_cleanup_count == last_clipboard_cleanup_count,
  142. "Verify clipboard cleanup count unchanged, got %d",
  143. clipboard_cleanup_count - last_clipboard_cleanup_count);
  144. expected_text = "TEST";
  145. text = (char *) SDL_GetClipboardText();
  146. SDLTest_AssertCheck(
  147. text && SDL_strcmp(text, expected_text) == 0,
  148. "Verify clipboard text, expected \"%s\", got \"%s\"",
  149. expected_text, text);
  150. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_TEXT]);
  151. SDLTest_AssertCheck(
  152. boolResult,
  153. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  154. text = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_TEXT], &size);
  155. SDLTest_AssertCheck(
  156. text && text[size] == '\0',
  157. "Verify test text data, expected null termination, got %c",
  158. text[size]);
  159. SDLTest_AssertCheck(
  160. text && SDL_strcmp(text, expected_text) == 0,
  161. "Verify test text data, expected \"%s\", got \"%s\"",
  162. expected_text, text);
  163. SDLTest_AssertCheck(
  164. size == SDL_strlen(expected_text),
  165. "Verify test text size, expected %d, got %d",
  166. (int)SDL_strlen(expected_text), (int)size);
  167. expected_text = "CUSTOM";
  168. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT]);
  169. SDLTest_AssertCheck(
  170. boolResult,
  171. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  172. text = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT], &size);
  173. SDLTest_AssertCheck(
  174. text && text[size] == '\0',
  175. "Verify test text data, expected null termination, got %c",
  176. text[size]);
  177. SDLTest_AssertCheck(
  178. text && SDL_strcmp(text, expected_text) == 0,
  179. "Verify test text data, expected \"%s\", got \"%s\"",
  180. expected_text, text);
  181. SDLTest_AssertCheck(
  182. size == SDL_strlen(expected_text),
  183. "Verify test text size, expected %d, got %d",
  184. (int)SDL_strlen(expected_text), (int)size);
  185. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_DATA]);
  186. SDLTest_AssertCheck(
  187. boolResult,
  188. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  189. data = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_DATA], &size);
  190. SDLTest_AssertCheck(
  191. SDL_memcmp(data, test_data1.data, test_data1.data_size) == 0,
  192. "Verify test data");
  193. SDLTest_AssertCheck(
  194. size == test_data1.data_size,
  195. "Verify test data size, expected %d, got %d",
  196. (int)test_data1.data_size, (int)size);
  197. boolResult = SDL_HasClipboardData("test/invalid");
  198. SDLTest_AssertCheck(
  199. !boolResult,
  200. "Verify has test text data, expected SDL_FALSE, got SDL_TRUE");
  201. data = SDL_GetClipboardData("test/invalid", &size);
  202. SDLTest_AssertCheck(
  203. data == NULL,
  204. "Verify invalid data, expected NULL, got %p",
  205. data);
  206. SDLTest_AssertCheck(
  207. size == 0,
  208. "Verify invalid data size, expected 0, got %d",
  209. (int)size);
  210. #if 0 /* There's no guarantee how or when the callback is called */
  211. SDLTest_AssertCheck(
  212. (clipboard_callback_count == last_clipboard_callback_count + 3) ||
  213. (clipboard_callback_count == last_clipboard_callback_count + 4),
  214. "Verify clipboard callback count incremented by 3 or 4, got %d",
  215. clipboard_callback_count - last_clipboard_callback_count);
  216. #endif
  217. /* Test setting and getting clipboard data again */
  218. last_clipboard_update_count = clipboard_update_count;
  219. last_clipboard_callback_count = clipboard_callback_count;
  220. last_clipboard_cleanup_count = clipboard_cleanup_count;
  221. result = SDL_SetClipboardData(ClipboardDataCallback, ClipboardCleanupCallback, &test_data2, test_mime_types, SDL_arraysize(test_mime_types));
  222. SDLTest_AssertCheck(
  223. result == 0,
  224. "Validate SDL_SetClipboardData(test_data2) result, expected 0, got %i",
  225. result);
  226. SDLTest_AssertCheck(
  227. clipboard_update_count == last_clipboard_update_count + 1,
  228. "Verify clipboard update count incremented by 1, got %d",
  229. clipboard_update_count - last_clipboard_update_count);
  230. SDLTest_AssertCheck(
  231. clipboard_cleanup_count == last_clipboard_cleanup_count + 1,
  232. "Verify clipboard cleanup count incremented by 1, got %d",
  233. clipboard_cleanup_count - last_clipboard_cleanup_count);
  234. expected_text = "TEST";
  235. text = (char *) SDL_GetClipboardText();
  236. SDLTest_AssertCheck(
  237. text && SDL_strcmp(text, expected_text) == 0,
  238. "Verify clipboard text, expected \"%s\", got \"%s\"",
  239. expected_text, text);
  240. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_TEXT]);
  241. SDLTest_AssertCheck(
  242. boolResult,
  243. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  244. text = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_TEXT], &size);
  245. SDLTest_AssertCheck(
  246. text && text[size] == '\0',
  247. "Verify test text data, expected null termination, got %c",
  248. text[size]);
  249. SDLTest_AssertCheck(
  250. text && SDL_strcmp(text, expected_text) == 0,
  251. "Verify test text data, expected \"%s\", got \"%s\"",
  252. expected_text, text);
  253. SDLTest_AssertCheck(
  254. size == SDL_strlen(expected_text),
  255. "Verify test text size, expected %d, got %d",
  256. (int)SDL_strlen(expected_text), (int)size);
  257. expected_text = "CUSTOM";
  258. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT]);
  259. SDLTest_AssertCheck(
  260. boolResult,
  261. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  262. text = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT], &size);
  263. SDLTest_AssertCheck(
  264. text && text[size] == '\0',
  265. "Verify test text data, expected null termination, got %c",
  266. text[size]);
  267. SDLTest_AssertCheck(
  268. text && SDL_strcmp(text, expected_text) == 0,
  269. "Verify test text data, expected \"%s\", got \"%s\"",
  270. expected_text, text);
  271. SDLTest_AssertCheck(
  272. size == SDL_strlen(expected_text),
  273. "Verify test text size, expected %d, got %d",
  274. (int)SDL_strlen(expected_text), (int)size);
  275. data = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_DATA], &size);
  276. SDLTest_AssertCheck(
  277. SDL_memcmp(data, test_data2.data, test_data2.data_size) == 0,
  278. "Verify test data");
  279. SDLTest_AssertCheck(
  280. size == test_data2.data_size,
  281. "Verify test data size, expected %d, got %d",
  282. (int)test_data2.data_size, (int)size);
  283. data = SDL_GetClipboardData("test/invalid", &size);
  284. SDLTest_AssertCheck(
  285. data == NULL,
  286. "Verify invalid data, expected NULL, got %p",
  287. data);
  288. SDLTest_AssertCheck(
  289. size == 0,
  290. "Verify invalid data size, expected 0, got %d",
  291. (int)size);
  292. #if 0 /* There's no guarantee how or when the callback is called */
  293. SDLTest_AssertCheck(
  294. (clipboard_callback_count == last_clipboard_callback_count + 3) ||
  295. (clipboard_callback_count == last_clipboard_callback_count + 4),
  296. "Verify clipboard callback count incremented by 3 or 4, got %d",
  297. clipboard_callback_count - last_clipboard_callback_count);
  298. #endif
  299. /* Test clearing clipboard data when has data */
  300. last_clipboard_update_count = clipboard_update_count;
  301. last_clipboard_cleanup_count = clipboard_cleanup_count;
  302. result = SDL_ClearClipboardData();
  303. SDLTest_AssertCheck(
  304. result == 0,
  305. "Validate SDL_ClearClipboardData result, expected 0, got %i",
  306. result);
  307. SDLTest_AssertCheck(
  308. clipboard_update_count == last_clipboard_update_count + 1,
  309. "Verify clipboard update count incremented by 1, got %d",
  310. clipboard_update_count - last_clipboard_update_count);
  311. SDLTest_AssertCheck(
  312. clipboard_cleanup_count == last_clipboard_cleanup_count + 1,
  313. "Verify clipboard cleanup count incremented by 1, got %d",
  314. clipboard_cleanup_count - last_clipboard_cleanup_count);
  315. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_TEXT]);
  316. SDLTest_AssertCheck(
  317. !boolResult,
  318. "Verify has test text data, expected SDL_FALSE, got SDL_TRUE");
  319. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_DATA]);
  320. SDLTest_AssertCheck(
  321. !boolResult,
  322. "Verify has test text data, expected SDL_FALSE, got SDL_TRUE");
  323. boolResult = SDL_HasClipboardData("test/invalid");
  324. SDLTest_AssertCheck(
  325. !boolResult,
  326. "Verify has test text data, expected SDL_FALSE, got SDL_TRUE");
  327. SDL_DelEventWatch(ClipboardEventWatch, NULL);
  328. return TEST_COMPLETED;
  329. }
  330. /**
  331. * End-to-end test of SDL_xyzClipboardText functions
  332. * \sa SDL_HasClipboardText
  333. * \sa SDL_GetClipboardText
  334. * \sa SDL_SetClipboardText
  335. */
  336. static int clipboard_testClipboardTextFunctions(void *arg)
  337. {
  338. char *textRef = SDLTest_RandomAsciiString();
  339. char *text = SDL_strdup(textRef);
  340. SDL_bool boolResult;
  341. int intResult;
  342. const char *charResult;
  343. int last_clipboard_update_count;
  344. SDL_AddEventWatch(ClipboardEventWatch, NULL);
  345. /* Empty clipboard text */
  346. last_clipboard_update_count = clipboard_update_count;
  347. intResult = SDL_SetClipboardText(NULL);
  348. SDLTest_AssertCheck(
  349. intResult == 0,
  350. "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
  351. intResult);
  352. charResult = SDL_GetClipboardText();
  353. SDLTest_AssertCheck(
  354. charResult && SDL_strcmp(charResult, "") == 0,
  355. "Verify SDL_GetClipboardText returned \"\", got %s",
  356. charResult);
  357. boolResult = SDL_HasClipboardText();
  358. SDLTest_AssertCheck(
  359. boolResult == SDL_FALSE,
  360. "Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
  361. (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
  362. SDLTest_AssertCheck(
  363. clipboard_update_count == last_clipboard_update_count,
  364. "Verify clipboard update unchanged, got %d",
  365. clipboard_update_count - last_clipboard_update_count);
  366. /* Set clipboard text */
  367. last_clipboard_update_count = clipboard_update_count;
  368. intResult = SDL_SetClipboardText(text);
  369. SDLTest_AssertCheck(
  370. intResult == 0,
  371. "Verify result from SDL_SetClipboardText(%s), expected 0, got %i", text,
  372. intResult);
  373. SDLTest_AssertCheck(
  374. SDL_strcmp(textRef, text) == 0,
  375. "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
  376. textRef, text);
  377. boolResult = SDL_HasClipboardText();
  378. SDLTest_AssertCheck(
  379. boolResult == SDL_TRUE,
  380. "Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
  381. (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
  382. charResult = SDL_GetClipboardText();
  383. SDLTest_AssertCheck(
  384. charResult && SDL_strcmp(textRef, charResult) == 0,
  385. "Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
  386. textRef, charResult);
  387. SDLTest_AssertCheck(
  388. clipboard_update_count == last_clipboard_update_count + 1,
  389. "Verify clipboard update count incremented by 1, got %d",
  390. clipboard_update_count - last_clipboard_update_count);
  391. /* Reset clipboard text */
  392. intResult = SDL_SetClipboardText(NULL);
  393. SDLTest_AssertCheck(
  394. intResult == 0,
  395. "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
  396. intResult);
  397. /* Cleanup */
  398. SDL_free(textRef);
  399. SDL_free(text);
  400. SDL_DelEventWatch(ClipboardEventWatch, NULL);
  401. return TEST_COMPLETED;
  402. }
  403. /**
  404. * End-to-end test of SDL_xyzPrimarySelectionText functions
  405. * \sa SDL_HasPrimarySelectionText
  406. * \sa SDL_GetPrimarySelectionText
  407. * \sa SDL_SetPrimarySelectionText
  408. */
  409. static int clipboard_testPrimarySelectionTextFunctions(void *arg)
  410. {
  411. char *textRef = SDLTest_RandomAsciiString();
  412. char *text = SDL_strdup(textRef);
  413. SDL_bool boolResult;
  414. int intResult;
  415. const char *charResult;
  416. int last_clipboard_update_count;
  417. SDL_AddEventWatch(ClipboardEventWatch, NULL);
  418. /* Empty primary selection */
  419. last_clipboard_update_count = clipboard_update_count;
  420. intResult = SDL_SetPrimarySelectionText(NULL);
  421. SDLTest_AssertCheck(
  422. intResult == 0,
  423. "Verify result from SDL_SetPrimarySelectionText(NULL), expected 0, got %i",
  424. intResult);
  425. charResult = SDL_GetPrimarySelectionText();
  426. SDLTest_AssertCheck(
  427. charResult && SDL_strcmp(charResult, "") == 0,
  428. "Verify SDL_GetPrimarySelectionText returned \"\", got %s",
  429. charResult);
  430. boolResult = SDL_HasPrimarySelectionText();
  431. SDLTest_AssertCheck(
  432. boolResult == SDL_FALSE,
  433. "Verify SDL_HasPrimarySelectionText returned SDL_FALSE, got %s",
  434. (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
  435. SDLTest_AssertCheck(
  436. clipboard_update_count == last_clipboard_update_count + 1,
  437. "Verify clipboard update count incremented by 1, got %d",
  438. clipboard_update_count - last_clipboard_update_count);
  439. /* Set primary selection */
  440. last_clipboard_update_count = clipboard_update_count;
  441. intResult = SDL_SetPrimarySelectionText(text);
  442. SDLTest_AssertCheck(
  443. intResult == 0,
  444. "Verify result from SDL_SetPrimarySelectionText(%s), expected 0, got %i", text,
  445. intResult);
  446. SDLTest_AssertCheck(
  447. SDL_strcmp(textRef, text) == 0,
  448. "Verify SDL_SetPrimarySelectionText did not modify input string, expected '%s', got '%s'",
  449. textRef, text);
  450. boolResult = SDL_HasPrimarySelectionText();
  451. SDLTest_AssertCheck(
  452. boolResult == SDL_TRUE,
  453. "Verify SDL_HasPrimarySelectionText returned SDL_TRUE, got %s",
  454. (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
  455. charResult = SDL_GetPrimarySelectionText();
  456. SDLTest_AssertCheck(
  457. charResult && SDL_strcmp(textRef, charResult) == 0,
  458. "Verify SDL_GetPrimarySelectionText returned correct string, expected '%s', got '%s'",
  459. textRef, charResult);
  460. SDLTest_AssertCheck(
  461. clipboard_update_count == last_clipboard_update_count + 1,
  462. "Verify clipboard update count incremented by 1, got %d",
  463. clipboard_update_count - last_clipboard_update_count);
  464. /* Reset primary selection */
  465. intResult = SDL_SetPrimarySelectionText(NULL);
  466. SDLTest_AssertCheck(
  467. intResult == 0,
  468. "Verify result from SDL_SetPrimarySelectionText(NULL), expected 0, got %i",
  469. intResult);
  470. /* Cleanup */
  471. SDL_free(textRef);
  472. SDL_free(text);
  473. SDL_DelEventWatch(ClipboardEventWatch, NULL);
  474. return TEST_COMPLETED;
  475. }
  476. /* ================= Test References ================== */
  477. static const SDLTest_TestCaseReference clipboardTest1 = {
  478. (SDLTest_TestCaseFp)clipboard_testClipboardDataFunctions, "clipboard_testClipboardDataFunctions", "End-to-end test of SDL_xyzClipboardData functions", TEST_ENABLED
  479. };
  480. static const SDLTest_TestCaseReference clipboardTest2 = {
  481. (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED
  482. };
  483. static const SDLTest_TestCaseReference clipboardTest3 = {
  484. (SDLTest_TestCaseFp)clipboard_testPrimarySelectionTextFunctions, "clipboard_testPrimarySelectionTextFunctions", "End-to-end test of SDL_xyzPrimarySelectionText functions", TEST_ENABLED
  485. };
  486. /* Sequence of Clipboard test cases */
  487. static const SDLTest_TestCaseReference *clipboardTests[] = {
  488. &clipboardTest1, &clipboardTest2, &clipboardTest3, NULL
  489. };
  490. /* Clipboard test suite (global) */
  491. SDLTest_TestSuiteReference clipboardTestSuite = {
  492. "Clipboard",
  493. NULL,
  494. clipboardTests,
  495. NULL
  496. };