testautomation_clipboard.c 21 KB

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