comparison src/testing.c @ 27470:f0096e5b3df9 v8.2.4263

patch 8.2.4263: no test for the GUI find/replace dialog Commit: https://github.com/vim/vim/commit/ec3637cbaf23730b6efe5e5c0047e23adc82160b Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Jan 30 18:01:24 2022 +0000 patch 8.2.4263: no test for the GUI find/replace dialog Problem: No test for the GUI find/replace dialog. Solution: Add a test function and a test. (Yegappan Lakshmanan, closes #9662)
author Bram Moolenaar <Bram@vim.org>
date Sun, 30 Jan 2022 19:15:03 +0100
parents b43f6c879d52
children 7480a2e2ca0f
comparison
equal deleted inserted replaced
27469:278bf9ba58b8 27470:f0096e5b3df9
1317 1317
1318 # ifdef FEAT_GUI 1318 # ifdef FEAT_GUI
1319 static int 1319 static int
1320 test_gui_drop_files(dict_T *args UNUSED) 1320 test_gui_drop_files(dict_T *args UNUSED)
1321 { 1321 {
1322 #if defined(HAVE_DROP_FILE) 1322 # if defined(HAVE_DROP_FILE)
1323 int row; 1323 int row;
1324 int col; 1324 int col;
1325 int_u mods; 1325 int_u mods;
1326 char_u **fnames; 1326 char_u **fnames;
1327 int count = 0; 1327 int count = 0;
1333 || dict_find(args, (char_u *)"row", -1) == NULL 1333 || dict_find(args, (char_u *)"row", -1) == NULL
1334 || dict_find(args, (char_u *)"col", -1) == NULL 1334 || dict_find(args, (char_u *)"col", -1) == NULL
1335 || dict_find(args, (char_u *)"modifiers", -1) == NULL) 1335 || dict_find(args, (char_u *)"modifiers", -1) == NULL)
1336 return FALSE; 1336 return FALSE;
1337 1337
1338 if (dict_get_tv(args, (char_u *)"files", &t) == FAIL) 1338 (void)dict_get_tv(args, (char_u *)"files", &t);
1339 return FALSE;
1340 row = (int)dict_get_number(args, (char_u *)"row"); 1339 row = (int)dict_get_number(args, (char_u *)"row");
1341 col = (int)dict_get_number(args, (char_u *)"col"); 1340 col = (int)dict_get_number(args, (char_u *)"col");
1342 mods = (int)dict_get_number(args, (char_u *)"modifiers"); 1341 mods = (int)dict_get_number(args, (char_u *)"modifiers");
1343 1342
1343 if (t.v_type != VAR_LIST || list_len(t.vval.v_list) == 0)
1344 return FALSE;
1345
1344 l = t.vval.v_list; 1346 l = t.vval.v_list;
1345 if (list_len(l) == 0)
1346 return FALSE;
1347
1348 fnames = ALLOC_MULT(char_u *, list_len(l)); 1347 fnames = ALLOC_MULT(char_u *, list_len(l));
1349 if (fnames == NULL) 1348 if (fnames == NULL)
1350 return FALSE; 1349 return FALSE;
1351 1350
1352 FOR_ALL_LIST_ITEMS(l, li) 1351 FOR_ALL_LIST_ITEMS(l, li)
1353 { 1352 {
1354 // ignore non-string items 1353 // ignore non-string items
1355 if (li->li_tv.v_type != VAR_STRING) 1354 if (li->li_tv.v_type != VAR_STRING
1355 || li->li_tv.vval.v_string == NULL)
1356 continue; 1356 continue;
1357 1357
1358 fnames[count] = vim_strsave(li->li_tv.vval.v_string); 1358 fnames[count] = vim_strsave(li->li_tv.vval.v_string);
1359 if (fnames[count] == NULL) 1359 if (fnames[count] == NULL)
1360 { 1360 {
1368 1368
1369 if (count > 0) 1369 if (count > 0)
1370 gui_handle_drop(TEXT_X(col - 1), TEXT_Y(row - 1), mods, fnames, count); 1370 gui_handle_drop(TEXT_X(col - 1), TEXT_Y(row - 1), mods, fnames, count);
1371 else 1371 else
1372 vim_free(fnames); 1372 vim_free(fnames);
1373 # endif 1373 # endif
1374 1374
1375 return TRUE; 1375 return TRUE;
1376 } 1376 }
1377 1377
1378 static int 1378 static int
1379 test_gui_mouse_event(dict_T *args UNUSED) 1379 test_gui_find_repl(dict_T *args)
1380 {
1381 int flags;
1382 char_u *find_text;
1383 char_u *repl_text;
1384 int forward;
1385 int retval;
1386
1387 if (dict_find(args, (char_u *)"find_text", -1) == NULL
1388 || dict_find(args, (char_u *)"repl_text", -1) == NULL
1389 || dict_find(args, (char_u *)"flags", -1) == NULL
1390 || dict_find(args, (char_u *)"forward", -1) == NULL)
1391 return FALSE;
1392
1393 find_text = dict_get_string(args, (char_u *)"find_text", TRUE);
1394 repl_text = dict_get_string(args, (char_u *)"repl_text", TRUE);
1395 flags = (int)dict_get_number(args, (char_u *)"flags");
1396 forward = (int)dict_get_number(args, (char_u *)"forward");
1397
1398 retval = gui_do_findrepl(flags, find_text, repl_text, forward);
1399 vim_free(find_text);
1400 vim_free(repl_text);
1401
1402 return retval;
1403 }
1404
1405 static int
1406 test_gui_mouse_event(dict_T *args)
1380 { 1407 {
1381 int button; 1408 int button;
1382 int row; 1409 int row;
1383 int col; 1410 int col;
1384 int repeated_click; 1411 int repeated_click;
1403 } 1430 }
1404 1431
1405 static int 1432 static int
1406 test_gui_tabline_event(dict_T *args UNUSED) 1433 test_gui_tabline_event(dict_T *args UNUSED)
1407 { 1434 {
1408 # ifdef FEAT_GUI_TABLINE 1435 # ifdef FEAT_GUI_TABLINE
1409 int tabnr; 1436 int tabnr;
1410 1437
1411 if (dict_find(args, (char_u *)"tabnr", -1) == NULL) 1438 if (dict_find(args, (char_u *)"tabnr", -1) == NULL)
1412 return FALSE; 1439 return FALSE;
1413 1440
1414 tabnr = (int)dict_get_number(args, (char_u *)"tabnr"); 1441 tabnr = (int)dict_get_number(args, (char_u *)"tabnr");
1415 1442
1416 return send_tabline_event(tabnr); 1443 return send_tabline_event(tabnr);
1417 # else 1444 # else
1418 return FALSE; 1445 return FALSE;
1419 # endif 1446 # endif
1420 } 1447 }
1421 1448
1422 static int 1449 static int
1423 test_gui_tabmenu_event(dict_T *args UNUSED) 1450 test_gui_tabmenu_event(dict_T *args UNUSED)
1424 { 1451 {
1425 # ifdef FEAT_GUI_TABLINE 1452 # ifdef FEAT_GUI_TABLINE
1426 int tabnr; 1453 int tabnr;
1427 int item; 1454 int item;
1428 1455
1429 if (dict_find(args, (char_u *)"tabnr", -1) == NULL 1456 if (dict_find(args, (char_u *)"tabnr", -1) == NULL
1430 || dict_find(args, (char_u *)"item", -1) == NULL) 1457 || dict_find(args, (char_u *)"item", -1) == NULL)
1432 1459
1433 tabnr = (int)dict_get_number(args, (char_u *)"tabnr"); 1460 tabnr = (int)dict_get_number(args, (char_u *)"tabnr");
1434 item = (int)dict_get_number(args, (char_u *)"item"); 1461 item = (int)dict_get_number(args, (char_u *)"item");
1435 1462
1436 send_tabline_menu_event(tabnr, item); 1463 send_tabline_menu_event(tabnr, item);
1437 # endif 1464 # endif
1438 return TRUE; 1465 return TRUE;
1439 } 1466 }
1440 # endif 1467 # endif
1441 1468
1442 void 1469 void
1454 return; 1481 return;
1455 1482
1456 event = tv_get_string(&argvars[0]); 1483 event = tv_get_string(&argvars[0]);
1457 if (STRCMP(event, "dropfiles") == 0) 1484 if (STRCMP(event, "dropfiles") == 0)
1458 rettv->vval.v_number = test_gui_drop_files(argvars[1].vval.v_dict); 1485 rettv->vval.v_number = test_gui_drop_files(argvars[1].vval.v_dict);
1486 else if (STRCMP(event, "findrepl") == 0)
1487 rettv->vval.v_number = test_gui_find_repl(argvars[1].vval.v_dict);
1459 else if (STRCMP(event, "mouse") == 0) 1488 else if (STRCMP(event, "mouse") == 0)
1460 rettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict); 1489 rettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict);
1461 else if (STRCMP(event, "tabline") == 0) 1490 else if (STRCMP(event, "tabline") == 0)
1462 rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict); 1491 rettv->vval.v_number = test_gui_tabline_event(argvars[1].vval.v_dict);
1463 else if (STRCMP(event, "tabmenu") == 0) 1492 else if (STRCMP(event, "tabmenu") == 0)