Ejemplo n.º 1
0
        public static void StartProcessWithFormAndControl(
            UIAutomationTestForms.Forms formCode,
            TimeoutsAndDelays formDelayEn,
            System.Windows.Automation.ControlType controlType,
            string controlName,
            string controlAutomationId,
            TimeoutsAndDelays controlDelayEn)
        {
            var controlToForm =
                new ControlToForm(
                    controlType,
                    controlName,
                    controlAutomationId,
                    controlDelayEn);

            // 20150322

            /*
             * var arr = new System.Collections.ArrayList();
             * arr.Add(controlToForm);
             *
             * StartProcessWithFormAndControl(
             *  formCode,
             *  formDelayEn,
             *  ((ControlToForm[])arr.ToArray(typeof(ControlToForm))));
             */
            var arr = new ArrayList {
                controlToForm
            };

            StartProcessWithFormAndControl(
                formCode,
                formDelayEn,
                ((ControlToForm[])arr.ToArray(typeof(ControlToForm))));
        }
Ejemplo n.º 2
0
        protected WinFormsForm(
            string formName,
            string formTitle,
            System.Windows.Automation.ControlType controlType,
            string controlName,
            string controlAutomationId,
            int controlDelay)
        {
            ControlType         = controlType;
            ControlDelay        = controlDelay;
            ControlName         = controlName;
            ControlAutomationId = controlAutomationId;
            FormName            = formName;
            FormTitle           = formTitle;

            if (FormName == "WinFormsNoTaskBar")
            {
                FormBorderStyle   = FormBorderStyle.FixedToolWindow;
                this.Visible      = false;
                AllowTransparency = true;
                ControlBox        = false;
                ShowIcon          = false;
                ShowInTaskbar     = false;
            }

            //this.ChildForm = this;
            //  // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            //  // TODO: Add constructor code after the InitializeComponent() call.
            //
        }
Ejemplo n.º 3
0
 public WinFormsNoTaskBar(
     System.Windows.Automation.ControlType controlType,
     string controlName,
     string controlAutomationId,
     int controlDelay) : base("WinFormsNoTaskBar", "WinFormsNoTaskBar", controlType, controlName, controlAutomationId, controlDelay)
 {
     ChildForm = this;
 }
Ejemplo n.º 4
0
 public WinFormsAnonymous(
     System.Windows.Automation.ControlType controlType,
     string controlName,
     string controlAutomationId,
     int controlDelay) : base("WinFormsAnonymous", "", controlType, controlName, controlAutomationId, controlDelay)
 {
     ChildForm = this;
 }
Ejemplo n.º 5
0
        private static string SimpleControlTypeName(IUIAutomationElement element)
        {
            var type = ControlType.LookupById(
                (int)element.GetCurrentPropertyValue(
                    AutomationElementIdentifiers.ControlTypeProperty.Id
                    )
                );

            return(type?.LocalizedControlType);
        }
Ejemplo n.º 6
0
 public ControlToForm(
     System.Windows.Automation.ControlType controlType,
     string controlName,
     string controlAutomationId,
     TimeoutsAndDelays controlDelay)
 {
     ControlType         = controlType;
     ControlName         = controlName;
     ControlAutomationId = controlAutomationId;
     ControlDelayEn      = controlDelay;
 }
Ejemplo n.º 7
0
 public WinFormsTripled(
     System.Windows.Automation.ControlType controlType,
     int controlDelay) : base("WinFormsTripled", "WinFormsTripled", controlType, controlDelay)
 {
     ChildForm = this;
 }
Ejemplo n.º 8
0
        private static void Main(string[] args)
        {
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.ToString());
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.ProgrammaticName.ToString());
            // Console.WriteLine(System.Windows.Automation.ControlType.Button.GetType().Name);


// Dumping types for further investigation

//            Console.WriteLine("Dumping the types...");
//            dumpTypes(System.Environment.GetEnvironmentVariable("TEMP",
//                                                                EnvironmentVariableTarget.User) +
//                      @"\types.txt");
//            Console.WriteLine("...completed");
//                      return;

            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            // the second command-line argument FormDelay
            if (args.Length > 1 && args[1] != null && args[1] != string.Empty)
            {
                try {
                    if ((Convert.ToInt32(args[0]) != 0) &&
                        (Convert.ToInt32(args[1]) != 0))
                    {
                        int sleepTime =
                            Convert.ToInt32(args[1]);
                        System.Threading.Thread.Sleep(sleepTime);
                    }
                } catch {
                    // Console.WriteLine("Wrong arguments!Use numbers:");
                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
                    return; // 1;
                }
            }

