#=============================================================================================
# @TITLE			LOG - check table
#
# @NUMBER			WDBM_FKT_02004
#
# @DESCRIPTION		Clicking the "Log" -link and checking the shown LOG
# @					table.
#
# @EXP_RESULT		The log 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 LOG_headline_ok = 1;
static LOG_first_row_ok = 1;
static LOG_headline_ok_1 = 1;
static LOG_first_row_ok_1 = 1;

static LOG_headline [] = {"Name","Value"};

static LOG_first_row_73 []= {"Log Mode","Max. Size (KB)","Backup Segment Size (KB)","Used Size (KB)","Used Size (%)","Not Saved (KB)","Not Saved (%)","Log Since Last Data Backup (KB)","Savepoints","Checkpoints","Physical Reads","Physical Writes","Queue Size (KB)","Queue Overflows","Group Commits","Waits for Logwriter","Max. Waits","Average Waits"};
static LOG_first_row_74 []= {"Log Mirrored","Log Writing","Log Automatic Overwrite","Max. Size (KB)","Backup Segment Size (KB)","Used Size (KB)","Used Size (%)","Not Saved (KB)","Not Saved (%)","Log Since Last Data Backup (KB)","Savepoints","Checkpoints","Physical Reads","Physical Writes","Queue Size (KB)","Queue Overflows","Group Commits","Waits for Logwriter","Max. Waits","Average Waits"};
static LOG_first_row_76 []= {"Log Mirrored","Log Writing","Log Automatic Overwrite","Max. Size (KB)","Backup Segment Size (KB)","Used Size (KB)","Used Size (%)","Not Saved (KB)","Not Saved (%)","Log Since Last Data Backup (KB)","Savepoints","Checkpoints","Physical Reads","Physical Writes","Queue Size (KB)","Queue Overflows","Group Commits","Waits for Logwriter","Max. Waits","Average Waits","OMS Log Used Pages","OMS Min. Free Pages"};
#=============================================================================================
# @STEP 1			Checking backup window.
#=============================================================================================
web_sync(100);
set_window (menu_window, 2);

if (version == "7.3.00") {
	web_link_click("Log");
}
if (version == "7.4.03" ||
	version == "7.5.00" ||
	version == "7.5.01" ||
	version == "7.6.00") {
	
	set_window (menu_window, 2);
	web_link_click("Log Area");
}

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("Log Area","0","has shown up correctly");
} else {
	tl_step("Log Area","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 - Log Area") {

	
	tl_step("Table index - LOG","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) != LOG_headline[i-1]) {
			LOG_headline_ok = 0;
			break;
		}
	}
	
	if (LOG_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) != LOG_first_row_73[i-1]) {
    			LOG_first_row_ok = 0;
    			break;
    		}
		}
		if (version == "7.4.03" ||
			version == "7.5.00" ||
			version == "7.5.01") {
			
    		if (trim(cell_value_3) != LOG_first_row_74[i-1]) {
    			LOG_first_row_ok = 0;
    			break;
			}
		}
		if (version == "7.6.00") {
			
    		if (trim(cell_value_3) != LOG_first_row_76[i-1]) {
    			LOG_first_row_ok = 0;
    			break;
			}
		}
	}	
	
	if (LOG_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);
	}
    set_window(work_window, 1);
	web_obj_get_text("Information - CACHES - DB73","#1","#1",cell_value_4,"","",1);
    
    if (trim(cell_value_4) == "Information - Log Area") {
		
    	tl_step("Table index - log - 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) != LOG_headline[i-1]) {
				LOG_headline_ok = 0;
				break;
			}
		}
		
		if (LOG_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) != LOG_first_row_73[i-1]) {
	    			LOG_first_row_ok = 0;
	    			break;
	    		}
			}
			if (version == "7.4.03" ||
				version == "7.5.00" ||
				version == "7.5.01") {
			
	    		if (trim(cell_value_3) != LOG_first_row_74[i-1]) {
    				LOG_first_row_ok = 0;
    				break;
				}
			}
			if (version == "7.6.00") {
				
    			if (trim(cell_value_3) != LOG_first_row_76[i-1]) {
    				LOG_first_row_ok = 0;
	    			break;
				}
			}
		}	
	
		if (LOG_first_row_ok == 0) {
			tl_step("type row content","1","incorrect");
		} else {
			tl_step("type row content","0","correct");
		}
    } else {
    	tl_step("Table index - LOG","1","incorrect");
    }
} else {
	tl_step("Table index - LOG","1","incorrect");
}
