Changeset aefdccd in mainline for uspace/lib/ui/test/filelist.c
- Timestamp:
- 2025-10-20T06:14:54Z (7 weeks ago)
- Parents:
- adbd7e1 (diff), 3e41cc4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2025-10-20 06:14:54)
- git-committer:
- GitHub <noreply@…> (2025-10-20 06:14:54)
- File:
-
- 1 edited
-
uspace/lib/ui/test/filelist.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/filelist.c
radbd7e1 raefdccd 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 665 665 } 666 666 667 /** ui_file_list_refresh() */ 668 PCUT_TEST(refresh) 669 { 670 ui_t *ui; 671 ui_window_t *window; 672 ui_wnd_params_t params; 673 ui_file_list_t *flist; 674 ui_file_list_entry_t *entry; 675 char buf[L_tmpnam]; 676 char *fname; 677 char *p; 678 errno_t rc; 679 FILE *f; 680 int rv; 681 682 /* Create name for temporary directory */ 683 p = tmpnam(buf); 684 PCUT_ASSERT_NOT_NULL(p); 685 686 /* Create temporary directory */ 687 rc = vfs_link_path(p, KIND_DIRECTORY, NULL); 688 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 689 690 rv = asprintf(&fname, "%s/%s", p, "a"); 691 PCUT_ASSERT_TRUE(rv >= 0); 692 693 f = fopen(fname, "wb"); 694 PCUT_ASSERT_NOT_NULL(f); 695 696 rv = fprintf(f, "X"); 697 PCUT_ASSERT_TRUE(rv >= 0); 698 699 rv = fclose(f); 700 PCUT_ASSERT_INT_EQUALS(0, rv); 701 702 rc = ui_create_disp(NULL, &ui); 703 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 704 705 ui_wnd_params_init(¶ms); 706 params.caption = "Test"; 707 708 rc = ui_window_create(ui, ¶ms, &window); 709 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 710 711 rc = ui_file_list_create(window, true, &flist); 712 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 713 714 rc = ui_file_list_read_dir(flist, p); 715 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 716 717 PCUT_ASSERT_INT_EQUALS(2, ui_list_entries_cnt(flist->list)); 718 719 entry = ui_file_list_first(flist); 720 PCUT_ASSERT_NOT_NULL(entry); 721 PCUT_ASSERT_STR_EQUALS("..", entry->name); 722 723 entry = ui_file_list_next(entry); 724 PCUT_ASSERT_NOT_NULL(entry); 725 PCUT_ASSERT_STR_EQUALS("a", entry->name); 726 PCUT_ASSERT_INT_EQUALS(1, entry->size); 727 728 rv = remove(fname); 729 PCUT_ASSERT_INT_EQUALS(0, rv); 730 free(fname); 731 732 rv = asprintf(&fname, "%s/%s", p, "b"); 733 PCUT_ASSERT_TRUE(rv >= 0); 734 735 f = fopen(fname, "wb"); 736 PCUT_ASSERT_NOT_NULL(f); 737 738 rv = fprintf(f, "X"); 739 PCUT_ASSERT_TRUE(rv >= 0); 740 741 rv = fclose(f); 742 PCUT_ASSERT_INT_EQUALS(0, rv); 743 744 rc = ui_file_list_refresh(flist); 745 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 746 747 entry = ui_file_list_first(flist); 748 PCUT_ASSERT_NOT_NULL(entry); 749 PCUT_ASSERT_STR_EQUALS("..", entry->name); 750 751 entry = ui_file_list_next(entry); 752 PCUT_ASSERT_NOT_NULL(entry); 753 PCUT_ASSERT_STR_EQUALS("b", entry->name); 754 PCUT_ASSERT_INT_EQUALS(1, entry->size); 755 756 rv = remove(fname); 757 PCUT_ASSERT_INT_EQUALS(0, rv); 758 free(fname); 759 760 rv = remove(p); 761 PCUT_ASSERT_INT_EQUALS(0, rv); 762 763 ui_file_list_destroy(flist); 764 765 ui_window_destroy(window); 766 ui_destroy(ui); 767 } 768 667 769 /** ui_file_list_list_compare compares two file list entries */ 668 770 PCUT_TEST(list_compare)
Note:
See TracChangeset
for help on using the changeset viewer.
