#=============================================================================================
# @TITLE			Checking second window - Recovery Wizard.
#
# @NUMBER			DBM2_FKT_02203
#
# @DESCRIPTION		Checking window and content. Step is to define the kind of recovery.
# @					First of all clicking the 'Back' button. Then
# @					clicking the options 4 options like -
# @					Restore last backup, Restore a specified backup from history,
# @					Restore a medium. -. And going 'Next'.
#
# @EXP_RESULT		The 'Back'buttonworks. The above mentioned 4 options will be displayed.
# @					And at last the 'Next' button works as well.
#
# @REQUIREMENTS		"Database Manager" is installed.
#=============================================================================================
static WizardOpen = 1;
TestName = "DBM2_FKT_02203";
#=============================================================================================
# @STEP 1			Checking window and clicking 'Next'.
#=============================================================================================
if (win_exists("Database Manager Recovery Wizard",0) == 0) {
	
	tl_step("Database Manager Recovery Wizard - Window Check", "0", "Window still open. - TN: " & TestName);
	
	set_window("Database Manager Recovery Wizard", 1);
#=============================================================================================
# @STEP 2			Clicking the 'Back' button.
#=============================================================================================
	button_press ("< Back");
	
	wait(5);
	
	ActiveX_get_info("DBMWfr2.Framework", "HeaderTitle", HeaderTitle1);
	ActiveX_get_info("DBMWfr2.Framework", "HeaderSubtitle", HeaderSubtitle1);
	
	if (HeaderTitle1 == "Type of Recovery" &&
		HeaderSubtitle1 == "Select the type of recovery that you want to perform.") {
		
		tl_step("Database Manager Recovery Wizard - Step Welcome title","0", "HeaderTitle: " & HeaderTitle1 & " not expected. - TN: " & TestName);
		tl_step("Database Manager Recovery Wizard - Step Welcome title","0", "HeaderSubtitle: " & HeaderSubtitle1 & " not expected. - TN: " & TestName);
	} else {
		tl_step("Database Manager Recovery Wizard - Step Welcome title","1", "HeaderTitle: " & HeaderTitle1 & " not expected. - TN: " & TestName);
		tl_step("Database Manager Recovery Wizard - Step Welcome title","1", "HeaderSubtitle: " & HeaderSubtitle1 & " not expected. - TN: " & TestName);
	}
#=============================================================================================
# @STEP 3			Clicking the 'Next' button and checking the window content.
#=============================================================================================
	button_press ("Next >");
	wait(5);

	# check for a incremental backup
	ActiveX_get_info("DBMWfr2.Framework", "HeaderTitle", HeaderTitle2);
	ActiveX_get_info("DBMWfr2.Framework", "HeaderSubtitle", HeaderSubtitle2);
	
	if (HeaderTitle2 == "Select Items for Recovery" &&
		HeaderSubtitle2 == "Select items to specify the use of incremental backups.") 
	{
		set_window("Database Manager Recovery Wizard", 1);
		list_get_info("lvwSelect","count",listCount);
		if (listCount > 0)
		{
			tl_step("Database Manager Recovery Wizard - Step Select Items for Recovery","0", listCount & " backups found - TN: " & TestName);
			for (i=0;i<listCount;i++)
			{
				list_get_item("lvwSelect","0",label);
				list_set_item_state ("lvwSelect", label, ON);
			}
		}
		else
		{
			tl_step("Database Manager Recovery Wizard - Step Select Items for Recovery","1", "No incremental backups found (should be there if backuptest was executed before) - TN: " & TestName);
		}
		
		button_press ("Next >");
		wait(5);
	}

	ActiveX_get_info("DBMWfr2.Framework", "HeaderTitle", HeaderTitle2);
	ActiveX_get_info("DBMWfr2.Framework", "HeaderSubtitle", HeaderSubtitle2);
	
	if (HeaderTitle2 == "Start Recovery" &&
		HeaderSubtitle2 == "Check your selection and start the recovery.") {
		
		tl_step("Database Manager Recovery Wizard - Step title","0", "HeaderTitle: " & HeaderTitle2 & " as expected. - TN: " & TestName);
		tl_step("Database Manager Recovery Wizard - Step title","0", "HeaderSubtitle: " & HeaderSubtitle2 & " as expected. - TN: " & TestName);
	} else {
		tl_step("Database Manager Recovery Wizard - Step title","1", "HeaderTitle: " & HeaderTitle2 & " not expected. - TN: " & TestName);
		tl_step("Database Manager Recovery Wizard - Step title","1", "HeaderSubtitle: " & HeaderSubtitle2 & " not expected. - TN: " & TestName);
	}
	
	L_RC_1 = obj_exists("lvwItems",0);
	L_RC_2 = obj_exists("Restore database until a specific time.",0);
	
	L_RC_4 = obj_exists("< Back",0);
	L_RC_5 = obj_exists("Start",0);
	L_RC_6 = obj_exists("Cancel",0);
	
	if (L_RC_1 == 0 &&
		L_RC_2 == 0 &&
		L_RC_3 == 0 &&
		L_RC_4 == 0 &&
		L_RC_5 == 0 &&
		L_RC_6 == 0) {
		
		tl_step("Start Recovery - Checking objects", "0", "All objects dispayed. - TN: " & TestName);
		
		list_get_info("lvwItems", "count", count);
		obj_get_info("Restore database until a specific time.", "value", value1);
		
		button_get_info("< Back", "enabled", value2);
		button_get_info("Start", "enabled", value3);
		button_get_info("Cancel", "enabled", value4);

		if (count == 2 &&
			value1 == 0 &&
			value2 == 1 &&
			value3 == 1 &&
			value4 == 1) {
			
			tl_step("Start Recovery - Checking button state and text.","0","All buttons in correct state and info text correct. - TN: " & TestName);
		} else {
			
			tl_step("Start Recovery - Checking button state and text.","1","Not all buttons in correct state or info text incorrect. - TN: " & TestName);
			
			tl_step("Start Recovery - Checking button state", "1", count & " expected 1 (Listitem count). - TN: " & TestName);
			tl_step("Start Recovery - Checking button state", "1", value1 & " expected 0 (Restore database until a specific time. - value). - TN: " & TestName);
			tl_step("Start Recovery - Checking button state", "1", value2 & " expected 1 (< Back). - TN: " & TestName);
			tl_step("Start Recovery - Checking button state", "1", value3 & " expected 1 (Start). - TN: " & TestName);
			tl_step("Start Recovery - Checking button state", "1", value4 & " expected 1 (Cancel). - TN: " & TestName);
		}		
#=============================================================================================
# @STEP 4			Clicking the 'Next' button and checking the window content.
#=============================================================================================
		set_window ("Database Manager Recovery Wizard", 3);
		
		# restore the complete data backup
		button_press ("Start");
		obj_wait_info("Start","enabled",TRUE,20);
		
		# restore the incremental data backup
		button_press ("Start");
		obj_wait_info("Start","enabled",TRUE,20);

	} else {
		tl_step("Start Recovery - Checking object of window.", "1", "Not all objects dispayed. - TN: " & TestName);
		
		tl_step("Start Recovery - Checking object of window.", "1", L_RC_1 & " expected 0. - TN: " & TestName);
		tl_step("Start Recovery - Checking object of window.", "1", L_RC_2 & " expected 0. - TN: " & TestName);
		tl_step("Start Recovery - Checking object of window.", "1", L_RC_4 & " expected 0. - TN: " & TestName);
		tl_step("Start Recovery - Checking object of window.", "1", L_RC_5 & " expected 0. - TN: " & TestName);
		tl_step("Start Recovery - Checking object of window.", "1", L_RC_6 & " expected 0. - TN: " & TestName);
	}
} else {
	
	tl_step("Database Manager Recovery Wizard - Window Check", "1", "Window not open. - TN: " & TestName);
	WizardOpen = 0;
}
