Пример #1
0
        public void HandleCommandButton(ref int hwnd, ref string winText, ref string clsName, ref string pText)
        {
            int r = GUITestActions.FindGUILike(ref hwnd, 0, ref winText, ref clsName, ref pText);

            GUITestActions.CenterMouseOn(hwnd);
            GUITestActions.ClickMouse(MonkeyButtons.btcLeft, 0, 0, 0, 0);
        }
        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);
        }
        private void StartAUT()
        {
            seqGUIUT = new GUITestUtility.GUIInfoSerializable();
            object obj = (object)seqGUIUT;

            GUITestUtility.DeSerializeInfo(guiTestDataStore, ref obj);
            seqGUIUT = (GUITestUtility.GUIInfoSerializable)obj;

            string AUTPath     = seqGUIUT.AUTPath;
            string startupType = seqGUIUT.AUTStartupForm;

            if (AUT == null)
            {
                AUT = (Form)GUITestUtility.StartAUT(AUTPath, startupType);
            }

            int           hwnd      = (int)AUT.Handle;
            StringBuilder sbClsName = new StringBuilder(128);

            GUITestActions.GetClassName(hwnd, sbClsName, 128);
            string clsName = sbClsName.ToString();
            string winText = AUT.Text;
            string pText   = "";

            GUITestActions.SynchronizeWindow(ref hwnd, ref winText, ref clsName, ref pText);
        }
 private void dgAvailableGUIs_CurrentCellChanged(object sender, System.EventArgs e)
 {
     try             //chapter 12
     {
         GUITestActions.IndicateSelectedGUI((int)guiSurveyCls.GUISortedList.GetKey(dgAvailableGUIs.CurrentCell.RowNumber));
     }
     catch {}
 }
Пример #5
0
        public void HandleTextBox(ref int hwnd, ref string winText, ref string clsName, ref string pText)
        {
            int r = GUITestActions.FindGUILike(ref hwnd, 0, ref winText, ref clsName, ref pText);

            GUITestActions.CenterMouseOn(hwnd);
            GUITestActions.MoveMouseInsideHwnd(hwnd, RectPosition.MiddleTop);
            GUITestActions.ClickMouse(MonkeyButtons.btcLeft, 0, 0, 0, 0);
        }
Пример #6
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;
            }
        }
Пример #7
0
        //chapter 12
        public void StartMenuSurvey()
        {
            int           wHnd       = GUITestActions.GetMenu(HandleUnderSurvey);
            StringBuilder ParentText = new StringBuilder(1000);

            GUITestActions.GetWindowText(HandleUnderSurvey, ParentText, 1000);

            int absPosID = 0;

            GUITestActions.FindMenuTextAndID(wHnd, ParentText.ToString(), ref absPosID, ref GUISortedList);
        }
Пример #8
0
        private void tmrAddDefinition_Tick(object sender, System.EventArgs e)
        {
            int    hwnd    = 0;
            string winText = "";
            string clsName = "WindowsForms10.LISTBOX.app3";
            string pText   = "C# API Text Viewer";

            GUITestActions.HandleListBox(ref hwnd, ref winText, ref clsName, ref pText);

            winText = "Add";
            clsName = "";
            pText   = "C# API Text Viewer";
            GUITestActions.HandleCommandButton(ref hwnd, ref winText, ref clsName, ref pText);
        }
Пример #9
0
        private void pbProbe_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Cursor csr = new Cursor(@"C:\GUISourceCode\Chapter03\TestMonkey\Monkey.ico");

            if (isDown)
            {
                pbProbe.Image = null;
                this.Cursor   = csr;

                dlgText    = new System.Text.StringBuilder();
                dlgClsName = new System.Text.StringBuilder();
                dlgPText   = new System.Text.StringBuilder();

                GUITestActions.GetWindowFromPoint(ref dlgHandle, ref dlgText, ref dlgClsName, ref dlgPText);
            }
        }
