[NUnit.Framework.Test] // [MbUnit.Framework.Test][NUnit.Framework.Test][Fact]
        public void ToolTipOpenedEvent()
        {
            // Arrange
            var element =
                // FakeFactory.GetAutomationElementExpected(ControlType.Window, string.Empty, string.Empty, string.Empty, string.Empty);
                AutomationFactory.GetUiElement(AutomationElement.RootElement);
            // AutomationFactory.GetUiElement();
            var cmdlet =
                new RegisterUiaToolTipOpenedEventCommand {
                InputObject = new IUiElement[] { element }
            };

            TestEvent(
                cmdlet);
        }
Exemplo n.º 2
0
        public void OnePattern()
        {
            IFakeUiElement element =
                FakeFactory.GetAutomationElement(
                    ControlType.Button,
                    "name",
                    "auId",
                    "className",
                    new[] { AutomationFactory.GetPatternAdapter <IValuePattern>(AutomationFactory.GetUiElement(), null) },
                    true);

            MbUnit.Framework.Assert.AreEqual(1, element.GetSupportedPatterns().Count());
            MbUnit.Framework.Assert.Exists(element.GetSupportedPatterns(), p => p is IValuePattern);
            Assert.Equal(1, element.GetSupportedPatterns().Count());
            // Xunit.Assert.Contains<IBasePattern>(AutomationFactory.GetPatternAdapter<IValuePattern>(AutomationFactory.GetUiElement(), null) as IBasePattern, element.GetSupportedPatterns());
        }
Exemplo n.º 3
0
        private static IUiElement GetAutomationElementForObjectModelTesting(ControlType controlType, string name, string automationId, string className, IBasePattern[] patterns, bool expected)
        {
            var fakeElement =
                GetAutomationElement(
                    controlType,
                    name,
                    automationId,
                    className,
                    patterns,
                    expected);

            var proxiedElement =
                AutomationFactory.GetUiElement(
                    fakeElement as IUiElement);

            return(proxiedElement);
        }
Exemplo n.º 4
0
        public void ThreePatterns()
        {
            IFakeUiElement element =
                FakeFactory.GetAutomationElement(
                    ControlType.Button,
                    "name",
                    "auId",
                    "className",
                    new IBasePattern[] {
                AutomationFactory.GetPatternAdapter <IExpandCollapsePattern>(AutomationFactory.GetUiElement(), null),
                AutomationFactory.GetPatternAdapter <ITableItemPattern>(AutomationFactory.GetUiElement(), null),
                AutomationFactory.GetPatternAdapter <IWindowPattern>(AutomationFactory.GetUiElement(), null)
            },
                    true);

            MbUnit.Framework.Assert.AreEqual(3, element.GetSupportedPatterns().Count());
            MbUnit.Framework.Assert.Exists(element.GetSupportedPatterns(), p => p is IExpandCollapsePattern);
            MbUnit.Framework.Assert.Exists(element.GetSupportedPatterns(), p => p is ITableItemPattern);
            MbUnit.Framework.Assert.Exists(element.GetSupportedPatterns(), p => p is IWindowPattern);
            Assert.Equal(3, element.GetSupportedPatterns().Count());
            // Xunit.Assert.Contains<IBasePattern>(AutomationFactory.GetPatternAdapter<IExpandCollapsePattern>(AutomationFactory.GetUiElement(), null) as IBasePattern, element.GetSupportedPatterns());
            // Xunit.Assert.Contains<IBasePattern>(AutomationFactory.GetPatternAdapter<ITableItemPattern>(AutomationFactory.GetUiElement(), null), element.GetSupportedPatterns());
            // Xunit.Assert.Contains<IBasePattern>(AutomationFactory.GetPatternAdapter<IWindowPattern>(AutomationFactory.GetUiElement(), null), element.GetSupportedPatterns());
        }
Exemplo n.º 5
0
        public static IUiElement GetElement_ForFindAll(IEnumerable <IUiElement> elements, Condition conditions)
        {
            var elementBeforeProxy =
                GetAutomationElement(ControlType.Pane, string.Empty, string.Empty, string.Empty, new IBasePattern[] {}, false);

            var element =
                AutomationFactory.GetUiElement(
                    elementBeforeProxy as IUiElement);

            Condition[] condCollection = null;
            if (null != conditions as AndCondition)
            {
                condCollection = (conditions as AndCondition).GetConditions();
            }

            if (null != conditions as OrCondition)
            {
                condCollection = (conditions as OrCondition).GetConditions();
            }

            IUiEltCollection descendants =
                AutomationFactory.GetUiEltCollection();

            descendants.SourceCollection.AddRange(
                AutomationFactory.GetUiEltCollection(elements)
                .ToArray().Where(elt => "expected" == elt.GetTag()));

//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Button)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.Button));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Calendar)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.Calendar));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.CheckBox)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.CheckBox));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.ComboBox)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.ComboBox));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Custom)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.Custom));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.DataItem)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.DataItem));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Document)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.Document));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Image)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.Image));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.TreeItem)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.TreeItem));
//            element.FindAll(TreeScope.Descendants, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Window)).Returns<IEnumerable<IUiElement>>(descendants.ToArray().Select(elt => elt.Current.ControlType == ControlType.Window));
            element.FindAll(TreeScope.Descendants, Arg.Any <Condition>()).Returns(descendants);

            IUiEltCollection children =
                AutomationFactory.GetUiEltCollection();

            children.SourceCollection.AddRange(
                AutomationFactory.GetUiEltCollection(elements)
                .ToArray().Where(elt => "expected" == elt.GetTag()));

//            element.FindAll(
//                TreeScope.Children,
//                new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button)).Returns<IEnumerable>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Button));
//            element.FindAll(
//                TreeScope.Children,
//                new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)).Returns<IEnumerable>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Document));
//            element.FindAll(
//                TreeScope.Children,
//                new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Image)).Returns<IEnumerable>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Image));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Button)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Button));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Calendar)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Calendar));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.CheckBox)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.CheckBox));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.ComboBox)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.ComboBox));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Custom)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Custom));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.DataItem)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.DataItem));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Document)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Document));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Image)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Image));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.TreeItem)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.TreeItem));
//            element.FindAll(TreeScope.Children, Arg.Is<PropertyCondition>(x => (x as PropertyCondition).Value == ControlType.Window)).Returns<IEnumerable<IUiElement>>(children.ToArray().Select(elt => elt.Current.ControlType == ControlType.Window));
            element.FindAll(TreeScope.Children, Arg.Any <Condition>()).Returns(children);

            return(element);
        }