Пример #1
0
        public void ControlViewConditionTest()
        {
            SWA.Condition controlViewCond = SWA.Automation.ControlViewCondition;
            Assert.IsNotNull(controlViewCond, "ControlViewCondition");

            SWA.PropertyCondition controlViewPropCond = controlViewCond as SWA.PropertyCondition;
            Assert.IsNull(controlViewPropCond, "ControlViewCondition is not a PropertyCondition");

            SWA.AndCondition controlViewAndCond = controlViewCond as SWA.AndCondition;
            Assert.IsNull(controlViewAndCond, "ControlViewCondition is not a AndCondition");

            SWA.OrCondition controlViewOrCond = controlViewCond as SWA.OrCondition;
            Assert.IsNull(controlViewOrCond, "ControlViewCondition is not a OrCondition");

            SWA.NotCondition controlViewNotCond = controlViewCond as SWA.NotCondition;
            Assert.IsNotNull(controlViewNotCond, "ControlViewCondition is a NotCondition");

            SWA.Condition subCond = controlViewNotCond.Condition;
            Assert.IsNotNull(subCond, "ControlViewCondition.Condition");

            SWA.PropertyCondition subPropertyCond = subCond as SWA.PropertyCondition;
            Assert.IsNotNull(subPropertyCond, "ControlViewCondition.Condition is a PropertyCondition");
            Assert.AreEqual(AEIds.IsControlElementProperty,
                            subPropertyCond.Property,
                            "ControlViewCondition.Condition.Property");
            Assert.AreEqual(false,
                            subPropertyCond.Value,
                            "ControlViewCondition.Condition.Value");
            Assert.AreEqual(SWA.PropertyConditionFlags.None,
                            subPropertyCond.Flags,
                            "ControlViewCondition.Condition.Flags");
        }
Пример #2
0
 public void NotConditionTest()
 {
     Condition condition = Condition.TrueCondition;
     NotCondition target = new NotCondition(condition);
     Assert.IsNotNull(target);
     Condition child = target.Condition;
     Assert.IsNotNull(child);
 }
Пример #3
0
 static Automation()
 {
     RawViewCondition     = Condition.TrueCondition;
     ControlViewCondition =
         new NotCondition(new PropertyCondition(AEIds.IsControlElementProperty, false));
     ContentViewCondition =
         new NotCondition(new OrCondition(new PropertyCondition(AEIds.IsControlElementProperty, false),
                                          new PropertyCondition(AEIds.IsContentElementProperty, false)));
 }
Пример #4
0
		static Automation ()
		{
			RawViewCondition = Condition.TrueCondition;
			ControlViewCondition =
				new NotCondition (new PropertyCondition (AEIds.IsControlElementProperty, false));
			ContentViewCondition =
				new NotCondition (new OrCondition (new PropertyCondition (AEIds.IsControlElementProperty, false),
				                                   new PropertyCondition (AEIds.IsContentElementProperty, false)));
		}
Пример #5
0
        public override void ExitNotCondition(PrevailParser.NotConditionContext context)
        {
            base.ExitNotCondition(context);

            var condition = _conditionStack.Pop();

            var not = new NotCondition(condition);

            _conditionStack.Push(not);
        }
Пример #6
0
        public void ContentViewConditionTest()
        {
            SWA.Condition contentViewCond = SWA.Automation.ContentViewCondition;
            Assert.IsNotNull(contentViewCond, "ContentViewCondition");

            SWA.PropertyCondition contentViewPropCond = contentViewCond as SWA.PropertyCondition;
            Assert.IsNull(contentViewPropCond, "ContentViewCondition is not a PropertyCondition");

            SWA.AndCondition contentViewAndCond = contentViewCond as SWA.AndCondition; Assert.IsNull(contentViewPropCond, "ContentViewCondition is not a PropertyCondition");
            Assert.IsNull(contentViewAndCond, "ContentViewCondition is not a AndCondition");

            SWA.OrCondition contentViewOrCond = contentViewCond as SWA.OrCondition;
            Assert.IsNull(contentViewOrCond, "ContentViewCondition is not a OrCondition");

            SWA.NotCondition contentViewNotCond = contentViewCond as SWA.NotCondition;
            Assert.IsNotNull(contentViewNotCond, "ContentViewCondition is a NotCondition");

            SWA.Condition subCond = contentViewNotCond.Condition;
            Assert.IsNotNull(subCond, "ContentViewCondition.Condition");

            SWA.OrCondition subOrCond = subCond as SWA.OrCondition;
            Assert.IsNotNull(subOrCond, "ContentViewCondition.Condition is a OrCondition");

            SWA.Condition [] subSubConditions = subOrCond.GetConditions();
            Assert.AreEqual(2, subSubConditions.Length, "ContentViewCondition.Condition.GetConditions length");

            SWA.PropertyCondition subSubPropertyCond1 = subSubConditions [0] as SWA.PropertyCondition;
            Assert.IsNotNull(subSubPropertyCond1);
            SWA.PropertyCondition subSubPropertyCond2 = subSubConditions [1] as SWA.PropertyCondition;
            Assert.IsNotNull(subSubPropertyCond2);

            Assert.AreEqual(AEIds.IsControlElementProperty,
                            subSubPropertyCond1.Property,
                            "subcondition1 Property");
            Assert.AreEqual(false,
                            subSubPropertyCond1.Value,
                            "subcondition1 Value");
            Assert.AreEqual(SWA.PropertyConditionFlags.None,
                            subSubPropertyCond1.Flags,
                            "subcondition1 Flags");

            Assert.AreEqual(AEIds.IsContentElementProperty.ProgrammaticName,
                            subSubPropertyCond2.Property.ProgrammaticName,
                            "subcondition2 Property");
            Assert.AreEqual(false,
                            subSubPropertyCond2.Value,
                            "subcondition2 Value");
            Assert.AreEqual(SWA.PropertyConditionFlags.None,
                            subSubPropertyCond2.Flags,
                            "subcondition2 Flags");
        }
