public virtual void TreeViewItemPeerScroll()
        {
            TreeView view = new TreeView {
                Height = 20, ItemsSource = new int[] { 1, 2, 3, 4, 5 }
            };
            TreeViewItem item = null;
            TreeViewItemAutomationPeer peer     = null;
            IScrollItemProvider        provider = null;

            TestAsync(
                5,
                view,
                () => item     = view.ItemContainerGenerator.ContainerFromIndex(4) as TreeViewItem,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as TreeViewItemAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ScrollItem) as IScrollItemProvider,
                () => provider.ScrollIntoView(),
                () =>
            {
                foreach (DependencyObject obj in view.GetVisualDescendents())
                {
                    ScrollViewer viewer = obj as ScrollViewer;
                    if (viewer != null)
                    {
                        Assert.AreNotEqual(0, viewer.VerticalOffset, "ScrollHost was not scrolled!");
                        return;
                    }
                }
                Assert.Fail("Did not find the ScrollHost!");
            });
        }
예제 #2
0
        private readonly ITextProvider2 publicITextProvider2;                                      // AccessibleObject as ITextProvider2

        /// <summary>
        ///  Create a new wrapper.
        /// </summary>
        internal InternalAccessibleObject(AccessibleObject accessibleImplemention)
        {
            // Get all the casts done here to catch any issues early
            publicIAccessible                     = (IAccessible)accessibleImplemention;
            publicIEnumVariant                    = (Oleaut32.IEnumVariant)accessibleImplemention;
            publicIOleWindow                      = (Ole32.IOleWindow)accessibleImplemention;
            publicIReflect                        = (IReflect)accessibleImplemention;
            publicIServiceProvider                = (Ole32.IServiceProvider)accessibleImplemention;
            publicIAccessibleEx                   = (IAccessibleEx)accessibleImplemention;
            publicIRawElementProviderSimple       = (IRawElementProviderSimple)accessibleImplemention;
            publicIRawElementProviderFragment     = (IRawElementProviderFragment)accessibleImplemention;
            publicIRawElementProviderFragmentRoot = (IRawElementProviderFragmentRoot)accessibleImplemention;
            publicIInvokeProvider                 = (IInvokeProvider)accessibleImplemention;
            publicIValueProvider                  = (IValueProvider)accessibleImplemention;
            publicIRangeValueProvider             = (IRangeValueProvider)accessibleImplemention;
            publicIExpandCollapseProvider         = (IExpandCollapseProvider)accessibleImplemention;
            publicIToggleProvider                 = (IToggleProvider)accessibleImplemention;
            publicITableProvider                  = (ITableProvider)accessibleImplemention;
            publicITableItemProvider              = (ITableItemProvider)accessibleImplemention;
            publicIGridProvider                   = (IGridProvider)accessibleImplemention;
            publicIGridItemProvider               = (IGridItemProvider)accessibleImplemention;
            publicILegacyIAccessibleProvider      = (ILegacyIAccessibleProvider)accessibleImplemention;
            publicISelectionProvider              = (ISelectionProvider)accessibleImplemention;
            publicISelectionItemProvider          = (ISelectionItemProvider)accessibleImplemention;
            publicIScrollItemProvider             = (IScrollItemProvider)accessibleImplemention;
            publicIRawElementProviderHwndOverride = (IRawElementProviderHwndOverride)accessibleImplemention;
            publicIMultiViewProvider              = (IMultipleViewProvider)accessibleImplemention;
            publicITextProvider                   = (ITextProvider)accessibleImplemention;
            publicITextProvider2                  = (ITextProvider2)accessibleImplemention;
            // Note: Deliberately not holding onto AccessibleObject to enforce all access through the interfaces
        }
        public virtual void TreeViewItemPeerIsIScrollItemProvider()
        {
            TreeViewItem        item     = new TreeViewItem();
            IScrollItemProvider provider = null;

            TestAsync(
                item,
                () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as IScrollItemProvider,
                () => Assert.IsNotNull(provider, "TreeViewItemAutomationPeer should implement IScrollItemProvider!"));
        }
