#=============================================================================================
# @TITLE			DBM Wizard - Unattended installtion.
#
# @NUMBER			DBM2_FKT_02031
#
# @DESCRIPTION		Checking the template
#
# @EXP_RESULT		All before maded properties can be read.
#
# @REQUIREMENTS		"Database Manager" is installed.
#=============================================================================================
TestName = "DBM2_FKT_02031";
static WizardOpen = 1;

static general[] = {
					{"Database Name", database},
					{"Version", inst_version},
					{"InstallPath", ""},	#not unequivocal
					{"DBM User", "dbm"},
					{"DBM Password", "**********"},
					{"DBA User", "dba"},
					{"DBA Password", "**********"},
					{"ParamInitMode", "INIT"},
					{"InstanceType","OLTP"}
				   };
					  
static parameter[] = {
						{"RESTART_SHUTDOWN", "AUTO"},
						{"LOG_MIRRORED", "NO"},
						{"",""}		#dummy value
					 };
static volume[];
if (match (Version, "7.3.00") != 0)
{
	volume[0,0] = "SYSTEM";
	volume[0,1] = "";
	volume[0,2] = "SYS_001";
	volume[0,3] = "";
	volume[1,0] = "DATA";
	volume[1,1] = "6250";
	volume[1,2] = "DAT_0001";
	volume[1,3] = "FILE";
	volume[2,0] = "LOG";
	volume[2,1] = "1250";
	volume[2,2] = "LOG_001";
	volume[2,3] = "FILE";
} 
else
{
	volume[0,0] = "DATA";
	volume[0,1] = "6250";
	volume[0,2] = "DAT_0001";
	volume[0,3] = "FILE";
	volume[1,0] = "LOG";
	volume[1,1] = "1250";
	volume[1,2] = "LOG_001";
	volume[1,3] = "FILE";
} 

				  
#=============================================================================================
# @STEP 1			Going 'Back' and checking window content.
#=============================================================================================
if (win_exists("Database Manager Installation Wizard") == 0) {

	set_window("Database Manager Installation Wizard", 1);
	ActiveX_get_info("DBMWfr2.Framework", "HeaderTitle", Header);

	exp_Header = "Select Template";
	
	if (Header == exp_Header) {
		tl_step ("Installation wizard - 'Installation Template'", "0", "Window is correct. - TN: " & TestName);
	} else {		
		tl_step ("Installation wizard - 'Installation Template'", "1", "Window is incorrect. - TN: " & TestName);
	}
#=============================================================================================
# @STEP 2			Checking template - General.
#=============================================================================================
	set_window ("Database Manager Installation Wizard", 1);
	toolbar_button_press ("msvb_lib_toolbar", "Properties");
	
	set_window ("Installation Template Properties", 1);
	list_get_info ("lvwGeneral", "count", count);

	for (i=0;i<count;i++) {
		
		if (i != 2) {	#InstallPath not unequivocal
			set_window ("Installation Template Properties", 1);
			list_get_item("lvwGeneral", i, item);
			
			if (item == general[i,0]) {
				list_get_subitem("lvwGeneral", item, 1, subitem);
				list_get_item_info("lvwGeneral", item, CHECKED, value);
				
				if (subitem == general[i,1] &&
					value == 1) {
					
					tl_step ("Installation Template Properties - Checking items", "0", "Item: " & general[i,0] & ", subitem: " & general[i,1] & " found and checked. - TN: " & TestName);
				} else {
				
					if (match (subitem, general[i,1]) != 0 &&
						value == 1) {
						
						tl_step ("Installation Template Properties - Checking items", "0", "Item: " & general[i,0] & ", subitem: " & general[i,1] & " found and checked. - TN: " & TestName);
					}else {
						tl_step ("Installation Template Properties - Checking items", "1", "Item: " & general[i,0] & ", subitem: " & general[i,1] & " not found or not checked. - TN: " & TestName);
					}
				}
			} else {			
				tl_step ("Installation Template Properties - Checking items", "1", "Item " & general[i,0] & " not found. - TN: " & TestName);
			}
		}
	}
#=============================================================================================
# @STEP 3			Checking template - Parameter.
#=============================================================================================
	set_window ("Installation Template Properties", 0);
	tab_select_item ("tabPages", "&Parameters");
	
	set_window ("Installation Template Properties", 1);
	list_get_info ("lvwParameters", "count", count);

	for (i=0;i<count;i++) {
		
		if (i != 2) {	#InstallPath not unequivocal
			set_window ("Installation Template Properties", 1);
			list_get_item("lvwParameters", i, item);
			
			if (item == parameter[i,0]) {
				list_get_subitem("lvwParameters", item, 1, subitem);
				list_get_item_info("lvwParameters", item, CHECKED, value);
				
				if (match (subitem, parameter[i,1]) != 0 &&
					value == 1) {
					
					tl_step ("Installation Template Properties - Checking items", "0", "Item: " & parameter[i,0] & ", subitem: " & parameter[i,1] & " found and checked. - TN: " & TestName);
				} else {
					tl_step ("Installation Template Properties - Checking items", "1", "Item: " & parameter[i,0] & ", subitem: " & parameter[i,1] & " not found or not checked. - TN: " & TestName);
				}
			} else {			
				tl_step ("Installation Template Properties - Checking items", "1", "Item " & parameter[i,0] & " not found. - TN: " & TestName);
			}
		}
	}
#=============================================================================================
# @STEP 4			Checking template - Volumes.
#=============================================================================================
	set_window ("Installation Template Properties", 0);
	tab_select_item ("tabPages", "&Volumes");
	
	set_window ("Installation Template Properties", 1);
	list_get_info ("lvwVolumes", "count", count);

	for (i=0;i<count;i++) {
		
		#if (i != 2) {	#InstallPath not unequivocal
			set_window ("Installation Template Properties", 1);
			list_get_item("lvwVolumes", i, item);
			
			if (item == volume[i,0]) {
				list_get_subitem("lvwVolumes", item, 1, subitem1);
				list_get_subitem("lvwVolumes", item, 2, subitem2);
				list_get_subitem("lvwVolumes", item, 3, subitem3);
				list_get_item_info("lvwVolumes", item, CHECKED, value);
				
				if ((subitem1 == volume[i,1] && 
					 subitem2 == volume[i,2] && 
					 subitem3 == volume[i,3] && 
					 value == 1)) 
				{	
					tl_step ("Installation Template Properties - Checking items", "0", "Item: " & volume[i,0] & ", subitems: " & volume[i,1] & "," & volume[i,2] & "," & volume[i,3] & " found and checked. - TN: " & TestName);
				} else {
					tl_step ("Installation Template Properties - Checking items", "1", "Item: " & volume[i,0] & ", subitems: " & volume[i,1] & "," & volume[i,2] & "," & volume[i,3] & " not found or not checked. - TN: " & TestName);
				}
			} else {			
				tl_step ("Installation Template Properties - Checking items", "1", "Item " & volume[i,0] & " not found. - TN: " & TestName);
			}
		#}
	}
#=============================================================================================
# @STEP 5			Checking template - Media.
#=============================================================================================
	set_window ("Installation Template Properties", 0);
	tab_select_item ("tabPages", "&Media");
	
	set_window ("Installation Template Properties", 1);
	list_get_info ("lvwMedia", "count", count);

	if (count == 0) {
		
		tl_step ("Installation Template Properties - Checking items", "0", "No backup items in list. - TN: " & TestName);
	} else {
		tl_step ("Installation Template Properties - Checking items", "1", "Backup items in list. - TN: " & TestName);
	}
#=============================================================================================
# @STEP 6			'Cancel' properties.
#=============================================================================================	
	set_window ("Installation Template Properties", 0);
	button_press ("Cancel");
} else {
	tl_step("Database Manager Installation Wizard - Window Check", "1", "Window not open. - TN: " & TestName);
	WizardOpen = 0;
}
