#=============================================================================================
# @TITLE			Caches - check table
#
# @NUMBER			WDBM_FKT_02001
#
# @DESCRIPTION		Clicking the "Caches" -link and checking the shown caches
# @					table.
#
# @EXP_RESULT		The caches 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 caches_headline_ok = 1;
static caches_first_row_ok = 1;
static caches_headline_ok_1 = 1;
static caches_first_row_ok_1 = 1;

static caches_headline [] = {"Type","Accesses","Successful","Unsuccessful","Hit Rate (%)"};

static caches_first_row_73 []= {"DATA","FBM","CONVERTER","USM","ROLLBACK","CATALOG","SEQUENCE"};   
static caches_first_row_74 []= {"DATA","CATALOG","SEQUENCE","COMMAND"};   
#=============================================================================================
# @STEP 1			Checking caches window.
#=============================================================================================
web_sync(100);
set_window (menu_window, 2);
web_link_click("Caches");

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("Caches","0","has shown up correctly");
} else {
	tl_step("Caches","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 - Caches") {
	
	tl_step("Table index - Caches","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) != caches_headline[i-1]) {
			caches_headline_ok = 0;
			break;
		}
	}
	
	if (caches_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) != caches_first_row_73[i-1]) {
    			data_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) != caches_first_row_74[i-1]) {
    			data_first_row_ok = 0;
    			break;
			}
		}
	}	
	
	if (caches_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_1) == "Information - Caches") {
	
		tl_step("Table index - Caches - 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) != caches_headline[i-1]) {
				caches_headline_ok = 0;
				break;
			}
		}
		
		if (caches_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) != caches_first_row_73[i-1]) {
	    			data_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) != caches_first_row_74[i-1]) {
	    			data_first_row_ok = 0;
	    			break;
				}
			}
		}	
		
		if (caches_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 - Caches - after refresh","1","incorrect");
	}
} else {
	tl_step("Table index - Caches - after refresh","1","incorrect");
}
