#=============================================================================================
# @TITLE			Start DB User Wizard.
#
# @NUMBER			DBM3_DBUser_002_DBALogin
#
# @DESCRIPTION		The DB User wizard get started.
#
# @EXP_RESULT		The "DB User" window opens.
#
# @REQUIREMENTS		"Database Manager" is installed.
#=============================================================================================
static TestName = "DBM3_DBUser_002_DBALogin";
static expHeaderTitle = "Configure Database Users / User Groups";
static expHeaderSubtitle = "Enter a database administrator.";
static Failure = 0;


#=============================================================================================
# @STEP 1			check if Config Wizard is open --> texit
#=============================================================================================
if (win_exists("Configuration Wizard",0) != E_OK)
{
	tl_step ("Wizard not open",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}	

#=============================================================================================
# @STEP 2		call Test - DBM3_WelcomeScreen ---> texit
#=============================================================================================
set_window("Configuration Wizard",0);
error = call_close "DBMGUI\Main\DBM3_WelcomeScreen"();
if (error) texit("true");

#=============================================================================================
# @STEP 3		check header title of login-window
#=============================================================================================	
#get header title
set_window("Configuration Wizard", 1);
ActiveX_get_info("DBMWfr3.Framework","HeaderTitle",HeaderTitle);
ActiveX_get_info("DBMWfr3.Framework","HeaderSubtitle",HeaderSubtitle);

# check if header title is correct
if (HeaderTitle != expHeaderTitle || HeaderSubtitle != expHeaderSubtitle)
{
	tl_step ("Header title not correct",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}
#=============================================================================================
# @STEP 3.1		check correct function of back Button
#=============================================================================================			
set_window ("Configuration Wizard", 2);

obj_get_info("< Back","enabled",BackEnabled);
if (BackEnabled == 0)
{
	tl_step ("Back button not enabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}
#=============================================================================================
# @STEP 3.2		check if WelcomeScreen appears
#=============================================================================================
set_window ("Configuration Wizard", 2);
button_press ("< Back");
if (obj_exists("rtbWelcome",0) != E_OK)
{
	tl_step ("No welcome screen after press backButton",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}

button_press ("Next >");
obj_wait_info("txtUser","enabled",1,10);
		
#=============================================================================================
# @STEP 3.3		check correct return to login-window
#=============================================================================================	
set_window("Configuration Wizard", 1);
ActiveX_get_info("DBMWfr3.Framework","HeaderTitle",HeaderTitle);
ActiveX_get_info("DBMWfr3.Framework","HeaderSubtitle",HeaderSubtitle);
	
# check if header title is correct
if (HeaderTitle != expHeaderTitle || HeaderSubtitle != expHeaderSubtitle)
{
	tl_step ("HeaderTitle / HeaderSubtitle not correct",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}

#=============================================================================================
# @STEP 4		enter user data
#=============================================================================================	
	
set_window ("Configuration Wizard", 4);
obj_get_info("txtUser","enabled",txtUserEnabled);
obj_get_info("txtPassword","enabled",txtPasswordEnabled);

#=============================================================================================
# @STEP 4.1		check if textfields are enabled
#=============================================================================================	

if (txtUserEnabled == 0 || txtPasswordEnabled == 0)
{
	tl_step ("Username or Password fields not enabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}

#=============================================================================================
# @STEP 4.2		check if textfields are empty
#=============================================================================================	
# read textfield content
set_window ("Configuration Wizard", 0);
edit_get_text("txtUser",txtUserContent);
edit_get_text("txtPassword",txtUserPassword);

if (txtUserContent != "" && txtPasswordContent != "")
{ 	
	tl_step ("Username and / or password fields are not empty",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	Failure = 1;
	
	# clear username and password field
	edit_set ("txtUser", "");
	password_edit_set("txtPassword", "");
}

#=============================================================================================
# @STEP 4.3		check other buttons
#=============================================================================================	

obj_get_info("Next >","enabled",NextEnabled);
obj_get_info("Cancel","enabled",CancelEnabled);
		
if (NextEnabled == 1)
{
	Failure = 1;
	tl_step ("Next button should be disabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
}
	
if (CancelEnabled == 0)
{
	Failure = 1;
	tl_step ("Cancel button should be enabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
}


#=============================================================================================
# @STEP 4.4		enter dba username / password
#=============================================================================================	
set_window ("Configuration Wizard", 0);
edit_set ("txtUser", "DBA");
password_edit_set("txtPassword", "dzbtaz");


#=============================================================================================
# @STEP 4.5		check if next button is now enabled and press next
#=============================================================================================	
obj_get_info("Next >","enabled",NextEnabled);
		
if (NextEnabled == 0)
{	
	tl_step ("Next button should be enabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}

button_press ("Next >");


#=============================================================================================
# @STEP 5		check if test passed successfully
#=============================================================================================	
if (Failure == 0)
	tl_step ("Test passed successfully",0,"Testname: " & TestName & ", Line:" & getvar("line_no"));
