/* *INDENT-OFF* */ END_PARAMETRIZED_TEST /* *INDENT-ON* */ /* --------------------------------------------------------------------------------------------- */ /* @Test */ /* *INDENT-OFF* */ START_TEST (the_file_is_remote_but_empty) /* *INDENT-ON* */ { /* given */ vfs_path_t *filename_vpath; filename_vpath = NULL; vfs_file_is_local__return_value = FALSE; /* when */ execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath); /* then */ mctest_assert_str_eq (do_execute__lc_shell__captured, NULL); mctest_assert_str_eq (do_execute__command__captured, NULL); mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 2); mctest_assert_int_eq (vfs_path_equal (g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), vfs_get_raw_current_dir ()), TRUE); fail_unless (g_ptr_array_index (vfs_file_is_local__vpath__captured, 1) == NULL, "\nParameter for second call to vfs_file_is_local() should be NULL!"); fail_unless (mc_getlocalcopy__pathname_vpath__captured == NULL, "\nFunction mc_getlocalcopy() shouldn't be called!"); vfs_path_free (filename_vpath); }
/* *INDENT-OFF* */ START_PARAMETRIZED_TEST (the_file_is_local, the_file_is_local_ds) /* *INDENT-ON* */ { /* given */ vfs_path_t *filename_vpath; filename_vpath = vfs_path_from_str (data->input_path); vfs_file_is_local__return_value = TRUE; /* when */ execute_with_vfs_arg ("cmd_for_local_file", filename_vpath); /* then */ mctest_assert_str_eq (do_execute__lc_shell__captured, "cmd_for_local_file"); mctest_assert_str_eq (do_execute__command__captured, data->input_path); mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1); { const vfs_path_t *tmp_vpath; tmp_vpath = (data->input_path == NULL) ? vfs_get_raw_current_dir () : filename_vpath; mctest_assert_int_eq (vfs_path_equal (g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), tmp_vpath), TRUE); } mctest_assert_int_eq (do_execute__flags__captured, EXECUTE_INTERNAL); fail_unless (mc_getlocalcopy__pathname_vpath__captured == NULL, "\nFunction mc_getlocalcopy() shouldn't be called!"); vfs_path_free (filename_vpath); }
/* *INDENT-OFF* */ END_TEST /* *INDENT-ON* */ /* --------------------------------------------------------------------------------------------- */ /* @Test */ /* *INDENT-OFF* */ START_TEST (the_file_is_remote_fail_to_create_local_copy) /* *INDENT-ON* */ { /* given */ vfs_path_t *filename_vpath; filename_vpath = vfs_path_from_str ("/ftp://some.host/editme.txt"); vfs_file_is_local__return_value = FALSE; mc_getlocalcopy__return_value = NULL; /* when */ execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath); /* then */ mctest_assert_str_eq (do_execute__lc_shell__captured, NULL); mctest_assert_str_eq (do_execute__command__captured, NULL); mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1); mctest_assert_int_eq (vfs_path_equal (g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), filename_vpath), TRUE); mctest_assert_int_eq (vfs_path_equal (mc_getlocalcopy__pathname_vpath__captured, filename_vpath), TRUE); mctest_assert_str_eq (message_title__captured, _("Error")); mctest_assert_str_eq (message_text__captured, _("Cannot fetch a local copy of /ftp://some.host/editme.txt")); vfs_path_free (filename_vpath); }
void reread_cmd (void) { panel_update_flags_t flag = UP_ONLY_CURRENT; if (get_current_type () == view_listing && get_other_type () == view_listing && vfs_path_equal (current_panel->cwd_vpath, other_panel->cwd_vpath)) flag = UP_OPTIMIZE; update_panels (UP_RELOAD | flag, UP_KEEPSEL); repaint_screen (); }
/* *INDENT-OFF* */ END_TEST /* *INDENT-ON* */ /* --------------------------------------------------------------------------------------------- */ /* @Test */ /* *INDENT-OFF* */ START_TEST (the_file_is_remote) /* *INDENT-ON* */ { /* given */ vfs_path_t *filename_vpath, *local_vpath, *local_vpath_should_be_freeing; filename_vpath = vfs_path_from_str ("/ftp://some.host/editme.txt"); local_vpath = vfs_path_from_str ("/tmp/blabla-editme.txt"); local_vpath_should_be_freeing = vfs_path_clone (local_vpath); vfs_file_is_local__return_value = FALSE; mc_getlocalcopy__return_value = local_vpath_should_be_freeing; /* when */ execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath); /* then */ mctest_assert_str_eq (do_execute__lc_shell__captured, "cmd_for_remote_file"); mctest_assert_str_eq (do_execute__command__captured, "/tmp/blabla-editme.txt"); mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1); mctest_assert_int_eq (vfs_path_equal (g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), filename_vpath), TRUE); mctest_assert_int_eq (vfs_path_equal (mc_getlocalcopy__pathname_vpath__captured, filename_vpath), TRUE); mctest_assert_int_eq (mc_stat__vpath__captured->len, 2); mctest_assert_int_eq (vfs_path_equal (g_ptr_array_index (mc_stat__vpath__captured, 0), local_vpath), TRUE); mctest_assert_int_eq (vfs_path_equal (g_ptr_array_index (mc_stat__vpath__captured, 0), g_ptr_array_index (mc_stat__vpath__captured, 1)), TRUE); mctest_assert_int_eq (vfs_path_equal (mc_ungetlocalcopy__pathname_vpath__captured, filename_vpath), TRUE); mctest_assert_int_eq (vfs_path_equal (mc_ungetlocalcopy__local_vpath__captured, local_vpath), TRUE); vfs_path_free (filename_vpath); vfs_path_free (local_vpath); }
/* *INDENT-OFF* */ START_PARAMETRIZED_TEST (test_path_equal, test_path_equal_ds) /* *INDENT-ON* */ { /* given */ vfs_path_t *vpath1, *vpath2; gboolean actual_result; vpath1 = vfs_path_from_str (data->input_path1); vpath2 = vfs_path_from_str (data->input_path2); /* when */ actual_result = vfs_path_equal (vpath1, vpath2); /* then */ mctest_assert_int_eq (actual_result, data->expected_result); vfs_path_free (vpath1); vfs_path_free (vpath2); }
static void show_tree (WTree * tree) { Widget *w = WIDGET (tree); WDialog *h = w->owner; tree_entry *current; int i, j, topsublevel; int x = 0, y = 0; int tree_lines, tree_cols; /* Initialize */ tree_lines = tlines (tree); tree_cols = w->cols; widget_move (w, y, x); if (tree->is_panel) { tree_cols -= 2; x = y = 1; } g_free (tree->tree_shown); tree->tree_shown = g_new0 (tree_entry *, tree_lines); if (tree->store->tree_first) topsublevel = tree->store->tree_first->sublevel; else topsublevel = 0; if (!tree->selected_ptr) { tree->selected_ptr = tree->store->tree_first; tree->topdiff = 0; } current = tree->selected_ptr; /* Calculate the directory which is to be shown on the topmost line */ if (!tree_navigation_flag) current = back_ptr (current, &tree->topdiff); else { i = 0; while (current->prev && i < tree->topdiff) { current = current->prev; if (current->sublevel < tree->selected_ptr->sublevel) { if (vfs_path_equal (current->name, tree->selected_ptr->name)) i++; } else if (current->sublevel == tree->selected_ptr->sublevel) { const char *cname; cname = vfs_path_as_str (current->name); for (j = strlen (cname) - 1; !IS_PATH_SEP (cname[j]); j--) ; if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) i++; } else if (current->sublevel == tree->selected_ptr->sublevel + 1) { j = vfs_path_len (tree->selected_ptr->name); if (j > 1 && vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) i++; } } tree->topdiff = i; } /* Loop for every line */ for (i = 0; i < tree_lines; i++) { tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h)); /* Move to the beginning of the line */ tty_draw_hline (w->y + y + i, w->x + x, ' ', tree_cols); if (current == NULL) continue; if (tree->is_panel) tty_setcolor (widget_get_state (w, WST_FOCUSED) && current == tree->selected_ptr ? SELECTED_COLOR : NORMAL_COLOR); else tty_setcolor (current == tree->selected_ptr ? TREE_CURRENTC (h) : TREE_NORMALC (h)); tree->tree_shown[i] = current; if (current->sublevel == topsublevel) /* Show full name */ tty_print_string (str_fit_to_term (vfs_path_as_str (current->name), tree_cols + (tree->is_panel ? 0 : 1), J_LEFT_FIT)); else { /* Sub level directory */ tty_set_alt_charset (TRUE); /* Output branch parts */ for (j = 0; j < current->sublevel - topsublevel - 1; j++) { if (tree_cols - 8 - 3 * j < 9) break; tty_print_char (' '); if (current->submask & (1 << (j + topsublevel + 1))) tty_print_char (ACS_VLINE); else tty_print_char (' '); tty_print_char (' '); } tty_print_char (' '); j++; if (!current->next || !(current->next->submask & (1 << current->sublevel))) tty_print_char (ACS_LLCORNER); else tty_print_char (ACS_LTEE); tty_print_char (ACS_HLINE); tty_set_alt_charset (FALSE); /* Show sub-name */ tty_print_char (' '); tty_print_string (str_fit_to_term (current->subname, tree_cols - x - 3 * j, J_LEFT_FIT)); } /* Calculate the next value for current */ current = current->next; if (tree_navigation_flag) { while (current != NULL) { if (current->sublevel < tree->selected_ptr->sublevel) { if (vfs_path_equal_len (current->name, tree->selected_ptr->name, vfs_path_len (current->name))) break; } else if (current->sublevel == tree->selected_ptr->sublevel) { const char *cname; cname = vfs_path_as_str (current->name); for (j = strlen (cname) - 1; !IS_PATH_SEP (cname[j]); j--) ; if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j)) break; } else if (current->sublevel == tree->selected_ptr->sublevel + 1 && vfs_path_len (tree->selected_ptr->name) > 1) { if (vfs_path_equal_len (current->name, tree->selected_ptr->name, vfs_path_len (tree->selected_ptr->name))) break; } current = current->next; } } } tree_show_mini_info (tree, tree_lines, tree_cols); }