Exemplo n.º 1
0
        private void FillTree()
        {
            treeView.Nodes.Clear();
            Cursor oldCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            TreeNode node = new TreeNode("Desktop");

            node.Tag = rootControl;
            node.ContextMenuStrip = nodeContextMenu;
            node.SelectedImageKey = node.ImageKey = "control.bmp";
            UIControlBase control = node.Tag as UIControlBase;

            treeView.Nodes.Add(node);
            foreach (UIControlBase child in control.Children)
            {
                try
                {
                    TreeNode newNode = new TreeNode(child.VisibleName);
                    newNode.Tag = child;
                    newNode.SelectedImageKey = newNode.ImageKey = GetImageIndexByControlType(child);

                    newNode.ContextMenuStrip = nodeContextMenu;
                    node.Nodes.Add(newNode);
                }
                catch (Exception ex)
                {
                    //TODO : report exception
                }
            }
            this.Cursor = oldCursor;
        }
Exemplo n.º 2
0
        private void FillTreeRec(TreeNode node, int depth)
        {
            node.Nodes.Clear();
            TreeNode      newNode = null;
            UIControlBase control = node.Tag as UIControlBase;

            if (depth > 0 && control.Children != null)
            {
                foreach (UIControlBase child in control.Children)
                {
                    try
                    {
                        if (child != null)
                        {
                            newNode     = new TreeNode(child.VisibleName);
                            newNode.Tag = child;
                            newNode.SelectedImageKey = newNode.ImageKey = GetImageIndexByControlType(child);

                            newNode.ContextMenuStrip = nodeContextMenu;
                            node.Nodes.Add(newNode);
                            FillTreeRec(newNode, depth - 1);
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("FillTree exception - " + ex.Message);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void HandleTimerTick(object sender, EventArgs e)
        {
            // Simulate a mouse move over this point to activate any important mouseover behaviors
            System.Windows.Point point = new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y);

            AutomationElement element = null;

            try {
                element = AutomationElement.FromPoint(new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y));
            }
            catch {
            }

            if (element != null)
            {
                /*if( !element.Equals( capturedElement ) )
                 *      GDI32.RedrawWindow(capturedElement);*/

                UIControlBase control = UIAControl.GetControlByType(element);

                if (control != null)
                {
                    Debug.WriteLine("Sending MOUSEMOVE");
                    System.Windows.Point clientPoint = new System.Windows.Point((int)(Cursor.Position.X - control.Layout.X), (int)(Cursor.Position.Y - control.Layout.Y));

                    SendMessage(new HandleRef(this, control.Handle), 0x0200, (IntPtr)0, (IntPtr)(((int)clientPoint.Y << 16) | (int)clientPoint.X));
                }

                Debug.WriteLine("Repainting highlight after MOUSEMOVE");
                GDI32.HighlightWindow(capturedElement);
            }

            RecaptureElement(point, true);
        }
Exemplo n.º 4
0
        private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            UIControlBase control = e.Node.Tag as UIControlBase;

            if (control != null)
            {
                TrackSelection(control);
                if (!(control is WebRoot || control is WPFRoot || control is WatinRoot))
                {
                    try
                    {
                        //Trying to get the layout, (an indication that the control exists
                        System.Windows.Rect dummy = control.Layout;
                        if (dummy == System.Windows.Rect.Empty)
                        {
                            throw new Exception("Layout is empty");
                        }
                    }
                    catch (Exception)
                    {
                        //Control does not exist, changing icon and disabling context menu
                        e.Node.SelectedImageKey = e.Node.ImageKey = "notexists.bmp";
                        e.Node.ContextMenuStrip = null;
                        treeView.Refresh();
                    }
                }
            }
        }
Exemplo n.º 5
0
 public void OnMouseClick(UIControlBase button)
 {
     Engine.Exit();
     //Engine.GameState.CurrentState.Remove();
     // Engine.GameState.Register("Playing", new PlayingGameState());
     // Engine.GameState.ChangeState("Playing");
 }
Exemplo n.º 6
0
        private static string GetText(string control, bool logErrors)
        {
            UIControlBase c = UIControlBase.FindControlByPath(control);

            if (c == null || !c.Exists)
            {
                if (logErrors)
                {
                    Log.Error("Control not found");
                }

                return(null);
            }

            IText text = c.GetControlInterface <IText>();

            if (text == null)
            {
                // TODO: Add support for HTML controls (or REALLY do generic implementations on the interfaces)
                if (logErrors)
                {
                    Log.Error("Couldn't find an appropriate way to get text from the control.");
                }

                return(null);
            }

            return(text.Text);
        }
Exemplo n.º 7
0
    protected T ShowControls <T>(bool overlayView = false) where T : UIControlBase
    {
        T control = UIControlBase.Show <T>(overlayView ? tf_OverlayControl : tf_CameraControl);

        m_ControlSibiling.Add(control, m_ControlSibiling.Count - 1);
        return(control);
    }
Exemplo n.º 8
0
        public override void Body()
        {
            ActualResult = TestCaseResult.Failed;

            Stopwatch watch         = new Stopwatch();
            string    lastException = string.Empty;

            watch.Start();
            while (watch.ElapsedMilliseconds < timeout + 10)
            {
                try
                {
                    UIControlBase c = UIControlBase.FindControlByPath(control, _logControlSearch);

                    if (c.Exists)
                    {
                        ActualResult = TestCaseResult.Passed;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    lastException = ex.ToString();
                }
            }

            LogFailedByExpectedResult("Control not found after " + timeout + " milliseconds", control);
            if (lastException != string.Empty)
            {
                Log.Warning("Exception caught", lastException, EntryVerbosity.Debug);
            }
        }
Exemplo n.º 9
0
 public void OnMouseClick(UIControlBase button)
 {
     MusicPlayer.Stop();
     Engine.GameState.CurrentState.Remove();
     Engine.GameState.Register("Playing", new PlayingGameState());
     Engine.GameState.ChangeState("Playing");
 }
Exemplo n.º 10
0
        public override void Body()
        {
            ActualResult = QAliber.RemotingModel.TestCaseResult.Failed;

            UIControlBase c = UIControlBase.FindControlByPath(control);

            if (!c.Exists)
            {
                ActualResult = QAliber.RemotingModel.TestCaseResult.Failed;
                Log.Error("Control not found");
                return;
            }

            IScrollItemPattern pattern = c.GetControlInterface <IScrollItemPattern>();

            if (pattern != null && _scrollIntoView)
            {
                pattern.ScrollIntoView();
            }

            LowLevelInput.PressKeys(_modifierKeys);
            c.Click(button, point);
            LowLevelInput.ReleaseKeys(_modifierKeys);

            ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;
        }
Exemplo n.º 11
0
        public override void Body()
        {
            ActualResult = QAliber.RemotingModel.TestCaseResult.Failed;
            _resultTable = null;

            UIControlBase c = UIControlBase.FindControlByPath(_control);

            if (c == null || !c.Exists)
            {
                Log.Error("Control not found", _control);
                return;
            }

            IGridPattern grid = c.GetControlInterface <IGridPattern>();

            if (grid == null)
            {
                Log.Error("Couldn't find an appropriate way to get at grid data.");
                return;
            }

            string[]   headers;
            string[][] rows = grid.CaptureGrid(out headers);

            if (headers != null && headers.Distinct().Count() != headers.Length)
            {
                Log.Error("Duplicate column names", "Could not produce an output table because there are two columns with the same name.");
                return;
            }

            DataTable table = new DataTable("Captured grid");

            if (headers != null)
            {
                foreach (string header in headers)
                {
                    table.Columns.Add(XPath.EscapeLiteral(header), typeof(string));
                }
            }
            else
            {
                int columnCount = grid.ColumnCount;

                for (int i = 0; i < columnCount; i++)
                {
                    table.Columns.Add("Column " + i.ToString(CultureInfo.CurrentUICulture), typeof(string));
                }
            }

            foreach (string[] row in rows)
            {
                table.Rows.Add(row.Select(cell => cell ?? string.Empty).Select(XPath.EscapeLiteral).ToArray());
            }

            _resultTable = table;

            ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;
        }
Exemplo n.º 12
0
        public static string[] CaptureList(string control, bool logErrors)
        {
            // Capture the list
            UIControlBase c = UIControlBase.FindControlByPath(control);

            if (c == null || !c.Exists)
            {
                if (logErrors)
                {
                    Log.Error("Control not found", control);
                }

                return(null);
            }

            IListPattern list = c.GetControlInterface <IListPattern>();

            if (list != null)
            {
                return(list.CaptureList());
            }

            ISelector selector = c.GetControlInterface <ISelector>();

            if (selector != null)
            {
                return(selector.Items);
            }

            // Try one control up; we could be on the combo box's edit or button controls
            c = c.Parent;

            if (c != null)
            {
                list = c.GetControlInterface <IListPattern>();

                if (list != null)
                {
                    return(list.CaptureList());
                }

                selector = c.GetControlInterface <ISelector>();

                if (selector != null)
                {
                    return(selector.Items);
                }
            }

            if (logErrors)
            {
                Log.Error("Couldn't find a way to read the list.");
            }

            return(null);
        }
Exemplo n.º 13
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;
            }
        }
Exemplo n.º 14
0
 private void OnResultPopped(UIControlBase p_screen)
 {
     if ((p_screen as mg_ss_ResultScreen).Restart)
     {
         Minigame.ShowTitle();
     }
     else
     {
         MinigameManager.Instance.OnMinigameEnded();
     }
 }
Exemplo n.º 15
0
    protected void SetControlViewMode(UIControlBase control, bool overlay)
    {
        if (!m_ControlSibiling.ContainsKey(control))
        {
            Debug.LogError("?");
            return;
        }

        TCommonUI.ReparentRestretchUI(control.rectTransform, overlay ? tf_OverlayControl : tf_CameraControl);
        control.transform.SetSiblingIndex(m_ControlSibiling[control]);
    }
Exemplo n.º 16
0
 private void OnResultPopped(UIControlBase p_screen)
 {
     if ((p_screen as mg_if_ResultScreen).Restart)
     {
         MinigameManager.GetActive <mg_IceFishing>().ShowTitle();
     }
     else
     {
         MinigameManager.Instance.OnMinigameEnded();
     }
 }
Exemplo n.º 17
0
        private void viewImageMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = treeView.SelectedNode;

            if (node != null && node.Tag is UIControlBase)
            {
                UIControlBase control = node.Tag as UIControlBase;
                ImageViewer   viewer  = new ImageViewer(control.CodePath);
                viewer.SetImage(control.GetImage());
                viewer.ShowDialog();
            }
        }
