Пример #1
0
        /// <summary>
        /// Executes Tests
        /// </summary>
        public static void Execute(ExecutionSettings settings)
        {
            Stack <ICleanableCommand> cleanupCommands = new Stack <ICleanableCommand>();

            try
            {
                //Elevation Service is hitting Error #5 "Access Denied" in XP - We don't have run time dependencies on it right now, so disabling.
                //cleanupCommands.Push(ElevationServiceCommand.Apply(infraBinariesDirectory));

                cleanupCommands.Push(LogDirectoryCommand.Apply(settings.LogFilesPath, settings.SkipDxDiag));

                ExecutionComponents executionComponents = new ExecutionComponents();
                executionComponents.DebuggingEngine = DebuggingEngineCommand.Apply(settings.InfraBinariesDirectory, settings.JitDebuggerCommand);
                cleanupCommands.Push(executionComponents.DebuggingEngine);
                ExecutionEventLog.RecordStatus("Creating LoggingMediator.");
                executionComponents.LoggingMediator = new LoggingMediator(settings.DebugTests); //Consider using dispose pattern.
                executionComponents.LoggingMediator.StartService(executionComponents.DebuggingEngine, settings.Tests.TestCollection.Count(record => record.ExecutionEnabled));

                //

                cleanupCommands.Push(ExecutionGroupLogCommand.Apply("InfraExecution", settings.LogFilesPath, executionComponents.LoggingMediator));
                if (settings.CodeCoverageEnabled)
                {
                    cleanupCommands.Push(MergeCodeCoverageDataCommand.Apply(settings.LogFilesPath));
                }
                cleanupCommands.Push(TemporaryDirectoryCommand.Apply(settings.ExecutionRootDirectory));
                cleanupCommands.Push(MoveWindowCommand.Apply());
                cleanupCommands.Push(ExecutionEventLog.Apply(settings.LogFilesPath, !settings.ContinueExecution));

                try
                {
                    ExecuteTestStateGroups(settings, executionComponents);
                }
                catch (Exception e)
                {
                    ExecutionEventLog.RecordException(e);
                }
                finally
                {
                    ExecutionEventLog.RecordStatus("Ending Test Sequence.");
                    ExecutionEventLog.RecordStatus("Shutting down test logging system.");
                    executionComponents.LoggingMediator.StopService();
                }
            }
            finally
            {
                Cleanup(cleanupCommands);
                Console.WriteLine("Test Execution has finished.\n");
            }
        }
Пример #2
0
        public ProcessesWatcher(RegionsManager regionsManager, SystemWindowsFactory windowsFactory, MoveWindowCommand moveWindowCommand)
        {
            _regionsManager    = regionsManager;
            _windowsFactory    = windowsFactory;
            _moveWindowCommand = moveWindowCommand;

            _asyncOperation = AsyncOperationManager.CreateOperation((object)null);
            _tickReporter   = new SendOrPostCallback(SyncedTick);

            SyncWindowsSet();

            _syncTimer = new Timer {
                Interval = 2000
            };
            _syncTimer.Elapsed  += SyncTick;
            _syncTimer.AutoReset = true;
            _syncTimer.Enabled   = true;
        }
