#=============================================================================================
#
# @TITLE			Configure users - Create New User Group.
#
# @NUMBER			DBM3_DBUser_005_Configure_users_NewGroup
#
# @DESCRIPTION		configure the DB users (create,delete,rename etc.).
#
#=============================================================================================

static TestName = "DBM3_DBUser_005_Configure_users_NewGroup";

#=============================================================================================
# @STEP 1		Check CreateNewuserGroup Button
#=============================================================================================

set_window ("Configuration Wizard", 7);
toolbar_get_button_info("msvb_lib_toolbar","New User Group",ENABLED,btn_NewUserGroup);
if (btn_NewUserGroup == 0)
{
	tl_step ("btn_NewUserGroup not available",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

toolbar_button_press ("msvb_lib_toolbar", "New User Group");

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

set_window("SQL User *");
#=============================================================================================
# @STEP 3		 Select <General> Tab & check all Elements
#=============================================================================================
tab_select_item("tabPages","&General");

obj_get_info("txtName","enabled",text_name);
obj_get_info("txtPassword","enabled",text_password);
obj_get_info("txtConfirmPassword","enabled",text_confirm_password);
obj_get_info("comUsermode","enabled",list_user_class);
obj_get_info("comConnectMode","enabled",list_connection_mode);

if (text_name == 0 || text_password == 1 || text_confirm_password == 1 || list_user_class == 0 || list_connection_mode == 0)
{
	tl_step ("Elements not in correct state (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#=============================================================================================
# @STEP 3.1		Check the Name textField ---> texit & content
#=============================================================================================
if (text_name == 0)
{
	tl_step ("textfieldName not enabled (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

obj_get_text("txtName",text_NameContent,"","","","");
if (text_NameContent != "")
{
	tl_step ("Textfield Name is not empty (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
	edit_set("txtName","");
}
button_get_info("OK","enabled",OK_enabled);

if (OK_enabled == 1) 
{
	tl_step ("OK button should be disabled (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

#=============================================================================================
# @STEP 3.2		Enter newGroup Name & check if OK Button gets enabled ---> texit
#=============================================================================================
edit_set ("txtName","TEST_GROUP");

button_get_info("OK","enabled",OK_enabled);
if (OK_enabled == 0)
{
	tl_step ("OK should be enabled (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

#=============================================================================================
# @STEP 4		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);
obj_get_info("txtTimeout","enabled",text_Timeout);
obj_get_info("txtCostwarning","enabled",text_CostWarning);
obj_get_info("txtCostlimit","enabled",text_CostLimit);
obj_get_info("comDefaultCode","enabled",text_DefaultCode);

if (text_Permlimit == 1 || text_TempLimit == 1 || text_Timeout == 0 || text_CostWarning == 0 || text_CostLimit == 0 || text_DefaultCode == 0)
{
	tl_step ("Elements not in correct state (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1; 
}


#=============================================================================================
# @STEP 4.1			check correct Timeout Value --> correct OK Button - enabled / else disabled 
#=============================================================================================
# value to LOW
edit_set ("txtTimeout","29");
button_get_info("OK","enabled",OK_enabled);
if (OK_enabled == 1)
{
	tl_step ("OK should be disabled because of illegal Timout value  (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
# value correct
edit_set ("txtTimeout","30");
button_get_info("OK","enabled",OK_enabled);
if (OK_enabled == 0)
{
	tl_step ("OK should be enabled [correctTimeout value]  (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
# value to HIGH
edit_set ("txtTimeout","32401");
button_get_info("OK","enabled",OK_enabled);
if (OK_enabled == 1)
{
	tl_step ("OK should be disabled because of illegal Timout value  (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
# value to correct
edit_set ("txtTimeout","32400");
button_get_info("OK","enabled",OK_enabled);
if (OK_enabled == 0)
{
	tl_step ("OK should be enabled [correctTimeout value]  (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}


#=============================================================================================================
# @STEP 4.2			check correct CostWarning <-> CostLimit ratio --> correct OK Button - enabled / else disabled 
#=============================================================================================================
# false ratio
edit_set("txtCostwarning","10")
edit_set("txtCostlimit","1")
button_get_info("OK","enabled",OK_enabled);
if (OK_enabled == 1)
{
	tl_step ("OK should be disabled because of illegal CostWarning CostLimit ratio (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
# correct ratio
edit_set("txtCostwarning","1")
edit_set("txtCostlimit","10")
button_get_info("OK","enabled",OK_enabled);
if (OK_enabled == 0)
{
	tl_step ("OK should be enabled [correct CostWarning CostLimit ratio] (SQL User Group Properties - New User Group)",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#=============================================================================================================
# @STEP 5			Press OK button to confirm the creation of the new group 
#=============================================================================================================
button_press ("OK");


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