예제 #4
0
        /// <summary>Scrolls the content area of a container object in order to display the control within the visible region (viewport) of the container.</summary>
        // Token: 0x0600287B RID: 10363 RVA: 0x000BC808 File Offset: 0x000BAA08
        void IScrollItemProvider.ScrollIntoView()
        {
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = this.GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                IScrollItemProvider scrollItemProvider = treeViewItemAutomationPeer;
                scrollItemProvider.ScrollIntoView();
                return;
            }
            this.RecursiveScrollIntoView();
        }
        public virtual void TreeViewItemPeerScrollNoParent()
        {
            TreeViewItem item = new TreeViewItem();
            TreeViewItemAutomationPeer peer     = null;
            IScrollItemProvider        provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as TreeViewItemAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ScrollItem) as IScrollItemProvider,
                () => provider.ScrollIntoView());
        }
        public virtual void TreeViewItemPeerSupportsScroll()
        {
            TreeViewItem item = new TreeViewItem();
            TreeViewItemAutomationPeer peer     = null;
            IScrollItemProvider        provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as TreeViewItemAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ScrollItem) as IScrollItemProvider,
                () => Assert.IsNotNull(provider, "IScrollItemProvider peer should not be null!"));
        }
        void IScrollItemProvider.ScrollIntoView()
        {
            TreeViewItemAutomationPeer wrapperPeer = GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (wrapperPeer != null)
            {
                IScrollItemProvider iScrollItemProvider = wrapperPeer as IScrollItemProvider;
                iScrollItemProvider.ScrollIntoView();
            }
            else
            {
                RecursiveScrollIntoView();
            }
        }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
 
        #region Constructors

        private ScrollItemProviderWrapper(AutomationPeer peer, IScrollItemProvider iface)
        {
            _peer = peer;
            _iface = iface;
        }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        private ScrollItemProviderWrapper(AutomationPeer peer, IScrollItemProvider iface)
        {
            _peer  = peer;
            _iface = iface;
        }
예제 #10
0
		internal ScrollItemPattern (IScrollItemProvider source)
		{
			this.source = source;
		}
예제 #11
0
		public ScrollItemPatternWrapper (IScrollItemProvider provider)
		{
			this.provider = provider;
		}
예제 #12
0
 public ScrollItemPatternWrapper(IScrollItemProvider provider)
 {
     this.provider = provider;
 }
예제 #13
0
 internal ScrollItemPattern(IScrollItemProvider source)
 {
     this.source = source;
 }
예제 #14
0
        public void BasicItemPropertiesTest()
        {
            ListBox listbox = new ListBox();

            listbox.Items.Add("test");

            IRawElementProviderFragmentRoot rootProvider;
            ISelectionProvider          selectionProvider;
            IRawElementProviderFragment child;

            rootProvider = (IRawElementProviderFragmentRoot)GetProviderFromControl(listbox);

            selectionProvider = rootProvider.GetPatternProvider(SelectionPatternIdentifiers.Pattern.Id) as ISelectionProvider;
            Assert.IsNotNull(selectionProvider, "Selection Provider for ListBox");

            child = rootProvider.Navigate(NavigateDirection.FirstChild);

            TestProperty(child,
                         AutomationElementIdentifiers.ControlTypeProperty,
                         ControlType.ListItem.Id);

            TestProperty(child,
                         AutomationElementIdentifiers.LocalizedControlTypeProperty,
                         "list item");

            TestProperty(child,
                         AutomationElementIdentifiers.IsKeyboardFocusableProperty,
                         true);

            //By default ListItem supports: SelectionItemPattern and ScrollItemPattern
            ISelectionItemProvider selectionItem =
                child.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id) as ISelectionItemProvider;

            Assert.IsNotNull(selectionItem, "ListItem should ALWAYS SUPPORT SelectionItem");


            IScrollProvider scroll
                = rootProvider.GetPatternProvider(ScrollPatternIdentifiers.Pattern.Id) as IScrollProvider;

            if (scroll != null)
            {
                IScrollItemProvider scrollItem =
                    child.GetPatternProvider(ScrollItemPatternIdentifiers.Pattern.Id) as IScrollItemProvider;
                Assert.IsNotNull(scrollItem, "ListItem should ALWAYS SUPPORT ScrollItem");
            }

            IToggleProvider toggleItem =
                child.GetPatternProvider(TogglePatternIdentifiers.Pattern.Id) as IToggleProvider;

            Assert.IsNull(toggleItem, "ListItem SHOULD NOT SUPPORT Toggletlge");

            bridge.ResetEventLists();
            selectionItem.AddToSelection();

            //Testing events.

            Assert.AreEqual(1,
                            bridge.GetAutomationPropertyEventCount(SelectionItemPatternIdentifiers.IsSelectedProperty),
                            "SelectionItemPatternIdentifiers.IsSelectedProperty");

            Assert.AreEqual(1,
                            bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent),
                            "SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent");

            bridge.ResetEventLists();
            selectionItem.RemoveFromSelection();

            Assert.AreEqual(1,
                            bridge.GetAutomationPropertyEventCount(SelectionItemPatternIdentifiers.IsSelectedProperty),
                            "SelectionItemPatternIdentifiers.IsSelectedProperty");

            Assert.AreEqual(0,
                            bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent),
                            "SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent");

            bridge.ResetEventLists();
            //Lets add a new item in listbox

            listbox.SelectionMode = SelectionMode.MultiSimple;
            listbox.Items.Add("test 2");

            selectionItem.AddToSelection();

            //Get 2nd child
            IRawElementProviderFragment child2nd = child.Navigate(NavigateDirection.NextSibling);

            ISelectionItemProvider selectionItem2
                = child2nd.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id) as ISelectionItemProvider;

            Assert.IsNotNull(selectionItem2, "ListItem should ALWAYS SUPPORT SelectionItem");

            selectionItem2.AddToSelection();

            Assert.AreEqual(1,
                            bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent),
                            "SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent");
            Assert.AreEqual(2,
                            bridge.GetAutomationPropertyEventCount(SelectionItemPatternIdentifiers.IsSelectedProperty),
                            "SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent");
            Assert.AreEqual(1,
                            bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent),
                            "SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent");
        }
