示例#1
0
        public void TestIntSupport()
        {
            var schema = TestSchema.GetInstance();

            // Ask for the custom pattern
            var testPattern = (ITestPattern)_customElement.GetCurrentPattern(schema.PatternId);

            Assert.IsNotNull(testPattern);

            // Call through a pattern getter
            var testPropertyValue = testPattern.CurrentIntValue;

            Assert.AreEqual(42, testPropertyValue);

            // Call for the custom property directly
            var testPropertyValue2 = (int)_customElement.GetCurrentPropertyValue(schema.IntValueProperty.PropertyId);

            Assert.AreEqual(42, testPropertyValue2);

            // Call a pattern passer
            int testPropertyValue3;

            testPattern.PassIntParam(82, out testPropertyValue3);
            Assert.AreEqual(82, testPropertyValue3);
        }
示例#2
0
        public void TestDoubleSupport()
        {
            var schema = TestSchema.GetInstance();

            // Ask for the custom pattern
            var testPattern = (ITestPattern)_customElement.GetCurrentPattern(schema.PatternId);

            Assert.IsNotNull(testPattern);

            // Call through a pattern getter
            var testPropertyValue = testPattern.CurrentDoubleValue;

            Assert.AreEqual(3.1415, testPropertyValue);

            // We cannot request the property directly,
            // since it is declared as a method, not a property.
            //double testPropertyValue2 = (double)this.customElement.GetCurrentPropertyValue(schema.DoubleValueProperty.PropertyId);
            //Assert.AreEqual(3.1415, testPropertyValue2);

            // Call a pattern passer
            double testPropertyValue3;

            testPattern.PassDoubleParam(1.772, out testPropertyValue3);
            Assert.AreEqual(1.772, testPropertyValue3);
        }
示例#3
0
        public void TestBoolSupport()
        {
            var schema = TestSchema.GetInstance();

            // Ask for the custom pattern
            var testPattern = (ITestPattern)
                              _customElement.GetCurrentPattern(schema.PatternId);

            Assert.IsNotNull(testPattern);

            // Call through a pattern getter
            var testPropertyValue = testPattern.CurrentBoolValue;

            Assert.AreEqual(true, testPropertyValue);

            // We cannot request the property directly,
            // since it is declared as a method, not a property.
            //bool testPropertyValue2 = (bool)this.customElement.GetCurrentPropertyValue(schema.BoolValueProperty.PropertyId);
            //Assert.AreEqual(true, testPropertyValue2);

            // Call a pattern passer
            bool testPropertyValue3;

            testPattern.PassBoolParam(true, out testPropertyValue3);
            Assert.AreEqual(true, testPropertyValue3);
        }
示例#4
0
        public void TestStringSupport()
        {
            var schema = TestSchema.GetInstance();

            // Ask for the custom pattern
            var testPattern = (ITestPattern)_customElement.GetCurrentPattern(schema.PatternId);

            Assert.IsNotNull(testPattern);

            // Call through a pattern getter
            var testPropertyValue = testPattern.CurrentStringValue;

            Assert.AreEqual("TestString", testPropertyValue);

            // Call for the custom property directly
            var testPropertyValue2 = (string)_customElement.GetCurrentPropertyValue(schema.StringValueProperty.PropertyId);

            Assert.AreEqual("TestString", testPropertyValue2);

            // Call a pattern passer
            string testPropertyValue3;

            testPattern.PassStringParam("String2", out testPropertyValue3);
            Assert.AreEqual("String2", testPropertyValue3);
        }
示例#5
0
        public void TestElementSupport()
        {
            var schema = TestSchema.GetInstance();

            // Ask for the custom pattern
            var testPattern = (ITestPattern)_customElement.GetCurrentPattern(schema.PatternId);

            Assert.IsNotNull(testPattern);

            // Call through a pattern getter
            // We expect to get the custom element
            var testPropertyValue = testPattern.CurrentElementValue;
            var compareResult     = _factory.CompareElements(_customElement, testPropertyValue);

            Assert.AreNotEqual(0, compareResult);

            // Call for the custom property directly
            // We cannot request the property directly,
            // since it is declared as a method, not a property.
            //Interop.UIAutomationClient.IUIAutomationElement testPropertyValue2 = (Interop.UIAutomationClient.IUIAutomationElement)this.customElement.GetCurrentPropertyValue(schema.ElementValueProperty.PropertyId);
        }
示例#6
0
        public void MyTestInitialize()
        {
            // Create the factory and register schemas
            _factory = new CUIAutomationClass();
            ReadyStateSchema.GetInstance().Register();
            TestSchema.GetInstance().Register();
            ColorSchema.GetInstance().Register();

            // Start the app
            var curDir = Environment.CurrentDirectory;

            _app = new TargetApp(curDir + "\\UiaControls.exe");
            _app.Start();

            // Find the main control
            var appElement = _factory.ElementFromHandle(_app.MainWindow);
            var condition  = _factory.CreatePropertyCondition(
                UIA_PropertyIds.UIA_AutomationIdPropertyId,
                "triColorControl1");

            _customElement = appElement.FindFirst(TreeScope.TreeScope_Children,
                                                  condition);
            Assert.IsNotNull(_customElement);
        }