Пример #3
0
            //build window command
            private static void BuildWindowCommand(IntPtr hWinEventHook, SystemEvents @event, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
            {
                switch (@event)
                {
                case SystemEvents.EVENT_MIN:
                    return;

                case SystemEvents.EVENT_MAX:
                    return;

                case SystemEvents.EVENT_SYSTEM_FOREGROUND:
                    break;

                case SystemEvents.MINIMIZE_END:
                    return;

                case SystemEvents.MINIMIZE_START:
                    return;

                default:
                    return;
                }


                int length     = GetWindowText(hwnd, _Buffer, _Buffer.Capacity);
                var windowName = _Buffer.ToString();



                //bypass screen recorder and Cortana (Win10) which throws errors
                if ((windowName == "Screen Recorder") || (windowName == "Cortana"))
                {
                    return;
                }



                if (length > 0)
                {
                    //wait additional for window to initialize
                    //System.Threading.Thread.Sleep(250);
                    windowName = _Buffer.ToString();

                    Automation.Commands.ActivateWindowCommand activateWindowCommand = new ActivateWindowCommand
                    {
                        v_WindowName = windowName,
                        v_Comment    = "Generated by Screen Recorder @ " + DateTime.Now.ToString()
                    };

                    generatedCommands.Add(activateWindowCommand);

                    //detect if tracking window open location or activate windows to top left
                    if (trackWindowOpenLocations)
                    {
                        GetWindowRect(hwnd, out RECT windowRect);


                        Automation.Commands.MoveWindowCommand moveWindowCommand = new MoveWindowCommand
                        {
                            v_WindowName      = windowName,
                            v_XWindowPosition = windowRect.left.ToString(),
                            v_YWindowPosition = windowRect.top.ToString(),
                            v_Comment         = "Generated by Screen Recorder @ " + DateTime.Now.ToString()
                        };

                        generatedCommands.Add(moveWindowCommand);
                    }
                    else if (activateWindowTopLeft)
                    {
                        //generate command to set window position
                        Automation.Commands.MoveWindowCommand moveWindowCommand = new MoveWindowCommand
                        {
                            v_WindowName      = windowName,
                            v_XWindowPosition = "0",
                            v_YWindowPosition = "0",
                            v_Comment         = "Generated by Screen Recorder @ " + DateTime.Now.ToString()
                        };

                        SetWindowPosition(hwnd, 0, 0);

                        generatedCommands.Add(moveWindowCommand);
                    }

                    //if tracking window sizes is set
                    if (trackActivatedWindowSizes)
                    {
                        //create rectangle from hwnd
                        GetWindowRect(hwnd, out RECT windowRect);

                        //do math to get height, etc
                        var width  = windowRect.right - windowRect.left;
                        var height = windowRect.bottom - windowRect.top;

                        //generate command to set window position
                        Automation.Commands.ResizeWindowCommand reszWindowCommand = new ResizeWindowCommand
                        {
                            v_WindowName  = windowName,
                            v_XWindowSize = width.ToString(),
                            v_YWindowSize = height.ToString(),
                            v_Comment     = "Generated by Screen Recorder @ " + DateTime.Now.ToString()
                        };


                        //add to list
                        generatedCommands.Add(reszWindowCommand);
                    }
                }
            }
Пример #4
0
        //build window command
        private static void BuildWindowCommand(IntPtr hWinEventHook, _systemEvents @event,
                                               IntPtr hwnd, int idObject, int idChild,
                                               uint dwEventThread, uint dwmsEventTime)
        {
            switch (@event)
            {
            case _systemEvents.EventMin:
                return;

            case _systemEvents.EventMax:
                return;

            case _systemEvents.EventSystemForeGround:
                break;

            case _systemEvents.MinimizeEnd:
                return;

            case _systemEvents.MinimizeStart:
                return;

            default:
                return;
            }

            int length     = GetWindowText(hwnd, _buffer, _buffer.Capacity);
            var windowName = _buffer.ToString();

            //bypass screen recorder and Cortana (Win10) which throws errors
            if ((windowName == "Screen Recorder") || (windowName == "Cortana"))
            {
                return;
            }

            if (length > 0)
            {
                //wait additional for window to initialize
                //System.Threading.Thread.Sleep(250);
                windowName = _buffer.ToString();

                ActivateWindowCommand activateWindowCommand = new ActivateWindowCommand
                {
                    v_WindowName = windowName,
                    v_Comment    = "Generated by Screen Recorder @ " + DateTime.Now.ToString()
                };

                GeneratedCommands.Add(activateWindowCommand);

                //detect if tracking window open location or activate windows to top left
                if (_trackWindowOpenLocations)
                {
                    User32Functions.GetWindowRect(hwnd, out Rect windowRect);

                    MoveWindowCommand moveWindowCommand = new MoveWindowCommand
                    {
                        v_WindowName     = windowName,
                        v_XMousePosition = windowRect.left.ToString(),
                        v_YMousePosition = windowRect.top.ToString(),
                        v_Comment        = "Generated by Screen Recorder @ " + DateTime.Now.ToString()
                    };

                    GeneratedCommands.Add(moveWindowCommand);
                }
                else if (_activateWindowTopLeft)
                {
                    //generate command to set window position
                    MoveWindowCommand moveWindowCommand = new MoveWindowCommand
                    {
                        v_WindowName     = windowName,
                        v_XMousePosition = "0",
                        v_YMousePosition = "0",
                        v_Comment        = "Generated by Screen Recorder @ " + DateTime.Now.ToString()
                    };

                    User32Functions.SetWindowPosition(hwnd, 0, 0);
                    GeneratedCommands.Add(moveWindowCommand);
                }

                //if tracking window sizes is set
                if (_trackActivatedWindowSizes)
                {
                    //create rectangle from hwnd
                    User32Functions.GetWindowRect(hwnd, out Rect windowRect);

                    //do math to get height, etc
                    var width  = windowRect.right - windowRect.left;
                    var height = windowRect.bottom - windowRect.top;

                    //generate command to set window position
                    ResizeWindowCommand reszWindowCommand = new ResizeWindowCommand
                    {
                        v_WindowName  = windowName,
                        v_XWindowSize = width.ToString(),
                        v_YWindowSize = height.ToString(),
                        v_Comment     = "Generated by Screen Recorder @ " + DateTime.Now.ToString()
                    };

                    //add to list
                    GeneratedCommands.Add(reszWindowCommand);
                }
            }
        }
        //combobox events for form items

        #region ComboBox Events

        private void cboIEWindow_SelectionChangeCommitted(object sender, EventArgs e)
        {
            var shellWindows = new ShellWindows();

            foreach (IWebBrowser2 shellWindow in shellWindows)
            {
                if (shellWindow.Document is HTMLDocument)
                {
                    if (shellWindow.Document.Title == cboIEWindow.Text)
                    {
                        _ie = shellWindow.Application;
                        var events = (HTMLDocumentEvents2_Event)_ie.Document;

                        events.onclick += (evt) =>
                        {
                            _searchParameters = new DataTable();
                            _searchParameters.Columns.Add("Enabled");
                            _searchParameters.Columns.Add("Property Name");
                            _searchParameters.Columns.Add("Property Value");

                            if (evt.srcElement is IHTMLElement)
                            {
                                IHTMLElement srcInfo           = evt.srcElement;
                                var          elementProperties = srcInfo.GetType().GetProperties();

                                foreach (PropertyInfo prp in elementProperties)
                                {
                                    var propIsString = prp.PropertyType == typeof(string);
                                    var propIsInt    = prp.PropertyType == typeof(int);

                                    if ((propIsString || propIsInt) && !prp.Name.Contains("IHTML"))
                                    {
                                        string propName  = prp.Name;
                                        string propValue = Convert.ToString(prp.GetValue(srcInfo));
                                        _searchParameters.Rows.Add(false, propName, propValue);
                                    }
                                }

                                dgvSearchParameters.Invoke(new MethodInvoker(() =>
                                {
                                    dgvSearchParameters.DataSource = _searchParameters;
                                })
                                                           );
                            }

                            return(false);
                        };

                        var activateWindow = new ActivateWindowCommand();
                        activateWindow.v_WindowName = cboIEWindow.Text + " - Internet Explorer";
                        activateWindow.RunCommand(null);

                        var moveWindow = new MoveWindowCommand();
                        moveWindow.v_WindowName      = cboIEWindow.Text + " - Internet Explorer";
                        moveWindow.v_XWindowPosition = "0";
                        moveWindow.v_YWindowPosition = "0";
                        moveWindow.RunCommand(null);

                        MoveFormToBottomRight(this);
                        TopMost = true;

                        foreach (Form frm in Application.OpenForms)
                        {
                            if (frm.Name != Name)
                            {
                                frm.WindowState = FormWindowState.Minimized;
                            }
                        }
                    }
                }
            }
        }