testautomation_clipboard.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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. void *data;
  77. size_t size;
  78. 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 = 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. SDL_free(text);
  168. expected_text = "CUSTOM";
  169. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT]);
  170. SDLTest_AssertCheck(
  171. boolResult,
  172. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  173. text = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT], &size);
  174. SDLTest_AssertCheck(
  175. text && text[size] == '\0',
  176. "Verify test text data, expected null termination, got %c",
  177. text[size]);
  178. SDLTest_AssertCheck(
  179. text && SDL_strcmp(text, expected_text) == 0,
  180. "Verify test text data, expected \"%s\", got \"%s\"",
  181. expected_text, text);
  182. SDLTest_AssertCheck(
  183. size == SDL_strlen(expected_text),
  184. "Verify test text size, expected %d, got %d",
  185. (int)SDL_strlen(expected_text), (int)size);
  186. SDL_free(text);
  187. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_DATA]);
  188. SDLTest_AssertCheck(
  189. boolResult,
  190. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  191. data = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_DATA], &size);
  192. SDLTest_AssertCheck(
  193. SDL_memcmp(data, test_data1.data, test_data1.data_size) == 0,
  194. "Verify test data");
  195. SDLTest_AssertCheck(
  196. size == test_data1.data_size,
  197. "Verify test data size, expected %d, got %d",
  198. (int)test_data1.data_size, (int)size);
  199. SDL_free(data);
  200. boolResult = SDL_HasClipboardData("test/invalid");
  201. SDLTest_AssertCheck(
  202. !boolResult,
  203. "Verify has test text data, expected SDL_FALSE, got SDL_TRUE");
  204. data = SDL_GetClipboardData("test/invalid", &size);
  205. SDLTest_AssertCheck(
  206. data == NULL,
  207. "Verify invalid data, expected NULL, got %p",
  208. data);
  209. SDLTest_AssertCheck(
  210. size == 0,
  211. "Verify invalid data size, expected 0, got %d",
  212. (int)size);
  213. SDL_free(data);
  214. #if 0 /* There's no guarantee how or when the callback is called */
  215. SDLTest_AssertCheck(
  216. (clipboard_callback_count == last_clipboard_callback_count + 3) ||
  217. (clipboard_callback_count == last_clipboard_callback_count + 4),
  218. "Verify clipboard callback count incremented by 3 or 4, got %d",
  219. clipboard_callback_count - last_clipboard_callback_count);
  220. #endif
  221. /* Test setting and getting clipboard data again */
  222. last_clipboard_update_count = clipboard_update_count;
  223. last_clipboard_callback_count = clipboard_callback_count;
  224. last_clipboard_cleanup_count = clipboard_cleanup_count;
  225. result = SDL_SetClipboardData(ClipboardDataCallback, ClipboardCleanupCallback, &test_data2, test_mime_types, SDL_arraysize(test_mime_types));
  226. SDLTest_AssertCheck(
  227. result == 0,
  228. "Validate SDL_SetClipboardData(test_data2) result, expected 0, got %i",
  229. result);
  230. SDLTest_AssertCheck(
  231. clipboard_update_count == last_clipboard_update_count + 1,
  232. "Verify clipboard update count incremented by 1, got %d",
  233. clipboard_update_count - last_clipboard_update_count);
  234. SDLTest_AssertCheck(
  235. clipboard_cleanup_count == last_clipboard_cleanup_count + 1,
  236. "Verify clipboard cleanup count incremented by 1, got %d",
  237. clipboard_cleanup_count - last_clipboard_cleanup_count);
  238. expected_text = "TEST";
  239. text = SDL_GetClipboardText();
  240. SDLTest_AssertCheck(
  241. text && SDL_strcmp(text, expected_text) == 0,
  242. "Verify clipboard text, expected \"%s\", got \"%s\"",
  243. expected_text, text);
  244. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_TEXT]);
  245. SDLTest_AssertCheck(
  246. boolResult,
  247. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  248. text = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_TEXT], &size);
  249. SDLTest_AssertCheck(
  250. text && text[size] == '\0',
  251. "Verify test text data, expected null termination, got %c",
  252. text[size]);
  253. SDLTest_AssertCheck(
  254. text && SDL_strcmp(text, expected_text) == 0,
  255. "Verify test text data, expected \"%s\", got \"%s\"",
  256. expected_text, text);
  257. SDLTest_AssertCheck(
  258. size == SDL_strlen(expected_text),
  259. "Verify test text size, expected %d, got %d",
  260. (int)SDL_strlen(expected_text), (int)size);
  261. SDL_free(text);
  262. expected_text = "CUSTOM";
  263. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT]);
  264. SDLTest_AssertCheck(
  265. boolResult,
  266. "Verify has test text data, expected SDL_TRUE, got SDL_FALSE");
  267. text = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_CUSTOM_TEXT], &size);
  268. SDLTest_AssertCheck(
  269. text && text[size] == '\0',
  270. "Verify test text data, expected null termination, got %c",
  271. text[size]);
  272. SDLTest_AssertCheck(
  273. text && SDL_strcmp(text, expected_text) == 0,
  274. "Verify test text data, expected \"%s\", got \"%s\"",
  275. expected_text, text);
  276. SDLTest_AssertCheck(
  277. size == SDL_strlen(expected_text),
  278. "Verify test text size, expected %d, got %d",
  279. (int)SDL_strlen(expected_text), (int)size);
  280. SDL_free(text);
  281. data = SDL_GetClipboardData(test_mime_types[TEST_MIME_TYPE_DATA], &size);
  282. SDLTest_AssertCheck(
  283. SDL_memcmp(data, test_data2.data, test_data2.data_size) == 0,
  284. "Verify test data");
  285. SDLTest_AssertCheck(
  286. size == test_data2.data_size,
  287. "Verify test data size, expected %d, got %d",
  288. (int)test_data2.data_size, (int)size);
  289. SDL_free(data);
  290. data = SDL_GetClipboardData("test/invalid", &size);
  291. SDLTest_AssertCheck(
  292. data == NULL,
  293. "Verify invalid data, expected NULL, got %p",
  294. data);
  295. SDLTest_AssertCheck(
  296. size == 0,
  297. "Verify invalid data size, expected 0, got %d",
  298. (int)size);
  299. SDL_free(data);
  300. #if 0 /* There's no guarantee how or when the callback is called */
  301. SDLTest_AssertCheck(
  302. (clipboard_callback_count == last_clipboard_callback_count + 3) ||
  303. (clipboard_callback_count == last_clipboard_callback_count + 4),
  304. "Verify clipboard callback count incremented by 3 or 4, got %d",
  305. clipboard_callback_count - last_clipboard_callback_count);
  306. #endif
  307. /* Test clearing clipboard data when has data */
  308. last_clipboard_update_count = clipboard_update_count;
  309. last_clipboard_cleanup_count = clipboard_cleanup_count;
  310. result = SDL_ClearClipboardData();
  311. SDLTest_AssertCheck(
  312. result == 0,
  313. "Validate SDL_ClearClipboardData result, expected 0, got %i",
  314. result);
  315. SDLTest_AssertCheck(
  316. clipboard_update_count == last_clipboard_update_count + 1,
  317. "Verify clipboard update count incremented by 1, got %d",
  318. clipboard_update_count - last_clipboard_update_count);
  319. SDLTest_AssertCheck(
  320. clipboard_cleanup_count == last_clipboard_cleanup_count + 1,
  321. "Verify clipboard cleanup count incremented by 1, got %d",
  322. clipboard_cleanup_count - last_clipboard_cleanup_count);
  323. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_TEXT]);
  324. SDLTest_AssertCheck(
  325. !boolResult,
  326. "Verify has test text data, expected SDL_FALSE, got SDL_TRUE");
  327. boolResult = SDL_HasClipboardData(test_mime_types[TEST_MIME_TYPE_DATA]);
  328. SDLTest_AssertCheck(
  329. !boolResult,
  330. "Verify has test text data, expected SDL_FALSE, got SDL_TRUE");
  331. boolResult = SDL_HasClipboardData("test/invalid");
  332. SDLTest_AssertCheck(
  333. !boolResult,
  334. "Verify has test text data, expected SDL_FALSE, got SDL_TRUE");
  335. SDL_DelEventWatch(ClipboardEventWatch, NULL);
  336. return TEST_COMPLETED;
  337. }
  338. /**
  339. * End-to-end test of SDL_xyzClipboardText functions
  340. * \sa SDL_HasClipboardText
  341. * \sa SDL_GetClipboardText
  342. * \sa SDL_SetClipboardText
  343. */
  344. static int clipboard_testClipboardTextFunctions(void *arg)
  345. {
  346. char *textRef = SDLTest_RandomAsciiString();
  347. char *text = SDL_strdup(textRef);
  348. SDL_bool boolResult;
  349. int intResult;
  350. char *charResult;
  351. int last_clipboard_update_count;
  352. SDL_AddEventWatch(ClipboardEventWatch, NULL);
  353. /* Empty clipboard text */
  354. last_clipboard_update_count = clipboard_update_count;
  355. intResult = SDL_SetClipboardText(NULL);
  356. SDLTest_AssertCheck(
  357. intResult == 0,
  358. "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
  359. intResult);
  360. charResult = SDL_GetClipboardText();
  361. SDLTest_AssertCheck(
  362. charResult && SDL_strcmp(charResult, "") == 0,
  363. "Verify SDL_GetClipboardText returned \"\", got %s",
  364. charResult);
  365. SDL_free(charResult);
  366. boolResult = SDL_HasClipboardText();
  367. SDLTest_AssertCheck(
  368. boolResult == SDL_FALSE,
  369. "Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
  370. (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
  371. SDLTest_AssertCheck(
  372. clipboard_update_count == last_clipboard_update_count,
  373. "Verify clipboard update unchanged, got %d",
  374. clipboard_update_count - last_clipboard_update_count);
  375. /* Set clipboard text */
  376. last_clipboard_update_count = clipboard_update_count;
  377. intResult = SDL_SetClipboardText(text);
  378. SDLTest_AssertCheck(
  379. intResult == 0,
  380. "Verify result from SDL_SetClipboardText(%s), expected 0, got %i", text,
  381. intResult);
  382. SDLTest_AssertCheck(
  383. SDL_strcmp(textRef, text) == 0,
  384. "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
  385. textRef, text);
  386. boolResult = SDL_HasClipboardText();
  387. SDLTest_AssertCheck(
  388. boolResult == SDL_TRUE,
  389. "Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
  390. (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
  391. charResult = SDL_GetClipboardText();
  392. SDLTest_AssertCheck(
  393. charResult && SDL_strcmp(textRef, charResult) == 0,
  394. "Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
  395. textRef, charResult);
  396. SDL_free(charResult);
  397. SDLTest_AssertCheck(
  398. clipboard_update_count == last_clipboard_update_count + 1,
  399. "Verify clipboard update count incremented by 1, got %d",
  400. clipboard_update_count - last_clipboard_update_count);
  401. /* Reset clipboard text */
  402. intResult = SDL_SetClipboardText(NULL);
  403. SDLTest_AssertCheck(
  404. intResult == 0,
  405. "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
  406. intResult);
  407. /* Cleanup */
  408. SDL_free(textRef);
  409. SDL_free(text);
  410. SDL_DelEventWatch(ClipboardEventWatch, NULL);
  411. return TEST_COMPLETED;
  412. }
  413. /**
  414. * End-to-end test of SDL_xyzPrimarySelectionText functions
  415. * \sa SDL_HasPrimarySelectionText
  416. * \sa SDL_GetPrimarySelectionText
  417. * \sa SDL_SetPrimarySelectionText
  418. */
  419. static int clipboard_testPrimarySelectionTextFunctions(void *arg)
  420. {
  421. char *textRef = SDLTest_RandomAsciiString();
  422. char *text = SDL_strdup(textRef);
  423. SDL_bool boolResult;
  424. int intResult;
  425. char *charResult;
  426. int last_clipboard_update_count;
  427. SDL_AddEventWatch(ClipboardEventWatch, NULL);
  428. /* Empty primary selection */
  429. last_clipboard_update_count = clipboard_update_count;
  430. intResult = SDL_SetPrimarySelectionText(NULL);
  431. SDLTest_AssertCheck(
  432. intResult == 0,
  433. "Verify result from SDL_SetPrimarySelectionText(NULL), expected 0, got %i",
  434. intResult);
  435. charResult = SDL_GetPrimarySelectionText();
  436. SDLTest_AssertCheck(
  437. charResult && SDL_strcmp(charResult, "") == 0,
  438. "Verify SDL_GetPrimarySelectionText returned \"\", got %s",
  439. charResult);
  440. SDL_free(charResult);
  441. boolResult = SDL_HasPrimarySelectionText();
  442. SDLTest_AssertCheck(
  443. boolResult == SDL_FALSE,
  444. "Verify SDL_HasPrimarySelectionText returned SDL_FALSE, got %s",
  445. (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
  446. SDLTest_AssertCheck(
  447. clipboard_update_count == last_clipboard_update_count + 1,
  448. "Verify clipboard update count incremented by 1, got %d",
  449. clipboard_update_count - last_clipboard_update_count);
  450. /* Set primary selection */
  451. last_clipboard_update_count = clipboard_update_count;
  452. intResult = SDL_SetPrimarySelectionText(text);
  453. SDLTest_AssertCheck(
  454. intResult == 0,
  455. "Verify result from SDL_SetPrimarySelectionText(%s), expected 0, got %i", text,
  456. intResult);
  457. SDLTest_AssertCheck(
  458. SDL_strcmp(textRef, text) == 0,
  459. "Verify SDL_SetPrimarySelectionText did not modify input string, expected '%s', got '%s'",
  460. textRef, text);
  461. boolResult = SDL_HasPrimarySelectionText();
  462. SDLTest_AssertCheck(
  463. boolResult == SDL_TRUE,
  464. "Verify SDL_HasPrimarySelectionText returned SDL_TRUE, got %s",
  465. (boolResult) ? "SDL_TRUE" : "SDL_FALSE");
  466. charResult = SDL_GetPrimarySelectionText();
  467. SDLTest_AssertCheck(
  468. charResult && SDL_strcmp(textRef, charResult) == 0,
  469. "Verify SDL_GetPrimarySelectionText returned correct string, expected '%s', got '%s'",
  470. textRef, charResult);
  471. SDL_free(charResult);
  472. SDLTest_AssertCheck(
  473. clipboard_update_count == last_clipboard_update_count + 1,
  474. "Verify clipboard update count incremented by 1, got %d",
  475. clipboard_update_count - last_clipboard_update_count);
  476. /* Reset primary selection */
  477. intResult = SDL_SetPrimarySelectionText(NULL);
  478. SDLTest_AssertCheck(
  479. intResult == 0,
  480. "Verify result from SDL_SetPrimarySelectionText(NULL), expected 0, got %i",
  481. intResult);
  482. /* Cleanup */
  483. SDL_free(textRef);
  484. SDL_free(text);
  485. SDL_DelEventWatch(ClipboardEventWatch, NULL);
  486. return TEST_COMPLETED;
  487. }
  488. /* ================= Test References ================== */
  489. static const SDLTest_TestCaseReference clipboardTest1 = {
  490. (SDLTest_TestCaseFp)clipboard_testClipboardDataFunctions, "clipboard_testClipboardDataFunctions", "End-to-end test of SDL_xyzClipboardData functions", TEST_ENABLED
  491. };
  492. static const SDLTest_TestCaseReference clipboardTest2 = {
  493. (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED
  494. };
  495. static const SDLTest_TestCaseReference clipboardTest3 = {
  496. (SDLTest_TestCaseFp)clipboard_testPrimarySelectionTextFunctions, "clipboard_testPrimarySelectionTextFunctions", "End-to-end test of SDL_xyzPrimarySelectionText functions", TEST_ENABLED
  497. };
  498. /* Sequence of Clipboard test cases */
  499. static const SDLTest_TestCaseReference *clipboardTests[] = {
  500. &clipboardTest1, &clipboardTest2, &clipboardTest3, NULL
  501. };
  502. /* Clipboard test suite (global) */
  503. SDLTest_TestSuiteReference clipboardTestSuite = {
  504. "Clipboard",
  505. NULL,
  506. clipboardTests,
  507. NULL
  508. };