Esempio n. 1
0
        // ------------------------------------------------------
        //
        // IRawElementProviderAdviseEvents interface implementation
        //
        // ------------------------------------------------------
        // Advises event sinks that an event has been added.
        void IRawElementProviderAdviseEvents.AdviseEventAdded(int eventIdAsInt, int[] propertiesAsInts)
        {
            AutomationEvent eventId = AutomationEvent.LookupById(eventIdAsInt);

            AutomationProperty [] properties = null;
            if (propertiesAsInts != null)
            {
                properties = new AutomationProperty[propertiesAsInts.Length];
                for (int i = 0; i < propertiesAsInts.Length; i++)
                {
                    properties[i] = AutomationProperty.LookupById(propertiesAsInts[i]);
                }
            }

            //ProxyHwnd.AdviseEventAdded
            AdviseEventAdded(eventId, properties);
        }
        public void IsTogglePatternAvailablePropertyTest()
        {
            AutomationProperty myIsTogglePatternAvailableProperty =
                AutomationElementIdentifiers.IsTogglePatternAvailableProperty;

            Assert.IsNotNull(
                myIsTogglePatternAvailableProperty,
                "Field must not be null.");
            Assert.AreEqual(
                30041,
                myIsTogglePatternAvailableProperty.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.IsTogglePatternAvailableProperty",
                myIsTogglePatternAvailableProperty.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myIsTogglePatternAvailableProperty,
                AutomationProperty.LookupById(myIsTogglePatternAvailableProperty.Id),
                "LookupById");
        }
        public void ControlTypePropertyTest()
        {
            AutomationProperty myControlTypeProperty =
                AutomationElementIdentifiers.ControlTypeProperty;

            Assert.IsNotNull(
                myControlTypeProperty,
                "Field must not be null.");
            Assert.AreEqual(
                30003,
                myControlTypeProperty.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.ControlTypeProperty",
                myControlTypeProperty.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myControlTypeProperty,
                AutomationProperty.LookupById(myControlTypeProperty.Id),
                "LookupById");
        }
        public void IsRequiredForFormPropertyTest()
        {
            AutomationProperty myIsRequiredForFormProperty =
                AutomationElementIdentifiers.IsRequiredForFormProperty;

            Assert.IsNotNull(
                myIsRequiredForFormProperty,
                "Field must not be null.");
            Assert.AreEqual(
                30025,
                myIsRequiredForFormProperty.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.IsRequiredForFormProperty",
                myIsRequiredForFormProperty.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myIsRequiredForFormProperty,
                AutomationProperty.LookupById(myIsRequiredForFormProperty.Id),
                "LookupById");
        }
        public void BoundingRectanglePropertyTest()
        {
            AutomationProperty myBoundingRectangleProperty =
                AutomationElementIdentifiers.BoundingRectangleProperty;

            Assert.IsNotNull(
                myBoundingRectangleProperty,
                "Field must not be null.");
            Assert.AreEqual(
                30001,
                myBoundingRectangleProperty.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.BoundingRectangleProperty",
                myBoundingRectangleProperty.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myBoundingRectangleProperty,
                AutomationProperty.LookupById(myBoundingRectangleProperty.Id),
                "LookupById");
        }
        public void HasKeyboardFocusPropertyTest()
        {
            AutomationProperty myHasKeyboardFocusProperty =
                AutomationElementIdentifiers.HasKeyboardFocusProperty;

            Assert.IsNotNull(
                myHasKeyboardFocusProperty,
                "Field must not be null.");
            Assert.AreEqual(
                30008,
                myHasKeyboardFocusProperty.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.HasKeyboardFocusProperty",
                myHasKeyboardFocusProperty.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myHasKeyboardFocusProperty,
                AutomationProperty.LookupById(myHasKeyboardFocusProperty.Id),
                "LookupById");
        }
        public void AcceleratorKeyPropertyTest()
        {
            AutomationProperty myAcceleratorKeyProperty =
                AutomationElementIdentifiers.AcceleratorKeyProperty;

            Assert.IsNotNull(
                myAcceleratorKeyProperty,
                "Field must not be null.");
            Assert.AreEqual(
                30006,
                myAcceleratorKeyProperty.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.AcceleratorKeyProperty",
                myAcceleratorKeyProperty.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myAcceleratorKeyProperty,
                AutomationProperty.LookupById(myAcceleratorKeyProperty.Id),
                "LookupById");
        }
        public void NativeWindowHandlePropertyTest()
        {
            AutomationProperty myNativeWindowHandleProperty =
                AutomationElementIdentifiers.NativeWindowHandleProperty;

            Assert.IsNotNull(
                myNativeWindowHandleProperty,
                "Field must not be null.");
            Assert.AreEqual(
                30020,
                myNativeWindowHandleProperty.Id,
                "Id");
            Assert.AreEqual(
                "AutomationElementIdentifiers.NativeWindowHandleProperty",
                myNativeWindowHandleProperty.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myNativeWindowHandleProperty,
                AutomationProperty.LookupById(myNativeWindowHandleProperty.Id),
                "LookupById");
        }