Exemplo n.º 18
0
        private void addAliasMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = treeView.SelectedNode;

            if (node != null && node.Tag is UIControlBase)
            {
                UIControlBase             control = node.Tag as UIControlBase;
                Aliases.ManageAliasesForm form    = new Aliases.ManageAliasesForm(control.CodePath, control.UIType);
                if (form.Initiated)
                {
                    form.ShowDialog();
                }
            }
        }
Exemplo n.º 19
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");
            }

            c.GetImage().Save(file);
        }
Exemplo n.º 20
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;
        }
Exemplo n.º 21
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");
            }

            Bitmap image = c.GetImage();

            Log.Image(image, logDescription);
        }
Exemplo n.º 22
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);
            }
        }
Exemplo n.º 23
0
        private void ShowCapturedElement()
        {
            if (capturedElement == null)
            {
                return;
            }

            UIControlBase control = null;

            if (radioButtonWeb.Checked)
            {
                control = Desktop.Web.GetControlFromCursor();
            }
            else
            {
                control = UIAControl.GetControlByType(capturedElement);
            }
            if (control != null)
            {
                textBox.Text   = control.CodePath;
                coordinate     = new System.Windows.Point((int)(Cursor.Position.X - control.Layout.X), (int)(Cursor.Position.Y - control.Layout.Y));
                textBoxXY.Text = coordinate.ToString();

                _controlPropertyGrid.SelectedObject = null;

                _hierarchyList.BeginUpdate();
                _hierarchyList.Items.Clear();

                UIControlBase pass = control;

                while (pass != null)
                {
                    _hierarchyList.Items.Add(new ListViewItem()
                    {
                        Text = pass.VisibleName,
                        Tag  = pass
                    });

                    pass = pass.Parent;
                }

                _hierarchyList.EndUpdate();
                _hierarchyList.Items[0].Selected = true;
            }
        }
