private void tmrStopScript_Tick(object sender, System.EventArgs e)
        {
            GUITestUtility.GUIInfo guiUnit = (GUITestUtility.GUIInfo)seqGUIUT.GUIList[clickNum - 1];
            Control ctrlTested;

            ctrlTested = (Control)GUITestUtility.VerifyField(AUT, guiUnit.GUIControlName);
            resultList.Add(ctrlTested.Text);

            if (clickNum >= seqGUIUT.GUIList.Count)
            {
                tmrRunScript.Enabled  = false;
                tmrStopScript.Enabled = false;
                tmrVerifyTest.Enabled = true;
                try
                {
                    AUT.Dispose();
                }
                catch {}
            }
            else
            {
                tmrRunScript.Enabled  = true;
                tmrStopScript.Enabled = false;
            }
        }
        private bool GetCheckedButtonInGroup(RadioButton rdBtn, ref string ErrorMsg)
        {
            int     parentHandle = GUITestActions.GetParent((int)rdBtn.Handle);
            Control parentGrp    = (Control)GUITestUtility.VerifyField(AUT, parentHandle);

            foreach (Control ctrl in parentGrp.Controls)
            {
                try
                {
                    RadioButton rdCtrl = (RadioButton)ctrl;
                    if (rdCtrl.Name == rdBtn.Name)
                    {
                        if (!rdBtn.Checked)
                        {
                            ErrorMsg = rdBtn.Name + " is not checked!";
                            return(false);
                        }
                    }
                    else
                    {
                        if (rdCtrl.Checked)
                        {
                            ErrorMsg = "Other than or beside the " + rdBtn.Name +
                                       " is checked, the " + rdCtrl.Name + " is also checked!";
                            return(false);
                        }
                    }
                }
                catch {}
            }
            return(true);
        }
        //chapter 8
        private void AddTestVerification()
        {
            if (AUT == null)
            {
                return;
            }

            string VerifyDataStore = guiTestDataStore.Replace(".xml", "_verify.xml");

            TypeVerificationSerializable verifyTypes = new TypeVerificationSerializable();
            object obj = (object)verifyTypes;

            GUITestUtility.DeSerializeInfo(VerifyDataStore, ref obj);
            verifyTypes = (TypeVerificationSerializable)obj;

            TypeVerification oneType  = (TypeVerification)verifyTypes.TypeList[clickNum - 1];
            object           resulted = null;

            foreach (TestExpectation fieldName in oneType.MemberList)
            {
                TestExpectation tested = fieldName;
                try
                {
                    resulted       = GUITestUtility.VerifyField(AUT, tested.VerifyingMember);
                    tested.isField = true;
                }
                catch (Exception ex4)
                {
                    resulted          = GUITestUtility.VerifyProperty(AUT, tested.VerifyingMember);
                    tested.isProperty = true;
                }
                VerifyAlphanumericResult(ref tested, resulted);
                VerifyClipboard(ref tested, resulted);
            }
        }
