#=============================================================================================
# @TITLE			Checking second window - Recovery Wizard.
#
# @NUMBER			DBM2_FKT_02211
#
# @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_02211";
#=============================================================================================
# @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);
	ActiveX_get_info("DBMWfr2.Framework", "HeaderTitle", HeaderTitle2);
	ActiveX_get_info("DBMWfr2.Framework", "HeaderSubtitle", HeaderSubtitle2);
	
	if (HeaderTitle2 == "Medium for Recovery" &&
		HeaderSubtitle2 == "Create/Select a medium for 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("lvwMedia",0);
		
	L_RC_2 = obj_exists("< Back",0);
	L_RC_3 = obj_exists("Next >",0);
	L_RC_4 = obj_exists("Cancel",0);
	
	if (L_RC_1 == E_OK &&
		L_RC_2 == E_OK &&
		L_RC_3 == E_OK &&
		L_RC_4 == E_OK) {
		
		tl_step("Start Recovery - Checking objects", "0", "All objects dispayed. - TN: " & TestName);
		
		list_select_item("lvwMedia", "TestBackup_2", LEFT, 0);
		
		button_get_info("< Back", "enabled", value1);
		button_get_info("Next >", "enabled", value2);
		button_get_info("Cancel", "enabled", value3);

		if (value1 == 1 &&
			value2 == 1 &&
			value3 == 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", value1 & " expected 1 (< Back). - TN: " & TestName);
			tl_step("Start Recovery - Checking button state", "1", value2 & " expected 1 (Start). - TN: " & TestName);
			tl_step("Start Recovery - Checking button state", "1", value3 & " expected 1 (Cancel). - TN: " & TestName);
		}		
#=============================================================================================
# @STEP 4			Clicking the 'Next' button and checking the window content.
#=============================================================================================
		set_window ("Database Manager Recovery Wizard", 3);
		button_press ("Next >");
		
		wait(10);
		
		if (win_exists("DBMDoc2", 0) == 0) {
			
			tl_step ("Performing recovery of a specified medium.","1","Error number 5 'invalid procedure call or argument'. - TN: " & TestName);
			set_window ("DBMDoc2", 2);
			button_press ("OK");
		}
			
		if (win_exists("DBMWre2_0", 0) == 0) {
			
			tl_step ("Performing second recovery start","1","Recovery wizard crashed. - TN: " & TestName);
			set_window ("DBMWre2_0", 2);
			button_press ("OK");
			
			if (win_exists("DBMApp2_0", 0) == 0) {
				set_window ("DBMApp2_0", 2);
				button_press ("OK");
			}
			#Setting database to Online			
			set_window("SAP DB Database Manager", 1);
			toolbar_button_press("msvb_lib_toolbar_1","Online",LEFT);
			wait(10);
		}
	} 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_3 & " expected 0. - TN: " & TestName);
		tl_step("Start Recovery - Checking object of window.", "1", L_RC_4 & " expected 0. - TN: " & TestName);
	}
} else {
	
	tl_step("Database Manager Recovery Wizard - Window Check", "1", "Window not open. - TN: " & TestName);
	WizardOpen = 0;
}