Пример #10
0
        private void StartAUT()
        {
            seqGUIUT = new GUITestUtility.GUIInfoSerializable();
            object obj = (object)seqGUIUT;

            GUITestUtility.DeSerializeInfo(guiTestDataStore, ref obj);
            seqGUIUT = (GUITestUtility.GUIInfoSerializable)obj;

            string AUTPath     = seqGUIUT.AUTPath;
            string startupType = seqGUIUT.AUTStartupForm;

            int hwnd = 0;

            if (AUT == null)
            {
                try                 //chapter 13
                {
                    AUT  = (Form)GUITestUtility.StartAUT(AUTPath, startupType);
                    hwnd = (int)AUT.Handle;
                }
                catch (InvalidCastException ex)                 //chapter 13
                {
                    AUT = GUITestUtility.StartControlUT(AUTPath, startupType);
                    AUT.Show();
                    Control ctrlAUT = AUT.Controls[0];
                    hwnd = (int)ctrlAUT.Handle;
                }
            }

            //int hwnd = (int)AUT.Handle;

            StringBuilder sbClsName = new StringBuilder(128);

            GUITestActions.GetClassName(hwnd, sbClsName, 128);
            string clsName = sbClsName.ToString();
            string winText = AUT.Text;
            string pText   = "";

            GUITestActions.SynchronizeWindow(ref hwnd, ref winText, ref clsName, ref pText);
        }
Пример #11
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;
            }
        }
        public void StartGUISurvey()
        {
            GUISortedList = new SortedList();

            int width      = 0;
            int height     = 0;
            int surveyStep = 10;
            int maxLen     = 128;

            GUITestActions.GetWindowSize(HandleUnderSurvey, ref width, ref height);

            for (int xPos = 0; xPos < width; xPos += surveyStep)
            {
                for (int yPos = 0; yPos < width; yPos += surveyStep)
                {
                    GUITestActions.MoveMouseInsideHwnd(HandleUnderSurvey, xPos, yPos, RectPosition.AnySpot);

                    GUITestUtility.GUIInfo GUISurvey = new GUITestUtility.GUIInfo();
                    StringBuilder          winText   = new StringBuilder(GUISurvey.GUIText, maxLen);
                    StringBuilder          clsName   = new StringBuilder(GUISurvey.GUIClassName, maxLen);
                    StringBuilder          pText     = new StringBuilder(GUISurvey.GUIParentText, maxLen);

                    GUITestActions.GetWindowFromPoint(ref GUISurvey.GUIHandle, ref winText, ref clsName, ref pText);

                    GUISurvey.GUIText       = winText.ToString();
                    GUISurvey.GUIClassName  = clsName.ToString();
                    GUISurvey.GUIParentText = pText.ToString();
                    try
                    {
                        GUISortedList.Add(GUISurvey.GUIHandle, GUISurvey);
                    }
                    catch
                    {
                    }
                }
            }

            return;
        }
        private void VerifyAlphanumericResult(ref TestExpectation fieldName, object resulted)
        {
            try
            {
                Control cntl = (Control)resulted;
                fieldName.isGUI        = true;
                fieldName.ActualResult = cntl.Text;
                StringBuilder sb = new StringBuilder(MaxLen);
                GUITestActions.GetWindowText((int)cntl.Handle, sb, MaxLen);
                fieldName.ScreenSnapshot = sb.ToString();
            }
            catch (InvalidCastException ex1)
            {
                fieldName.ActualResult = resulted.ToString() + "\n" + ex1.Message;
            }
            catch (Exception ex2)
            {
                fieldName.ActualResult = fieldName.VerifyingMember + " is not found as a member.\n" + ex2.Message;
            }

            fieldName.AssertAlphanumericTest(fieldName.ExpectAlphaNumericEqual);
            testResult.MemberList.Add(fieldName);
        }
Пример #14
0
 public object VerifyField(string fldName)
 {
     return(GUITestActions.VerifyField(CSharpAPITextViewerObj, fldName));
 }
Пример #15
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;
            }
        }