// if (Delay > 0) {
// System.Threading.Thread.Sleep(Delay);
// }
            // the first command-line argument FormType
            if (args.Length > 0 && args[0] != null && args[0] != "")
            {
                Forms formCode;
                try {
                    formCode = (Forms)(Convert.ToInt32(args[0]));
                } catch {
                    // Console.WriteLine("Wrong arguments!Use numbers:");
                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
                    return; // 2;
                }

                // System.Windows.Forms.Application.Run(new MainForm());

                #region reserved code
//                System.Windows.Automation.ControlType ctrlType = null;
//
//                // the third command-line argument ControlType
//                if (args.Length > 2 && args[2] != null && args[2] != "") {
//                    // string _controlType = String.Empty;
//                    //_controlType = args[2].ToUpper();
//                    ctrlType =
//                        UiaHelper.GetControlTypeByTypeName(args[2]);
//                }
//
//                int controlDelay = 0;
//
//                // the fourth command-line argument ControlDelay
//                if (args.Length > 3 && args[3] != null && args[3] != string.Empty) {
//                    try {
//                        controlDelay = System.Convert.ToInt32(args[3]);
//                    } catch { }
//                }
//
//                string controlName = string.Empty;
//
//                // the fifth command-line argument ControlName
//                if (args.Length > 4 && args[4] != null && args[4] != string.Empty) {
//                    try {
//                        controlName = args[4];
//                    } catch { }
//                }
//
//                string controlAutomationId = string.Empty;
//
//                // the sixth command-line argument ControlAutomationId
//                if (args.Length > 5 && args[5] != null && args[5] != string.Empty) {
//                    try {
//                        controlAutomationId = args[5];
//                    } catch { }
//                }
//
//                switch (formCode)
//                {
//                    case Forms.WinFormsEmpty:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        // WinFormsEmpty frmWFE = new WinFormsEmpty();
//                        // frmWFE.ShowDialog();
//                        break;
//                    case Forms.WinFormsEmptyX2:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsEmpty(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsAnonymous:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsAnonymous(
//                                ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsMinimized:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsMinimized(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsMaximized:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsMaximized(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsNoTaskBar:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsNoTaskBar(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//                    case Forms.WinFormsRich:
//                        System.Windows.Forms.Application.Run(
//                            new WinFormsRich(ctrlType, controlName, controlAutomationId, controlDelay));
//                        break;
//
//
//                    case Forms.WPFEmpty:
//                        WPFEmpty frmWPFE = new WPFEmpty();
//                        frmWPFE.ShowDialog();
//                        //Application.Run(new MainForm());
//                        break;
//                    case Forms.WPFEmptyX2:
//                        WPFEmpty frmWPFE1 = new WPFEmpty();
//                        frmWPFE1.ShowDialog();
//                        WPFEmpty frmWPFE2 = new WPFEmpty();
//                        frmWPFE2.ShowDialog();
//                        break;
//                    case Forms.WPFAnonymous:
//                        WPFAnonymous frmWPFA = new WPFAnonymous();
//                        frmWPFA.ShowDialog();
//                        break;
//                    case Forms.WPFMinimized:
//                        WPFMinimized frmWPFMi = new WPFMinimized();
//                        frmWPFMi.ShowDialog();
//                        break;
//                    case Forms.WPFMaximized:
//                        WPFMaximized frmWPFMa = new WPFMaximized();
//                        frmWPFMa.ShowDialog();
//                        break;
//                    case Forms.WPFCollapsed:
//                        WPFCollapsed frmWPFCo = new WPFCollapsed();
//                        frmWPFCo.ShowDialog();
//                        break;
//
//                }
//            }
                #endregion reserved code

                System.Windows.Automation.ControlType ctrlType = null;
                int             controlDelay        = 0;
                string          controlName         = string.Empty;
                string          controlAutomationId = string.Empty;
                ControlToForm[] controls            = null;

                if (args.Length > 2)
                {
                    //    ControlToForm controlToForm = new ControlToForm();
                    //    for (int i = 2; i < args.Length; i++) {
                    //        controlto
                    //    }

                    System.Collections.ArrayList arrList =
                        new System.Collections.ArrayList();

                    for (int i = 2; i < args.Length; i = i + 4)
                    {
                        ControlToForm controlToForm =
                            new ControlToForm();

                        //System.Windows.Automation.ControlType ctrlType = null;
                        ctrlType = null;

                        // the third command-line argument ControlType
                        if (args[i] != null && args[i] != "")
                        {
                            ctrlType =
                                UiaHelper.GetControlTypeByTypeName(args[i]);
                            controlToForm.ControlType = ctrlType;
                        }

                        //int controlDelay = 0;
                        controlDelay = 0;

                        // the fourth command-line argument ControlDelay
                        if (args[i + 1] != null && args[i + 1] != string.Empty)
                        {
                            try {
                                controlDelay = Convert.ToInt32(args[i + 1]);
                                controlToForm.ControlDelayEn = controlDelay;
                            } catch { }
                        }

                        //string controlName = string.Empty;
                        controlName = string.Empty;

                        // the fifth command-line argument ControlName
                        if (args[i + 2] != null && args[i + 2] != string.Empty)
                        {
                            try {
                                controlName = args[i + 2];
                                controlToForm.ControlName = controlName;
                            } catch { }
                        }

                        //string controlAutomationId = string.Empty;
                        controlAutomationId = string.Empty;

                        // the sixth command-line argument ControlAutomationId
                        if (args[i + 3] != null && args[i + 3] != string.Empty)
                        {
                            try {
                                controlAutomationId = args[i + 3];
                                controlToForm.ControlAutomationId = controlAutomationId;
                            } catch { }
                        }

                        arrList.Add(controlToForm);
                    } // for (int i = 2; i < args.Length; i = i + 4)

                    controls =
                        (ControlToForm[])arrList.ToArray(typeof(ControlToForm));
                }

                switch (formCode)
                {
                case Forms.WinFormsEmpty:
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    break;

                case Forms.WinFormsEmptyX2:
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    System.Windows.Forms.Application.Run(
                        new WinFormsEmpty(controls));
                    break;

                case Forms.WinFormsAnonymous:
                    System.Windows.Forms.Application.Run(
                        new WinFormsAnonymous(
                            ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsMinimized:
                    System.Windows.Forms.Application.Run(
                        new WinFormsMinimized(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsMaximized:
                    System.Windows.Forms.Application.Run(
                        new WinFormsMaximized(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsNoTaskBar:
                    System.Windows.Forms.Application.Run(
                        new WinFormsNoTaskBar(ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsTripled:
                    System.Windows.Forms.Application.Run(
                        new WinFormsTripled(controls));
                    break;

                case Forms.WinFormsThreeSet:
                    System.Windows.Forms.Application.Run(
                        new WinFormsOuter()); //(controls));
                    break;

                case Forms.WinFormsWithMenus:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithMenus());
                    break;

                case Forms.WinFormsRich:
                    System.Windows.Forms.Application.Run(
                        new WinFormsRich()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsFull:
                    System.Windows.Forms.Application.Run(
                        new WinFormsFull()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsWizard:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWizard()); //ctrlType, controlName, controlAutomationId, controlDelay));
                    break;

                case Forms.WinFormsWithGrid:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithGrid());
                    break;

                case Forms.WinFormsWithLists:
                    System.Windows.Forms.Application.Run(
                        new WinFormsWithLists());
                    break;

                case Forms.WPFEmpty:
                    WPFEmpty frmWPFE = new WPFEmpty();
                    frmWPFE.ShowDialog();
                    //Application.Run(new MainForm());
                    break;

                case Forms.WPFEmptyX2:
                    WPFEmpty frmWPFE1 = new WPFEmpty();
                    frmWPFE1.ShowDialog();
                    WPFEmpty frmWPFE2 = new WPFEmpty();
                    frmWPFE2.ShowDialog();
                    break;

                case Forms.WPFAnonymous:
                    WPFAnonymous frmWPFA = new WPFAnonymous();
                    frmWPFA.ShowDialog();
                    break;

                case Forms.WPFMinimized:
                    WPFMinimized frmWPFMi = new WPFMinimized();
                    frmWPFMi.ShowDialog();
                    break;

                case Forms.WPFMaximized:
                    WPFMaximized frmWPFMa = new WPFMaximized();
                    frmWPFMa.ShowDialog();
                    break;

                case Forms.WPFCollapsed:
                    WPFCollapsed frmWPFCo = new WPFCollapsed();
                    frmWPFCo.ShowDialog();
                    break;

                case Forms.WPFFull:
                    WPFFull frmWPFFull = new WPFFull();
                    frmWPFFull.ShowDialog();
                    break;
//                case Forms.WPFWizard:
//                    WPFWizard frmWPFWizard = new WPFWizard();
//                    frmWPFWizard.ShowDialog();
//                    break;
                }

//            } // if (args.Length > 2)
//            else {
//                System.Windows.Forms.Application.Run(
//                    new WinFormsEmpty(ctrlType, 0));
//            }
            }


//            // the third command-line argument ControlType
//            if (args.Length > 2 && args[2] != null && args[2] != string.Empty)
//            {
//
//
//                FormControls controls;
//                try {
//                    controls = (FormControls)(System.Convert.ToInt32(args[2]));
//                } catch {
//                    // Console.WriteLine("Wrong arguments!Use numbers:");
//                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
//                    return; // 2;
//                }
//
//                System.Windows.Forms.Application.EnableVisualStyles();
//                System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
//                // System.Windows.Forms.Application.Run(new MainForm());
//
//
//                System.Windows.Automation.ControlType ctrlType = null;
//                if (args.Length > 2 && args[2] != null && args[2] != "") {
//                    // string _controlType = String.Empty;
//                    //_controlType = args[2].ToUpper();
//                    ctrlType =
//                        UiaHelper.GetControlTypeByTypeName(args[2]);
//
//
//                try {
//                    if ((System.Convert.ToInt32(args[0]) != 0) &&
//                        (System.Convert.ToInt32(args[1]) != 0))
//                    {
//                        int sleepTime =
//                            System.Convert.ToInt32(args[1]);
//                        System.Threading.Thread.Sleep(sleepTime);
//                    }
//                } catch {
//                    // Console.WriteLine("Wrong arguments!Use numbers:");
//                    // Console.WriteLine("TetUIAutomation Forms SleepBefore");
//                    return; // 1;
//                }
//            }
        }