#=============================================================================================
# @TITLE			VERSIONS - check table
#
# @NUMBER			WDBM_FKT_02007
#
# @DESCRIPTION		Clicking the "Versions" -link and checking the shown VERSIONS
# @					table.
#
# @EXP_RESULT		The Versions table has shown up and the headline and the first row will be
# @					checked.
#
# @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 VERSIONS_headline_ok = 1;
static VERSIONS_first_row_ok = 1;
static VERSIONS_headline_ok_1 = 1;
static VERSIONS_first_row_ok_1 = 1;

static VERSIONS_headline [] = {"Name","Value"};
static VERSIONS_first_row []= {"Kernel","Runtime Environment"};   
#=============================================================================================
# @STEP 1			Checking backup window.
#=============================================================================================
web_sync(100);
set_window (menu_window, 2);
web_link_click("Versions");
wait(5);
set_window(work_window, 1);

static tablename;
if (new_interface == "1") {
	tablename = "Information - CACHES - DB73";
} else {
	tablename = "1x1";
}
if (obj_exists(tablename,0) == 0) {	
	tl_step("VERSION","0","has shown up correctly");
} else {
	tl_step("VERSION","1","has not shown up correctly");
}

#=============================================================================================
# @STEP 2			Checking table content.
#=============================================================================================
set_window(work_window, 1);
web_obj_get_text("Information - CACHES - DB73","#1","#1",cell_value_1,"","",1);

if (trim(cell_value_1) == "Information - Versions") {
	
	tl_step("Table index - VERSIONS","0","correct");
	
	set_window(work_window, 1);
			
	tbl_get_rows_count(tablename,rows_count);
	tbl_get_cols_count(tablename,cols_count);
	
	for (i=1;i<(cols_count);i++) {
		
		set_window(work_window, 1);
		if (new_interface == "1") {
			web_obj_get_text ("Database Users", "#1", "#"&i, cell_value_2, "", "", 1);
		} else {
			tbl_get_cell_data ("1x1", "#1", "#"&i, cell_value_2);
		}
			
		if (trim(cell_value_2) != VERSIONS_headline[i-1]) {
			VERSIONS_headline_ok = 0;
			break;
		}
	}
	
	if (VERSIONS_headline_ok == 0) {
		tl_step("headline of caches table","1","incorrect");
	} else {
		tl_step("headline of caches table","0","correct");
	}
	
	for (i=1;i<(rows_count);i++) {
		
		set_window(work_window, 1);
		if (new_interface == "1") {
			web_obj_get_text ("Database Users", "#"&(i+1), "#1", cell_value_3, "", "", 1);
		} else {
			tbl_get_cell_data ("1x1", "#"&(i+1), "#1", cell_value_3);
		}
		
		if (version == "7.3.00") {
    		if (trim(cell_value_3) != VERSIONS_first_row[i-1]) {
    			VERSIONS_first_row_ok = 0;
    			break;
    		}
		}
		if (version == "7.4.03" ||
			version == "7.5.00" ||
			version == "7.5.01" ||
			version == "7.6.00") {
			
    		if (trim(cell_value_3) != VERSIONS_first_row[i-1]) {
    			VERSIONS_first_row_ok = 0;
    			break;
			}
		}
	}	
	
	if (VERSIONS_first_row_ok == 0) {
		tl_step("type row content","1","incorrect");
	} else {
		tl_step("type row content","0","correct");
	}
#=============================================================================================
# @STEP 3			Checking the refresh button.
#=============================================================================================
	set_window (work_window, 1);
	if (new_interface == "1") {
		web_image_click("1x1.gif", 7, 9);
	} else {
		web_image_click("refresh", 9, 4);
	}
	wait(5);
	set_window(work_window, 1);
	web_obj_get_text("Information - CACHES - DB73","#1","#1",cell_value_4,"","",1);

	if (trim(cell_value_4) == "Information - Versions") {

		tl_step("Table index - VERSIONS - after refresh","0","correct");
	
		set_window(work_window, 1);
				
		tbl_get_rows_count(tablename,rows_count);
		tbl_get_cols_count(tablename,cols_count);
		
		for (i=1;i<(cols_count);i++) {
			
			set_window(work_window, 1);
			if (new_interface == "1") {
				web_obj_get_text ("Database Users", "#1", "#"&i, cell_value_2, "", "", 1);
			} else {
				tbl_get_cell_data ("1x1", "#1", "#"&i, cell_value_2);
			}
				
			if (trim(cell_value_2) != VERSIONS_headline[i-1]) {
				VERSIONS_headline_ok = 0;
				break;
			}
		}
		
		if (VERSIONS_headline_ok == 0) {
			tl_step("headline of caches table - after refresh","1","incorrect");
		} else {
			tl_step("headline of caches table - after refresh","0","correct");
		}
		
		for (i=1;i<(rows_count);i++) {
			
			set_window(work_window, 1);
			if (new_interface == "1") {
				web_obj_get_text ("Database Users", "#"&(i+1), "#1", cell_value_3, "", "", 1);
			} else {
				tbl_get_cell_data ("1x1", "#"&(i+1), "#1", cell_value_3);
			}
			
			if (version == "7.3.00") {
	    		if (trim(cell_value_3) != VERSIONS_first_row[i-1]) {
	    			VERSIONS_first_row_ok = 0;
	    			break;
	    		}
			}
			if (version == "7.4.03" ||
				version == "7.5.00" ||
				version == "7.5.01" ||
				version == "7.6.00") {
				
	    		if (trim(cell_value_3) != VERSIONS_first_row[i-1]) {
	    			VERSIONS_first_row_ok = 0;
	    			break;
				}
			}
		}	
		
		if (VERSIONS_first_row_ok == 0) {
			tl_step("type row content - after refresh","1","incorrect");
		} else {
			tl_step("type row content - after refresh","0","correct");
		}
	} else {
		tl_step("Table index - VERSIONS - after refresh","1","incorrect");
	}
} else {
	tl_step("Table index - VERSIONS","1","incorrect");
}
