#=============================================================================================
# @TITLE					Configuration - Backup Media - check table
#
# @NUMBER					WDBM_FKT_02050
#
# @DESCRIPTION		The table for 'Backup Media' will be checked and the links as well.
#
# @EXP_RESULT			All links work fine and the contents are as expected.
#
# @REQUIREMENTS		Test: WDBM_FKT_01000; WDBM_FKT_00100; WDBM_FKT_01010;
#=============================================================================================

public function trim (in str) {
	if (substr(str, 1, 1) == " ") {

		str = trim(substr(str, 2));
	}
	if (substr(str, length(str)) == " ") {
		str = trim(substr(str, 1, length(str)-1));
	}
	return (str);
} 

static table_single_ok = 1;
static table_single [] = {"Name","Location","Device Type","Backup Type","Modified","Size (Pages)","Overwrite"};

static table_parallel_ok = 1;
static table_parallel [] = {"Name","Device Type","Backup Type","Modified","Overwrite"};
#=============================================================================================
# @STEP 1			Clicking the link for Backup Media - Configuration.
#=============================================================================================
set_window(menu_window, 1);

if (version == "7.3.00") {
	web_link_click("Backup Media");
}
if (version == "7.4.03" ||
	version == "7.5.00" ||
	version == "7.5.01" ||
	version == "7.6.00") {
	web_link_click("Backup Medium");
}

set_window (work_window, 1);

if (new_interface == "1") {
	web_obj_get_text ("Information - CACHES - DB73", "#1", "#1", cell_value_1, "", "", 1);
} else {
	tbl_get_cell_data ("Database/Servername", "#1", "#1", cell_value_1);
}

if ((cell_value_1 == "Backup Media - " & database && version == "7.3.00") ||
	(cell_value_1 == "Configuration - Backup Medium" && (version == "7.4.03" || version == "7.5.00" || version == "7.5.01" || version == "7.6.00"))) {
	
	tl_step("Title of window - " & cell_value,"0","is correct");
} else {
	tl_step("Title of window - " & cell_value,"1","is incorrect");
}
#=============================================================================================
# @STEP 2			Checking table headline - single.
#=============================================================================================
set_window(work_window, 1);

for (i=1;i<8;i++) {
	
	if (new_interface == "1") {
		web_obj_get_text ("1x1_2", "#2", "#"&i, cell_value_2, "", "", 1);
	} else {
		tbl_get_cell_data ("Owner", "#2", "#"&i, cell_value_2);
	}
	
	if (trim(cell_value_2) != table_single [i-1]) {
		table_single_ok = 0;
		break;
	}
}

if (table_single_ok == 0) {
	tl_step("Headline of table","1","incorrect");
} else {
	tl_step("Headline of table","0","correct");
}
#=============================================================================================
# @STEP 3			Checking the links.
#=============================================================================================
if (obj_exists("log",0) == 0) {

	tl_step("Link for log backup","0","exists");
	
	set_window (work_window, 1);
	web_link_click("log");
	
	set_window (work_window, 1);
	if (new_interface == "1") {
		web_obj_get_text ("Information - CACHES - DB73", "#1", "#1", cell_value_3, "", "", 1);
	} else {
		tbl_get_cell_data ("Backup Media - DB73", "#1", "#1", cell_value_3);
	}
	
	if ((cell_value_3 == "Backup Medium - " & database & " - log" && version == "7.3.00") ||
		(cell_value_3 == "Configuration - Backup Medium - log" && (version == "7.4.03" || version == "7.5.00" || version == "7.5.01" || version == "7.6.00"))) {
	
		tl_step("Link let the right window appear","0","correct");
		set_window (work_window, 1);
		web_link_click("Cancel");
	} else {
		tl_step("Link do not let the right window appear","1","incorrect");
		set_window (menu_window, 2);
		web_link_click("Backup Media");
	}
}

if (obj_exists("medium",0) == 0) {

	tl_step("Link for data backup","0","exists");
	
	set_window (work_window, 1);
	web_link_click("medium");
	
	set_window (work_window, 1);
	if (new_interface == "1") {
		web_obj_get_text ("Information - CACHES - DB73", "#1", "#1", cell_value_4, "", "", 1);
	} else {
		tbl_get_cell_data ("Database/Servername", "#1", "#1", cell_value_4);
	}

	if ((cell_value_4 == "Backup Medium - medium" && version == "7.3.00") ||
		(cell_value_4 == "Configuration - Backup Medium - medium" && (version == "7.4.03" || version == "7.5.00" || version == "7.5.01" || version == "7.6.00"))) {
		
		tl_step("Link let the right window appear","0","correct");
		set_window (work_window, 1);
		web_link_click("Cancel");
	} else {
		tl_step("Link do not let the right window appear","1","incorrect");
		set_window (menu_window, 2);
		
		if (version == "7.3.00") {		
			web_link_click("Backup Media");
		}
		if (version == "7.4.03" ||
			version == "7.5.00" ||
			version == "7.5.01" ||
			version == "7.6.00") {
			web_link_click("Backup Medium");
		}
	}
}
#=============================================================================================
# @STEP 4			Checking table headline - parallel.
#=============================================================================================
set_window(work_window, 1);
web_link_click("Parallel");
set_window (work_window, 0);

for (i=1;i<6;i++) {

	if (new_interface == "1") {
		web_obj_get_text ("1x1_2", "#2", "#"&i, cell_value_4, "", "", 1);
	} else {
		tbl_get_cell_data ("Owner", "#2", "#"&i, cell_value_4);
	}
	
	if (trim(cell_value_4) != table_parallel [i-1]) {
		table_parallel_ok = 0;
		break;
	}
}

if(table_parallel_ok == 0) {
	tl_step("Headline of table","1","incorrect");
} else {
	tl_step("Headline of table","0","correct");
}