Exemplo n.º 24
0
        private void CreateMouseEntry(object entryObj)
        {
            MouseEntry entry = (MouseEntry)entryObj;

            try
            {
                lock (this)
                {
                    UIControlBase control = ((IControlLocator)RecorderConfig.Default.RootControl).GetControlFromPoint(new Point(entry.Point.X, entry.Point.Y));
                    if (control == null)
                    {
                        return;
                    }
                    if (control.Process != null)
                    {
                        foreach (string processName in RecorderConfig.Default.FilteredProcesses)
                        {
                            foreach (Process process in Process.GetProcessesByName(processName))
                            {
                                if (process.Id == control.Process.Id)
                                {
                                    return;
                                }
                            }
                        }
                    }

                    Point relPoint = new Point(entry.Point.X - control.Layout.Left, entry.Point.Y - control.Layout.Top);
                    entry.LLEntry.IsMouseUp     = entry.IsUp;
                    entry.LLEntry.AbsPoint      = new Point(entry.Point.X, entry.Point.Y);
                    entry.LLEntry.Button        = entry.Button;
                    entry.LLEntry.RelativePoint = relPoint;
                    entry.LLEntry.CodePath      = control.CodePath;
                    entry.LLEntry.Type          = control.UIType;
                    entry.LLEntry.Name          = control.VisibleName;
                    entries.Add(entry.LLEntry);
                }
            }

            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Exemplo n.º 25
0
 private void FillTreeFromLeaf(TreeNode node, UIControlBase control)
 {
     if (control.Parent != null)
     {
         TreeNode parentNode = new TreeNode(control.Parent.VisibleName);
         parentNode.Tag = control.Parent;
         parentNode.SelectedImageKey = parentNode.ImageKey = GetImageIndexByControlType(control.Parent);
         parentNode.ContextMenuStrip = nodeContextMenu;
         parentNode.Nodes.Add(node);
         FillTreeFromLeaf(parentNode, control.Parent);
     }
     else
     {
         node.Text             = "Desktop";
         node.Tag              = rootControl;
         node.ContextMenuStrip = nodeContextMenu;
         treeView.Nodes.Add(node);
     }
 }
Exemplo n.º 26
0
        public override void Body()
        {
            try
            {
                UIControlBase c = UIControlBase.FindControlByPath(control);

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

                ISelector selectorPattern = c.GetControlInterface <ISelector>();

                if (selectorPattern != null)
                {
                    listItems    = selectorPattern.Items;
                    ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;
                }
                else if (c is HTMLSelect)
                {
                    HTMLOption[] ops = ((HTMLSelect)c).Options;
                    listItems = new string[ops.Length];
                    for (int idx = 0; idx < ops.Length; idx++)
                    {
                        listItems[idx] = ops[idx].Text;
                    }

                    ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;
                }
                else
                {
                    ActualResult = QAliber.RemotingModel.TestCaseResult.Failed;
                    throw new InvalidOperationException("Control is not list type control");
                }
            }
            catch (Exception ex)
            {
                ActualResult = QAliber.RemotingModel.TestCaseResult.Failed;
                throw ex;
            }
        }
Exemplo n.º 27
0
        private void CreateKBEntry(object entryObj)
        {
            KBEntry entry = (KBEntry)entryObj;

            try
            {
                lock (this)
                {
                    UIControlBase control = ((IControlLocator)RecorderConfig.Default.RootControl).GetFocusedElement();
                    if (control == null)
                    {
                        return;
                    }
                    if (control.Process != null)
                    {
                        foreach (string processName in RecorderConfig.Default.FilteredProcesses)
                        {
                            foreach (Process process in Process.GetProcessesByName(processName))
                            {
                                if (process.Id == control.Process.Id)
                                {
                                    return;
                                }
                            }
                        }
                    }

                    entry.LLEntry.IsKeyUp     = entry.IsUp;
                    entry.LLEntry.Key         = entry.Key;
                    entry.LLEntry.InputHandle = entry.InputHandle;
                    entry.LLEntry.CodePath    = control.CodePath;
                    entry.LLEntry.Type        = control.UIType;
                    entry.LLEntry.Name        = control.VisibleName;
                    entries.Add(entry.LLEntry);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Exemplo n.º 28
0
        public override void Body()
        {
            ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;

            try
            {
                UIControlBase c = UIControlBase.FindControlByPath(control);

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

                c.MoveMouseTo(point);
            }
            catch (System.Reflection.TargetInvocationException)
            {
                ActualResult = QAliber.RemotingModel.TestCaseResult.Failed;
            }
        }
Exemplo n.º 29
0
        public override void Body()
        {
            ActualResult = TestCaseResult.Failed;

            UIControlBase c = UIControlBase.FindControlByPath(_control);

            if (!c.Exists)
            {
                Log.Error("Control not found");
                return;
            }

            if (!c.Enabled)
            {
                Log.Error("Control not enabled");
                return;
            }

            ITogglePattern toggle = c.GetControlInterface <ITogglePattern>();

            if (toggle != null)
            {
                ToggleState currentState = toggle.ToggleState;

                if (currentState != _state)
                {
                    LogFailedByExpectedResult("Did not match",
                                              string.Format("The control's state was \"{0}\" instead of \"{1}\".",
                                                            currentState, _state));
                    return;
                }

                ActualResult = QAliber.RemotingModel.TestCaseResult.Passed;
            }
            else
            {
                Log.Error("The target control doesn't support toggle operations.");
                return;
            }
        }
Exemplo n.º 30
0
        private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Cursor oldCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            if (toolStripComboBoxSpyAs.Text == "WPF")
            {
                rootControl.Refresh();
                FillTree();
            }
            else
            {
                TreeNode node = treeView.SelectedNode;
                if (node != null && node.Tag is UIControlBase)
                {
                    UIControlBase control = node.Tag as UIControlBase;
                    control.Refresh();
                    FillTreeRec(node, 2);
                }
            }
            this.Cursor = oldCursor;
        }