Esempio n. 9
0
 public AutomationProperty [] GetSupportedProperties()
 {
     int [] supportedProperties = null;
     try {
         supportedProperties = dbusElement.SupportedPropertyIds;
     } catch (Exception ex) {
         throw DbusExceptionTranslator.Translate(ex);
     }
     if (supportedProperties == null)
     {
         Log.Error("SupportedPropertyIds returned null for element " +
                   "with bus name {0} and path {1}",
                   busName,
                   dbusPath);
         return(new AutomationProperty [] {});
     }
     return(supportedProperties
            .Select(i => AutomationProperty.LookupById(i))
            .Where(p => p != null)
            .ToArray());
 }
Esempio n. 10
0
 private void EnsurePropertyEventsSetUp(DCI.IApplication app, string busName)
 {
     if (!propertyEventBusNames.Contains(busName))
     {
         propertyEventBusNames.Add(busName);
         app.AutomationPropertyChanged += delegate(
             int hId, int evtId, string providerPath,
             int propertyId, object oldValue, object newValue) {
             var handler = eventHandlerManager.GetPropertyEventHandlerById(hId);
             if (handler != null)
             {
                 UiaDbusElement    elem = GetOrCreateElement(busName, providerPath);
                 AutomationElement ae   = SourceManager.GetOrCreateAutomationElement(elem);
                 oldValue = DeserializeAutomationPropertyValue(busName, propertyId, oldValue);
                 newValue = DeserializeAutomationPropertyValue(busName, propertyId, newValue);
                 var args = new AutomationPropertyChangedEventArgs(
                     AutomationProperty.LookupById(propertyId),
                     oldValue, newValue);
                 handler(ae, args);
             }
         };
     }
 }
Esempio n. 11
0
        public AutomationProperty[] GetSupportedProperties()
        {
            Array rawPropertyIds;
            Array rawPropertyNames;

            try
            {
                Automation.Factory.PollForPotentialSupportedProperties(this._obj, out rawPropertyIds, out rawPropertyNames);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx))
                {
                    throw newEx;
                }
                else
                {
                    throw;
                }
            }
            int[] propertyIds = (int[])rawPropertyIds;

            // This element may support properties that are not registered for this
            // client.  Filter them out.
            List <AutomationProperty> properties = new List <AutomationProperty>();

            foreach (int propertyId in propertyIds)
            {
                AutomationProperty property = AutomationProperty.LookupById(propertyId);
                if (property != null)
                {
                    properties.Add(property);
                }
            }
            return(properties.ToArray());
        }
        public void VerifyFlowsToAndFromConnectsPrimaryAndSecondaryCommands()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Button       showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout");
                ToggleButton isFlyoutOpenCheckBox       = FindElement.ById <ToggleButton>("IsFlyoutOpenCheckBox");

                Log.Comment("Tapping on a button to show the CommandBarFlyout.");
                InputHelper.Tap(showCommandBarFlyoutButton);

                // Pre-RS5, CommandBarFlyouts always open expanded,
                // so we don't need to tap on the more button in that case.
                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
                {
                    Log.Comment("Expanding the CommandBar by invoking the more button.");
                    FindElement.ById <Button>("MoreButton").InvokeAndWait();
                }

                Log.Comment("Retrieving the more button and undo button's automation element objects.");
                FindElement.ById("MoreButton").SetFocus();
                Wait.ForIdle();
                var moreButtonElement = AutomationElement.FocusedElement;

                FindElement.ById("UndoButton1").SetFocus();
                Wait.ForIdle();
                var undoButtonElement = AutomationElement.FocusedElement;

                Log.Comment("Verifying that the two elements point at each other using FlowsTo and FlowsFrom.");
                var flowsToCollection = (AutomationElementCollection)moreButtonElement.GetCurrentPropertyValue(AutomationProperty.LookupById(UIA_FlowsToPropertyId));

                Verify.AreEqual(1, flowsToCollection.Count);
                Verify.AreEqual(undoButtonElement, flowsToCollection[0]);

                var flowsFromCollection = (AutomationElementCollection)undoButtonElement.GetCurrentPropertyValue(AutomationProperty.LookupById(UIA_FlowsFromPropertyId));

                Verify.AreEqual(1, flowsFromCollection.Count);
                Verify.AreEqual(moreButtonElement, flowsFromCollection[0]);

                Log.Comment("Tapping on a button to hide the CommandBarFlyout.");
                InputHelper.Tap(showCommandBarFlyoutButton);
            }
        }
