Ejemplo n.º 1
0
        public override void Body()
        {
            ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;

            UIControlBase c = UIControlBase.FindControlByPath(control);

            if (!c.Exists)
            {
                ActualResult = QAliber.RemotingModel.TestCaseResult.Failed;
                throw new InvalidOperationException("Control not found");
            }

            IWindowPattern window = c.GetControlInterface <IWindowPattern>();

            if (window == null)
            {
                ActualResult = QAliber.RemotingModel.TestCaseResult.Failed;
                throw new InvalidOperationException("Control doesn't appear to be a window");
            }

            switch (opType)
            {
            case WindowOperationType.Close:
                window.Close();
                break;

            case WindowOperationType.Maximize:
                if (!window.CanMaximize)
                {
                    Log.Error("Window does not support maximizing.", string.Empty, EntryVerbosity.Internal);
                    return;
                }

                window.SetState(WindowVisualState.Maximized);
                break;

            case WindowOperationType.Minimize:
                if (!window.CanMinimize)
                {
                    Log.Error("Window does not support maximizing.", string.Empty, EntryVerbosity.Internal);
                    return;
                }

                window.SetState(WindowVisualState.Minimized);
                break;

            case WindowOperationType.Restore:
                window.SetState(WindowVisualState.Normal);
                break;

            case WindowOperationType.SetFocus:
                window.SetState(WindowVisualState.Normal);
                c.SetFocus();
                break;
            }
        }
Ejemplo n.º 2
0
        public override void Body()
        {
            ActualResult = TestCaseResult.Failed;

            Stopwatch     watch         = new Stopwatch();
            string        lastException = null;
            UIControlBase c             = null;

            watch.Start();
            while (watch.ElapsedMilliseconds < _timeout + 10)
            {
                try
                {
                    c = UIControlBase.FindControlByPath(_control);

                    if (c.Exists)
                    {
                        break;
                    }
                }
                catch (Exception ex) {
                    lastException = ex.ToString();
                }
            }

            if (c == null || !c.Exists)
            {
                Log.Error("Control not found after " + _timeout + " milliseconds", _control);

                if (lastException != null)
                {
                    Log.Warning("Exception caught", lastException, EntryVerbosity.Debug);
                }

                return;
            }

            UIAControl uia = c as UIAControl;

            if (uia != null && uia.XPathElementName == "titlebar")
            {
                // Go with the parent
                c = uia.Parent;
            }

            c.SetFocus();
            ActualResult = TestCaseResult.Passed;
        }
Ejemplo n.º 3
0
        private void HighlightWorker(object obj)
        {
            UIControlBase control = obj as UIControlBase;

            if (control.Layout != System.Windows.Rect.Empty)
            {
                if (control.Layout.X == -1111)
                {
                    ((WatinControl)control).Flash(4);
                    return;
                }
                control.SetFocus();

                QAliber.Engine.Win32.GDI32.HighlightRectangleDesktop(
                    control, 2500);
            }
        }