Пример #7
0
        public void RawViewConditionTest()
        {
            SWA.Condition rawViewCond = SWA.Automation.RawViewCondition;
            Assert.IsNotNull(rawViewCond, "RawViewCondition");

            SWA.PropertyCondition rawViewPropCond = rawViewCond as SWA.PropertyCondition;
            Assert.IsNull(rawViewPropCond, "RawViewCondition is not a PropertyCondition");

            SWA.AndCondition rawViewAndCond = rawViewCond as SWA.AndCondition;
            Assert.IsNull(rawViewAndCond, "RawViewCondition is not a AndCondition");

            SWA.OrCondition rawViewOrCond = rawViewCond as SWA.OrCondition;
            Assert.IsNull(rawViewOrCond, "RawViewCondition is not a OrCondition");

            SWA.NotCondition rawViewNotCond = rawViewCond as SWA.NotCondition;
            Assert.IsNull(rawViewNotCond, "RawViewCondition is not a NotCondition");
        }
Пример #8
0
        public void VerifyBasicConditions()
        {
            // Class = 'Awsum'

            Condition result1 = new PropertyCondition(AutomationElement.ClassNameProperty, "Awsum");

            var expression = new ExpressionLocator("", 1, Scope.Descendants, "Class = 'Awsum'");

            var result1Expression = expression.Condition;

            Assert.IsTrue(AutomationHelper.Compare(result1, result1Expression));

            // Class != 'Awsum'

            Condition result2 =
                new NotCondition(
                    new PropertyCondition(AutomationElement.ClassNameProperty, "Awsum"));

            var expression2 = new ExpressionLocator("", 1, Scope.Descendants, "Class != 'Awsum'");

            var result2Expression = expression2.Condition;

            Assert.IsTrue(AutomationHelper.Compare(result2, result2Expression));

            // Class = 'Awsum' And Name = 'Adi'

            Condition result3 =
                new AndCondition(
                    new PropertyCondition(AutomationElement.ClassNameProperty, "Awsum"),
                    new PropertyCondition(AutomationElement.NameProperty, "Adi"));

            var expression3 = new ExpressionLocator("", 1, Scope.Descendants, "Class = 'Awsum' And Name = 'Adi'");

            var result3Expression = expression3.Condition;

            Assert.IsTrue(AutomationHelper.Compare(result3, result3Expression));

            // Test
        }
Пример #9
0
        public Condition[] GetConditions()
        {
            if (!(IUIAutomationCondition is IUIAutomationAndCondition automationCondition))
            {
                return(null);
            }
            var typedArray     = automationCondition.GetChildren().ToTypedArray <IUIAutomationCondition>();
            var conditionArray = new Condition[typedArray.Length];

            for (var index = 0; index < conditionArray.Length; ++index)
            {
                if (typedArray[index] is IUIAutomationPropertyCondition)
                {
                    var propertyCondition = typedArray[index] as IUIAutomationPropertyCondition;
                    conditionArray[index] = new PropertyCondition(property: AutomationProperty.LookupById(id: propertyCondition.propertyId), value: propertyCondition.PropertyValue);
                }
                else if (typedArray[index] is IUIAutomationAndCondition)
                {
                    var automationAndCondition = typedArray[index] as IUIAutomationAndCondition;
                    conditionArray[index] = new AndCondition(iUIAConditions: automationAndCondition.GetChildren().ToTypedArray <IUIAutomationCondition>());
                }
                else if (typedArray[index] is IUIAutomationOrCondition)
                {
                    var automationOrCondition = typedArray[index] as IUIAutomationOrCondition;
                    conditionArray[index] = new OrCondition(iUIAConditions: automationOrCondition.GetChildren().ToTypedArray <IUIAutomationCondition>());
                }
                else if (typedArray[index] is IUIAutomationNotCondition)
                {
                    conditionArray[index] = new NotCondition(condition: new Condition(condition: typedArray[index]));
                }
                else if (typedArray[index] != null)
                {
                    conditionArray[index] = new Condition(condition: typedArray[index]);
                }
            }

            return(conditionArray);
        }