예제 #4
0
        private void RunsScript()
        {
            guiTestActionLib = Path.Combine(progDir, "GUITestActionLib.xml");

            GUITestUtility.GUIInfo guiUnit = (GUITestUtility.GUIInfo)seqGUIUT.GUIList[clickNum];

            string        ctrlAction = GUITestUtility.GetAGUIAction(guiTestActionLib, guiUnit.GUIControlType);
            StringBuilder sb         = new StringBuilder(10000);

            try             //chapter 12
            {
                Control ctrlTested = (Control)GUITestUtility.VerifyField(AUT, guiUnit.GUIControlName);
                GUITestActions.GetWindowText((int)ctrlTested.Handle, sb, 10000);
            }
            catch {}

            //object[] paramArr = new object[4];
            object[] paramArr = new object[5];             //chapter 10

            if (ctrlAction == "HandleMenuItems")           //chapter 12
            {
                paramArr[0] = AUT.Handle.ToInt32();
            }
            else
            {
                paramArr[0] = 0;
            }

            paramArr[1] = sb.ToString();
            paramArr[2] = guiUnit.GUIClassName;
            paramArr[3] = guiUnit.GUIParentText;
            paramArr[4] = guiUnit.TextEntry;             //chapter 10

            Type       guiTestLibType = new GUITestActions().GetType();
            object     obj            = Activator.CreateInstance(guiTestLibType);
            MethodInfo mi             = guiTestLibType.GetMethod(ctrlAction);

            //chapter 11
            preChecked = DeterminePreCheckedStatus(guiUnit);

            try
            {
                mi.Invoke(obj, paramArr);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (clickNum < seqGUIUT.GUIList.Count)
            {
                clickNum++;
                tmrRunScript.Enabled  = false;
                tmrStopScript.Enabled = true;
            }
        }
        private bool DeterminePreCheckedStatus(GUITestUtility.GUIInfo guiUnit)
        {
            bool isChecked = false;

            if (guiUnit.GUIControlType == "System.Windows.Form.CheckBox")
            {
                CheckBox chckBx = (CheckBox)GUITestUtility.VerifyField(AUT, guiUnit.GUIControlName);
                isChecked = chckBx.Checked;
            }
            return(isChecked);
        }
예제 #6
0
 private void timer2_Tick(object sender, System.EventArgs e)
 {
     if (clickNum > 0)
     {
         Control ctrlTested;
         ctrlTested = (Control)GUITestUtility.VerifyField(AUTobj, "txtSelected");
         statusCollection.Add(ctrlTested.Text);
     }
     timer1.Enabled = true;
     timer2.Enabled = false;
 }
예제 #7
0
        private void RunsScript()
        {
            guiTestActionLib = Path.Combine(progDir, "GUITestActionLib.xml");

            GUITestUtility.GUIInfo guiUnit = (GUITestUtility.GUIInfo)seqGUIUT.GUIList[clickNum];

            string ctrlAction = GUITestUtility.GetAGUIAction(guiTestActionLib, guiUnit.GUIControlType);

            StringBuilder sb = new StringBuilder(10000);

            Control ctrlTested = (Control)GUITestUtility.VerifyField(AUT, guiUnit.GUIControlName);

            GUITestActions.GetWindowText((int)ctrlTested.Handle, sb, 10000);

            object[] paramArr = new object[4];
            paramArr[0] = 0;
            paramArr[1] = sb.ToString();            //.Replace("\r\n", "\n");
            paramArr[2] = guiUnit.GUIClassName;
            paramArr[3] = guiUnit.GUIParentText;

            Type       guiTestLibType = new GUITestActions().GetType();
            object     obj            = Activator.CreateInstance(guiTestLibType);
            MethodInfo mi             = guiTestLibType.GetMethod(ctrlAction);

            try
            {
                mi.Invoke(obj, paramArr);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (clickNum < seqGUIUT.GUIList.Count)
            {
                clickNum++;
                tmrRunScript.Enabled  = false;
                tmrStopScript.Enabled = true;
            }
        }
예제 #8
0
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            if (clickNum < 7)
            {
                clickNum++;
                timer1.Enabled = false;
                timer2.Enabled = true;
            }

            int    hwnd    = 0;
            string winText = "";
            string clsName = "";
            string pText   = "";

            switch (clickNum)
            {
            case 1:
                //1. click the list box
                hwnd    = 0;
                winText = "";
                clsName = "WindowsForms10.LISTBOX.app3";
                pText   = "C# API Text Viewer";
                GUITestActions.HandleListBox(ref hwnd, ref winText, ref clsName, ref pText);
                break;

            case 2:
                //2. click the Add button
                winText = "Add";
                clsName = "";
                GUITestActions.HandleCommandButton(ref hwnd, ref winText, ref clsName, ref pText);
                break;

            case 3:
                //3. Click the Copy button
                winText = "Copy";
                clsName = "";
                GUITestActions.HandleCommandButton(ref hwnd, ref winText, ref clsName, ref pText);

                break;

            case 4:
                //4. Click the text box
                Control ctrlTested;
                ctrlTested = (Control)GUITestUtility.VerifyField(AUTobj, "txtSelected");
                StringBuilder sb = new StringBuilder(1000);
                GUITestActions.GetWindowText((int)ctrlTested.Handle, sb, 1000);
                winText = sb.ToString();
                clsName = "WindowsForms10.RichEdit20W.app3";
                GUITestActions.HandleTextBox(ref hwnd, ref winText, ref clsName, ref pText);
                break;

            case 5:
                //5. Click the Remove button to remove one line of code
                winText = "Remove";
                clsName = "";
                GUITestActions.HandleCommandButton(ref hwnd, ref winText, ref clsName, ref pText);
                break;

            case 6:
                //6. Click the Clear button to clear the text box
                winText = "Clear";
                clsName = "";
                pText   = "C# API Text Viewer";
                GUITestActions.HandleCommandButton(ref hwnd, ref winText, ref clsName, ref pText);
                break;

            default:
                //Complet this clicking sequence
                timer1.Enabled = false;
                timer2.Enabled = false;
                break;
            }
        }