Esempio n. 13
0
        public void VerifyFlowsToAndFromIsNotSetWithoutPrimaryCommands()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Button showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout with no primary commands");

                Log.Comment("Tapping on a button to show the CommandBarFlyout.");
                InputHelper.Tap(showCommandBarFlyoutButton);

                Log.Comment("Retrieving the undo button's automation element object.");
                FindElement.ById("UndoButton6").SetFocus();
                Wait.ForIdle();
                var undoButtonElement = AutomationElement.FocusedElement;

                Log.Comment("Verifying that the undo button does not point at the more button using FlowsFrom.");
                var flowsFromCollection = (AutomationElementCollection)undoButtonElement.GetCurrentPropertyValue(AutomationProperty.LookupById(UIA_FlowsFromPropertyId));
                Verify.AreEqual(0, flowsFromCollection.Count);

                Log.Comment("Tapping on a button to hide the CommandBarFlyout.");
                InputHelper.Tap(showCommandBarFlyoutButton);
            }
        }
        // Returns a given property
        // UIAutomation as a generic call for all the properties for all the patterns.
        // This routine splits properties per pattern and calls the appropriate routine
        // within a pattern.
        // A default implementation is provided for some properties
        object IRawElementProviderSimple.GetPropertyValue(int propertyId)
        {
            AutomationProperty idProp = AutomationProperty.LookupById(propertyId);

            return(GetElementProperty(idProp));
        }
        public void VerifyFlowsToAndFromConnectsPrimaryAndSecondaryCommandsWithAlwaysExpanded()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Button showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout with AlwaysExpanded");

                Log.Comment("Tapping on a button to show the CommandBarFlyout.");
                showCommandBarFlyoutButton.InvokeAndWait();

                Log.Comment("Press Right key to move focus to last primary command: Underline.");
                for (int i = 0; i < 5; i++)
                {
                    KeyboardHelper.PressKey(Key.Right);
                    Wait.ForIdle();
                }

                Button underlineButton9       = FindElement.ById <Button>("UnderlineButton9");
                var    underlineButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(underlineButtonElement.Current.AutomationId, underlineButton9.AutomationId);

                // Moving to the Undo button to retrieve it
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();

                Button undoButton9       = FindElement.ById <Button>("UndoButton9");
                var    undoButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(undoButtonElement.Current.AutomationId, undoButton9.AutomationId);

                Log.Comment("Verifying that the two elements point at each other using FlowsTo and FlowsFrom.");
                var flowsToCollection = (AutomationElementCollection)underlineButtonElement.GetCurrentPropertyValue(AutomationProperty.LookupById(UIA_FlowsToPropertyId));

                Verify.AreEqual(1, flowsToCollection.Count);
                Verify.AreEqual(undoButtonElement, flowsToCollection[0]);

                var flowsFromCollection = (AutomationElementCollection)undoButtonElement.GetCurrentPropertyValue(AutomationProperty.LookupById(UIA_FlowsFromPropertyId));

                Verify.AreEqual(1, flowsFromCollection.Count);
                Verify.AreEqual(underlineButtonElement, flowsFromCollection[0]);

                Log.Comment("Tapping on a button to hide the CommandBarFlyout.");
                InputHelper.Tap(showCommandBarFlyoutButton);
            }
        }
Esempio n. 16
0
 public object GetPropertyValue(int propertyId)
 {
     return(AutomationProperty.LookupById(propertyId));
 }