#=============================================================================================
# @TITLE			Checking forth window - Backup Wizard.
#
# @NUMBER			DBM3_BackupP_008_DeleteMedium
#
# @DESCRIPTION		Checking the delete window of a parallel backup medium.
#
# @EXP_RESULT		All controls will be displayed there will be one media in the lvwMedia -
# @					listview.
#
# @REQUIREMENTS		"Database Manager" is installed.
#=============================================================================================
static WizardOpen = 1;
#if change check for loops at the end of test
static list_array_before [] = {"TestBackupP_com","TestBackupP_comCopy"};
static list_array_before_ok = 1;
#if change check for loops at the end of test
static list_array_after [] = {"TestBackupP_com"};
static list_array_after_ok = 1;

static Testname = getvar("testname");
#=============================================================================================
# @STEP 1			Checking window and clicking 'New Parallel Medium'.
#=============================================================================================
if (win_exists("Database Manager Backup Wizard",0) == 0) {
	
	tl_step("Database Manager Backup Wizard - Window Check", "0", "Window still open. - TN: " & Testname);
#=============================================================================================
# @STEP 2			Delete TestBackupCopy --> Request --> No.
#=============================================================================================	
	set_window ("Database Manager Backup Wizard", 2);
	list_select_item ("lvwMedia", "TestBackupP_comCopy");
	toolbar_button_press ("msvb_lib_toolbar", "Delete");	

	set_window ("Confirm Medium Delete", 0);
	button_press ("No");
	
	wait(3);
#=============================================================================================
# @STEP 3			Checking entries in lvwMedia.
#=============================================================================================	
	#sort the lvwMedia list alphabetically
	set_window ("Database Manager Backup Wizard", 3);
	list_get_item("lvwMedia", 0, firstitem);
	while (firstitem != "TestBackupP_com")
	{
	obj_mouse_click ("msvb_lib_header", 1, 1, LEFT);
	list_get_item("lvwMedia", 0, firstitem);
	}
	
	#compare the lvwMedia list items with the one stored in the array
	for (i = 0;i < 2;i++) {
		
		set_window ("Database Manager Backup Wizard", 2);
		list_get_item("lvwMedia", i, Listitem);
		
		if (Listitem != list_array_before [i]) {
			
			list_array_before_ok = 0;
			break;
		}
	}
	
	if (list_array_before_ok == 0) {
		
		tl_step ("Database Manager Backup Wizard - Delete", "1", "Not all listitems are correct. - TN: " & Testname);
		tl_step ("Database Manager Backup Wizard - Delete", "1", "Last item: " & Listitem & " expected: " & list_array [i] & ". - TN: " & Testname);
	} else {
		
		tl_step ("Database Manager Backup Wizard - Delete", "0", "All listitems are correct - rename correct. - TN: " & Testname);
	}
#=============================================================================================
# @STEP 4			Delete TestBackupCopy --> Request --> Yes.
#=============================================================================================	
	set_window ("Database Manager Backup Wizard", 2);
	list_select_item ("lvwMedia", "TestBackupP_comCopy");
	toolbar_button_press ("msvb_lib_toolbar", "Delete");

	set_window ("Confirm Medium Delete", 0);
	button_press ("Yes");
	
	wait(3);
#=============================================================================================
# @STEP 5			Checking entries in lvwMedia.
#=============================================================================================	
	#sort the lvwMedia list alphabetically
	set_window ("Database Manager Backup Wizard", 3);
	list_get_item("lvwMedia", 0, firstitem);
	while (firstitem != "TestBackupP_com")
	{
	obj_mouse_click ("msvb_lib_header", 1, 1, LEFT);
	list_get_item("lvwMedia", 0, firstitem);
	}
	
	#compare the lvwMedia list items with the one stored in the array
	for (i = 0;i < 1;i++) {
		
		set_window ("Database Manager Backup Wizard", 2);
		list_get_item("lvwMedia", i, Listitem);
		
		if (Listitem != list_array_after [i]) {
			
			list_array_after_ok = 0;
			break;
		}
	}
	
	if (list_array_after_ok == 0) {
		tl_step ("Database Manager Backup Wizard - Delete", "1", "Not all listitems are correct. - TN: " & Testname);
		tl_step ("Database Manager Backup Wizard - Delete", "1", "Last item: " & Listitem & " expected: " & list_array [i] & ". - TN: " & Testname);
	} else {
		tl_step ("Database Manager Backup Wizard - Delete", "0", "All listitems are correct - rename correct. - TN: " & Testname);
	}
#=============================================================================================
# @STEP 5			Clicking 'Next'.
#=============================================================================================	
	set_window ("Database Manager Backup Wizard", 2);
	button_press ("Next >");
} else {
	
	tl_step("Database Manager Backup Wizard - Window Check", "1", "Window not open. - TN: " & Testname);
	WizardOpen = 0;
}