예제 #15
0
        public void BasicItemPropertiesTest()
        {
            CheckedListBox listbox = (CheckedListBox)GetControlInstance();

            listbox.Items.Add("1");

            IRawElementProviderFragmentRoot rootProvider;
            ISelectionProvider          selectionProvider;
            IRawElementProviderFragment child;
            IToggleProvider             toggleProvider1;
            IToggleProvider             toggleProvider2;
            IRawElementProviderFragment child2;

            rootProvider = (IRawElementProviderFragmentRoot)GetProviderFromControl(listbox);
            child        = rootProvider.Navigate(NavigateDirection.FirstChild);

            TestProperty(child,
                         AutomationElementIdentifiers.ControlTypeProperty,
                         ControlType.ListItem.Id);

            TestProperty(child,
                         AutomationElementIdentifiers.LocalizedControlTypeProperty,
                         "list item");

            TestProperty(child,
                         AutomationElementIdentifiers.IsContentElementProperty,
                         true);

            TestProperty(child,
                         AutomationElementIdentifiers.IsControlElementProperty,
                         true);

            TestProperty(child,
                         AutomationElementIdentifiers.IsKeyboardFocusableProperty,
                         true);

            // Should support selection
            selectionProvider = rootProvider.GetPatternProvider(SelectionPatternIdentifiers.Pattern.Id) as ISelectionProvider;
            Assert.IsNotNull(selectionProvider, "Selection Pattern in SelectionItem");

            // TODO: add more selection-related tests

            //Should support Toggle
            toggleProvider1 = child.GetPatternProvider(TogglePatternIdentifiers.Pattern.Id) as IToggleProvider;
            Assert.IsNotNull(toggleProvider1, "Toggle Pattern in SelectionItem");

            Assert.AreEqual(toggleProvider1.ToggleState, ToggleState.Off);
            toggleProvider1.Toggle();
            Assert.AreEqual(toggleProvider1.ToggleState, ToggleState.On);
            toggleProvider1.Toggle();
            Assert.AreEqual(toggleProvider1.ToggleState, ToggleState.Off);

            //By default ListItem supports: SelectionItemPattern and ScrollItemPattern
            ISelectionItemProvider selectionItem =
                child.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id) as ISelectionItemProvider;

            Assert.IsNotNull(selectionItem, "ListItem should ALWAYS SUPPORT SelectionItem");

            IScrollProvider scroll
                = rootProvider.GetPatternProvider(ScrollPatternIdentifiers.Pattern.Id) as IScrollProvider;

            if (scroll != null)
            {
                IScrollItemProvider scrollItem =
                    child.GetPatternProvider(ScrollItemPatternIdentifiers.Pattern.Id) as IScrollItemProvider;
                Assert.IsNotNull(scrollItem, "ListItem should ALWAYS SUPPORT ScrollItem");
            }

            IToggleProvider toggleItem =
                child.GetPatternProvider(TogglePatternIdentifiers.Pattern.Id) as IToggleProvider;

            Assert.IsNotNull(toggleItem, "ListItem show ALWAYS SUPPORT Toggle");

            //Add new item
            child2 = child.Navigate(NavigateDirection.NextSibling);
            Assert.IsNull(child2, "Child2 should be NULL");

            listbox.Items.Add("2");
            child2 = child.Navigate(NavigateDirection.NextSibling);
            Assert.IsNotNull(child2, "Child2 is NULL");

            toggleProvider2 = (IToggleProvider)child2.GetPatternProvider(TogglePatternIdentifiers.Pattern.Id);
            Assert.AreEqual(toggleProvider2.ToggleState, ToggleState.Off);
            toggleProvider2.Toggle();
            Assert.AreEqual(toggleProvider2.ToggleState, ToggleState.On);
            toggleProvider2.Toggle();
            Assert.AreEqual(toggleProvider2.ToggleState, ToggleState.Off);
        }