#=============================================================================================
#
# @TITLE			Configure users - Check new Group.
#
# @NUMBER			DBM3_DBUser_006_Configure_users_NewGroup_check
#
# @DESCRIPTION		check (Buttons,Properties) of new created Group
#
#=============================================================================================

static TestName = "DBM3_DBUser_006_Configure_users_NewGroup_check";
static expHeaderTitle = "Configure Database Users / User Groups";
static expHeaderSubtitle = "Configure database user for the database administrator 'DBA'.";
static Failure = 0;

static val_comUsermode;
static val_comConnectmode;
static val_timeout;
static val_costwarning;
static val_costlimit;
static val_defaultcode;


if (newGroup_properties == "check_create_values")
{
val_comUsermode = "STANDARD";
val_comConnectmode = "NOT EXCLUSIVE";
val_timeout = "32400";
val_costwarning = "1";
val_costlimit = "10";
val_defaultcode = "DEFAULT";
}

if (newGroup_properties == "check_new_values")
{
val_comUsermode = "RESOURCE";
val_comConnectmode = "EXCLUSIVE";
val_timeout = "32399";
val_costwarning = "2";
val_costlimit = "9";
val_defaultcode = "ASCII";
}

#=============================================================================================
# @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		check header title ---> texit
#=============================================================================================	
#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		Check TEST_GROUP ---> texit
#=============================================================================================	
set_window ("Configuration Wizard", 1);
if (list_select_item ("lvwSQLUser", "TEST_GROUP") != E_OK)
{
	tl_step ("No TEST_GROUP",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}

#=============================================================================================
# @STEP 4		Check  Toolbar Buttons
#=============================================================================================	

toolbar_get_button_info("msvb_lib_toolbar","New User",ENABLED,btn_NewUser);
toolbar_get_button_info("msvb_lib_toolbar","New User Group",ENABLED,btn_NewUserGroup);
toolbar_get_button_info("msvb_lib_toolbar","Properties",ENABLED,btn_Properties);
toolbar_get_button_info("msvb_lib_toolbar","Copy",ENABLED,btn_Copy);
toolbar_get_button_info("msvb_lib_toolbar","Delete",ENABLED,btn_Delete);
toolbar_get_button_info("msvb_lib_toolbar","Rename",ENABLED,btn_Rename);

if (btn_NewUser == 0 || btn_NewUserGroup == 0 || btn_Properties == 0 || btn_Copy == 1 || btn_Delete == 0 || btn_Rename == 0 )
{
	tl_step ("Toolbar Buttons not in correct state",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}


#=============================================================================================
# @STEP 5		Check Properties Button and press it ---> texit 
#=============================================================================================

toolbar_get_button_info("msvb_lib_toolbar","Properties",ENABLED,btn_NewUserGroup);
if (btn_NewUserGroup == 0)
{
	tl_step ("btn_Properties not available",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

set_window ("Configuration Wizard", 7);
toolbar_button_press ("msvb_lib_toolbar", "Properties");

#=============================================================================================
# @STEP 6	 	Check if new User Group Properties Window appears ---> texit
#=============================================================================================
if (win_exists("SQL User *",0) != E_OK)
{
	tl_step ("New user Group Properties window not opened",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

set_window("SQL User *");

#=============================================================================================
# @STEP 7 	 Select <General> Tab & check all Elements
#=============================================================================================
tab_select_item("tabPages","&General");

#check group name
edit_get_text("txtName",compare);
if (compare != "TEST_GROUP")
{
	tl_step ("False Group Name in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#check password fields
obj_get_info("txtPassword","enabled",text_password);
obj_get_info("txtConfirmPassword","enabled",text_confirm_password);
if (text_password == 1 || text_confirm_password == 1)
{
	tl_step ("Password settings FOR GROUP enabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#check user mode text
list_get_selected("comUsermode",compare,number);
if (compare != val_comUsermode)
{
	tl_step ("False USER MODE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#check connect mode text

list_get_selected("comConnectMode",compare,number);
if (compare != val_comConnectmode)
{
	tl_step ("False CONNECT MODE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#=============================================================================================
# @STEP 8		Select <Extended> Tab & check all Elements
#=============================================================================================
tab_select_item("tabPages","&Extended");


#obj_get_info("txtPermlimit","enabled",text_Permlimit);
#obj_get_info("txtTemplimit","enabled",text_TempLimit);

#check Timeout text
edit_get_text("txtTimeout",compare);
if (compare != val_timeout)
{
	tl_step ("False TIMEOUT VALUE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
#check cotswarning text
edit_get_text("txtCostwarning",compare);
if (compare != val_costwarning)
{
	tl_step ("False COSTWARNING VALUE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
#check costlimit text
edit_get_text("txtCostlimit",compare);
if (compare != val_costlimit)
{
	tl_step ("False COSTLIMIT in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
#check defaultcode text
list_get_selected("comDefaultCode",compare,number);
if (compare != val_defaultcode)
{
	tl_step ("False DEFAULT CODE VALUE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

button_press("OK");

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



