Bugzilla – Attachment 257630 Details for
Bug 428759
ToolBar: Begin implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
patch uploaded.
toolbar.patch (text/plain), 23.55 KB, created by
Neville Gao
on 2008-12-03 10:03:02 UTC
(
hide
)
Description:
patch uploaded.
Filename:
MIME Type:
Creator:
Neville Gao
Created:
2008-12-03 10:03:02 UTC
Size:
23.55 KB
patch
obsolete
>Index: UIAutomationWinforms/Mono.UIAutomation.Winforms.mdp >=================================================================== >--- UIAutomationWinforms/Mono.UIAutomation.Winforms.mdp (revision 120577) >+++ UIAutomationWinforms/Mono.UIAutomation.Winforms.mdp (working copy) >@@ -279,6 +279,10 @@ > <File name="Mono.UIAutomation.Winforms.Events/TabPage/SelectionItemPatternElementRemovedEvent.cs" subtype="Code" buildaction="Compile" /> > <File name="Mono.UIAutomation.Winforms.Events/TabPage/SelectionItemPatternElementSelectedEvent.cs" subtype="Code" buildaction="Compile" /> > <File name="Mono.UIAutomation.Winforms/MonthCalendarProvider.cs" subtype="Code" buildaction="Compile" /> >+ <File name="Mono.UIAutomation.Winforms/ToolBarProvider.cs" subtype="Code" buildaction="Compile" /> >+ <File name="Mono.UIAutomation.Winforms.Behaviors/ToolBar/ToolBarButtonInvokeProviderBehavior.cs" subtype="Code" buildaction="Compile" /> >+ <File name="Mono.UIAutomation.Winforms.Events/ToolBar" subtype="Directory" buildaction="Compile" /> >+ <File name="Mono.UIAutomation.Winforms.Events/ToolBar/ToolBarButtonInvokePatternInvokedEvent.cs" subtype="Code" buildaction="Compile" /> > </Contents> > <References> > <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> >Index: UIAutomationWinforms/Makefile.am >=================================================================== >--- UIAutomationWinforms/Makefile.am (revision 120577) >+++ UIAutomationWinforms/Makefile.am (working copy) >@@ -102,6 +102,7 @@ > Mono.UIAutomation.Winforms.Behaviors/TextBox/ScrollProviderBehavior.cs \ > Mono.UIAutomation.Winforms.Behaviors/TextBox/TextProviderBehavior.cs \ > Mono.UIAutomation.Winforms.Behaviors/TextBox/ValueProviderBehavior.cs \ >+ Mono.UIAutomation.Winforms.Behaviors/ToolBar/ToolBarButtonInvokeProviderBehavior.cs \ > Mono.UIAutomation.Winforms.Behaviors/ToolStripItem/InvokeProviderBehavior.cs \ > Mono.UIAutomation.Winforms.Behaviors/ToolStripSplitButton/ExpandCollapseProviderBehavior.cs \ > Mono.UIAutomation.Winforms.Behaviors/UpDownBase/ButtonInvokeProviderBehavior.cs \ >@@ -218,6 +219,7 @@ > Mono.UIAutomation.Winforms.Events/TextBox/HasKeyBoardFocusPropertyEvent.cs \ > Mono.UIAutomation.Winforms.Events/TextBox/ValuePatternValueIsReadOnlyEvent.cs \ > Mono.UIAutomation.Winforms.Events/TextBox/ValuePatternValueValueEvent.cs \ >+ Mono.UIAutomation.Winforms.Events/ToolBar/ToolBarButtonInvokePatternInvokedEvent.cs \ > Mono.UIAutomation.Winforms.Events/ToolStripItem/AutomationBoundingRectanglePropertyEvent.cs \ > Mono.UIAutomation.Winforms.Events/ToolStripItem/AutomationFocusChangedEvent.cs \ > Mono.UIAutomation.Winforms.Events/ToolStripItem/AutomationHasKeyboardFocusPropertyEvent.cs \ >@@ -292,6 +294,7 @@ > Mono.UIAutomation.Winforms/TextNormalizer.cs \ > Mono.UIAutomation.Winforms/TextNormalizerPoints.cs \ > Mono.UIAutomation.Winforms/TextRangeProvider.cs \ >+ Mono.UIAutomation.Winforms/ToolBarProvider.cs \ > Mono.UIAutomation.Winforms/ToolStripComboBoxProvider.cs \ > Mono.UIAutomation.Winforms/ToolStripDropDownItemProvider.cs \ > Mono.UIAutomation.Winforms/ToolStripItemProvider.cs \ >Index: UIAutomationWinforms/Mono.UIAutomation.Winforms/ProviderFactory.cs >=================================================================== >--- UIAutomationWinforms/Mono.UIAutomation.Winforms/ProviderFactory.cs (revision 120577) >+++ UIAutomationWinforms/Mono.UIAutomation.Winforms/ProviderFactory.cs (working copy) >@@ -111,6 +111,7 @@ > SWF.MonthCalendar mc; > SWF.SplitContainer sc; > SWF.Splitter s; >+ SWF.ToolBar tb; > > SWF.StatusStrip ss; > SWF.MenuStrip ms; >@@ -226,6 +227,8 @@ > provider = new SplitContainerProvider (sc); > else if ((s = component as SWF.Splitter) != null) > provider = new SplitterProvider (s); >+ else if ((tb = component as SWF.ToolBar) != null) >+ provider = new ToolBarProvider (tb); > else { > //TODO: We have to solve the problem when there's a Custom control > // Ideally the first thing we do is send a wndproc message to >Index: UIAutomationWinforms/Mono.UIAutomation.Winforms/ToolBarProvider.cs >=================================================================== >--- UIAutomationWinforms/Mono.UIAutomation.Winforms/ToolBarProvider.cs (revision 0) >+++ UIAutomationWinforms/Mono.UIAutomation.Winforms/ToolBarProvider.cs (revision 0) >@@ -0,0 +1,220 @@ >+// Permission is hereby granted, free of charge, to any person obtaining >+// a copy of this software and associated documentation files (the >+// "Software"), to deal in the Software without restriction, including >+// without limitation the rights to use, copy, modify, merge, publish, >+// distribute, sublicense, and/or sell copies of the Software, and to >+// permit persons to whom the Software is furnished to do so, subject to >+// the following conditions: >+// >+// The above copyright notice and this permission notice shall be >+// included in all copies or substantial portions of the Software. >+// >+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND >+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE >+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION >+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION >+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >+// >+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) >+// >+// Authors: >+// Neville Gao <nevillegao@gmail.com> >+// >+ >+using System; >+using System.ComponentModel; >+using System.Collections.Generic; >+using System.Windows.Forms; >+using System.Windows.Automation; >+using System.Windows.Automation.Provider; >+using Mono.UIAutomation.Winforms.Behaviors; >+using Mono.UIAutomation.Winforms.Behaviors.ToolBar; >+ >+namespace Mono.UIAutomation.Winforms >+{ >+ internal class ToolBarProvider : FragmentRootControlProvider >+ { >+ #region Constructor >+ >+ public ToolBarProvider (ToolBar toolBar) : base (toolBar) >+ { >+ this.toolBar = toolBar; >+ buttons = new List<ToolBarButtonProvider> (); >+ } >+ >+ #endregion >+ >+ #region SimpleControlProvider: Specializations >+ >+ protected override object GetProviderPropertyValue (int propertyId) >+ { >+ if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id) >+ return ControlType.ToolBar.Id; >+ else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id) >+ return "tool bar"; >+ else if (propertyId == AutomationElementIdentifiers.NameProperty.Id) >+ return toolBar.Text; >+ else >+ return base.GetProviderPropertyValue (propertyId); >+ } >+ >+ #endregion >+ >+ #region FragmentRootControlProvider: Specializations >+ >+ public override void InitializeChildControlStructure () >+ { >+ try { >+ Helper.AddPrivateEvent (typeof (ToolBar.ToolBarButtonCollection), >+ toolBar.Buttons, >+ "UIACollectionChanged", >+ this, >+ "OnCollectionChanged"); >+ } catch (NotSupportedException) { } >+ >+ for (int i = 0; i < toolBar.Buttons.Count; ++i) { >+ ToolBarButtonProvider button = GetButtonProvider (i); >+ OnNavigationChildAdded (false, button); >+ } >+ } >+ >+ public override void FinalizeChildControlStructure () >+ { >+ try { >+ Helper.RemovePrivateEvent (typeof (ToolBar.ToolBarButtonCollection), >+ toolBar.Buttons, >+ "UIACollectionChanged", >+ this, >+ "OnCollectionChanged"); >+ } catch (NotSupportedException) { } >+ >+ foreach (ToolBarButtonProvider button in buttons) >+ OnNavigationChildRemoved (false, button); >+ OnNavigationChildrenCleared (false); >+ } >+ >+ #endregion >+ >+ #region Public Methods >+ >+ public ToolBarButtonProvider GetButtonProvider (int index) >+ { >+ ToolBarButtonProvider button = null; >+ >+ if (index < 0 || index >= toolBar.Buttons.Count) >+ return null; >+ else if (index >= buttons.Count) { >+ for (int loop = buttons.Count - 1; loop < index; ++loop) { >+ button = new ToolBarButtonProvider (toolBar.Buttons [index]); >+ buttons.Add (button); >+ button.Initialize (); >+ } >+ } >+ >+ return buttons [index]; >+ } >+ >+ public ToolBarButtonProvider RemoveButtonAt (int index) >+ { >+ ToolBarButtonProvider button = null; >+ >+ if (index < buttons.Count) { >+ button = buttons [index]; >+ buttons.RemoveAt (index); >+ button.Terminate (); >+ } >+ >+ return button; >+ } >+ >+ public void ClearButtonsCollection () >+ { >+ while (buttons.Count > 0) { >+ RemoveButtonAt (buttons.Count - 1); >+ } >+ } >+ >+ #endregion >+ >+ #region Private Methods >+ >+ #pragma warning disable 169 >+ >+ private void OnCollectionChanged (object sender, CollectionChangeEventArgs e) >+ { >+ if (e.Action == CollectionChangeAction.Add) { >+ ToolBarButtonProvider button = GetButtonProvider ((int) e.Element); >+ OnNavigationChildAdded (true, button); >+ } else if (e.Action == CollectionChangeAction.Remove) { >+ ToolBarButtonProvider button = RemoveButtonAt ((int) e.Element); >+ OnNavigationChildRemoved (true, button); >+ } else if (e.Action == CollectionChangeAction.Refresh) { >+ ClearButtonsCollection (); >+ OnNavigationChildrenCleared (true); >+ } >+ } >+ >+ #pragma warning restore 169 >+ >+ #endregion >+ >+ #region Private Fields >+ >+ private ToolBar toolBar; >+ private List<ToolBarButtonProvider> buttons; >+ >+ #endregion >+ >+ #region Internal Class: ToolBarButton Provider >+ >+ internal class ToolBarButtonProvider : FragmentControlProvider >+ { >+ #region Constructor >+ >+ public ToolBarButtonProvider (ToolBarButton toolBarButton) : base (toolBarButton) >+ { >+ this.toolBarButton = toolBarButton; >+ } >+ >+ #endregion >+ >+ #region SimpleControlProvider: Specializations >+ >+ public override void Initialize () >+ { >+ base.Initialize (); >+ >+ SetBehavior (InvokePatternIdentifiers.Pattern, >+ new ToolBarButtonInvokeProviderBehavior (this)); >+ } >+ >+ #endregion >+ >+ #region Public Methods >+ >+ protected override object GetProviderPropertyValue (int propertyId) >+ { >+ if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id) >+ return ControlType.MenuItem.Id; >+ else if (propertyId == AutomationElementIdentifiers.LocalizedControlTypeProperty.Id) >+ return "menu item"; >+ else if (propertyId == AutomationElementIdentifiers.NameProperty.Id) >+ return toolBarButton.Text; >+ else >+ return base.GetProviderPropertyValue (propertyId); >+ } >+ >+ #endregion >+ >+ #region Private Fields >+ >+ private ToolBarButton toolBarButton; >+ >+ #endregion >+ } >+ >+ #endregion >+ } >+} >Index: UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolBar/ToolBarButtonInvokeProviderBehavior.cs >=================================================================== >--- UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolBar/ToolBarButtonInvokeProviderBehavior.cs (revision 0) >+++ UIAutomationWinforms/Mono.UIAutomation.Winforms.Behaviors/ToolBar/ToolBarButtonInvokeProviderBehavior.cs (revision 0) >@@ -0,0 +1,76 @@ >+// Permission is hereby granted, free of charge, to any person obtaining >+// a copy of this software and associated documentation files (the >+// "Software"), to deal in the Software without restriction, including >+// without limitation the rights to use, copy, modify, merge, publish, >+// distribute, sublicense, and/or sell copies of the Software, and to >+// permit persons to whom the Software is furnished to do so, subject to >+// the following conditions: >+// >+// The above copyright notice and this permission notice shall be >+// included in all copies or substantial portions of the Software. >+// >+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND >+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE >+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION >+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION >+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >+// >+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) >+// >+// Authors: >+// Neville Gao <nevillegao@gmail.com> >+// >+ >+using System; >+using System.Windows.Automation; >+using System.Windows.Automation.Provider; >+using SWF = System.Windows.Forms; >+using Mono.UIAutomation.Winforms; >+using Mono.UIAutomation.Winforms.Events; >+using Mono.UIAutomation.Winforms.Events.ToolBar; >+ >+namespace Mono.UIAutomation.Winforms.Behaviors.ToolBar >+{ >+ internal class ToolBarButtonInvokeProviderBehavior : ProviderBehavior, IInvokeProvider >+ { >+ #region Constructor >+ >+ public ToolBarButtonInvokeProviderBehavior (ToolBarProvider.ToolBarButtonProvider provider) >+ : base (provider) >+ { >+ } >+ >+ #endregion >+ >+ #region IProviderBehavior Interface >+ >+ public override AutomationPattern ProviderPattern { >+ get { return InvokePatternIdentifiers.Pattern; } >+ } >+ >+ public override void Connect () >+ { >+ Provider.SetEvent (ProviderEventType.InvokePatternInvokedEvent, >+ new ToolBarButtonInvokePatternInvokedEvent (Provider)); >+ } >+ >+ public override void Disconnect () >+ { >+ Provider.SetEvent (ProviderEventType.InvokePatternInvokedEvent, >+ null); >+ } >+ >+ #endregion >+ >+ #region IInvokeProvider Members >+ >+ public void Invoke () >+ { >+ // TODO: >+ } >+ >+ #endregion >+ } >+} >Index: UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ToolBar/ToolBarButtonInvokePatternInvokedEvent.cs >=================================================================== >--- UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ToolBar/ToolBarButtonInvokePatternInvokedEvent.cs (revision 0) >+++ UIAutomationWinforms/Mono.UIAutomation.Winforms.Events/ToolBar/ToolBarButtonInvokePatternInvokedEvent.cs (revision 0) >@@ -0,0 +1,74 @@ >+// Permission is hereby granted, free of charge, to any person obtaining >+// a copy of this software and associated documentation files (the >+// "Software"), to deal in the Software without restriction, including >+// without limitation the rights to use, copy, modify, merge, publish, >+// distribute, sublicense, and/or sell copies of the Software, and to >+// permit persons to whom the Software is furnished to do so, subject to >+// the following conditions: >+// >+// The above copyright notice and this permission notice shall be >+// included in all copies or substantial portions of the Software. >+// >+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND >+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE >+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION >+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION >+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >+// >+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) >+// >+// Authors: >+// Neville Gao <nevillegao@gmail.com> >+// >+ >+using System; >+using System.Windows.Automation; >+using System.Windows.Automation.Provider; >+using SWF = System.Windows.Forms; >+using Mono.UIAutomation.Winforms.Events; >+ >+namespace Mono.UIAutomation.Winforms.Events.ToolBar >+{ >+ internal class ToolBarButtonInvokePatternInvokedEvent : BaseAutomationEvent >+ { >+ #region Constructor >+ >+ public ToolBarButtonInvokePatternInvokedEvent (SimpleControlProvider provider) >+ : base (provider, InvokePatternIdentifiers.InvokedEvent) >+ { >+ } >+ >+ #endregion >+ >+ #region IConnectable Overrides >+ >+ public override void Connect () >+ { >+// ((SWF.ToolBar) Provider.Control).ButtonClick += >+// new SWF.ToolBarButtonClickEventHandler (OnButtonClick); >+ } >+ >+ public override void Disconnect () >+ { >+// ((SWF.ToolBar) Provider.Control).ButtonClick -= >+// new SWF.ToolBarButtonClickEventHandler (OnButtonClick); >+ } >+ >+ #endregion >+ >+ #region Private Methods >+ >+ #pragma warning disable 169 >+ >+ private void OnButtonClick (object sender, SWF.ToolBarButtonClickEventArgs e) >+ { >+ RaiseAutomationEvent (); >+ } >+ >+ #pragma warning restore 169 >+ >+ #endregion >+ } >+} >Index: UIAutomationWinformsTests/UIAutomationWinformsTests.mdp >=================================================================== >--- UIAutomationWinformsTests/UIAutomationWinformsTests.mdp (revision 120577) >+++ UIAutomationWinformsTests/UIAutomationWinformsTests.mdp (working copy) >@@ -58,6 +58,8 @@ > <File name="TextBoxBaseProviderTest.cs" subtype="Code" buildaction="Compile" /> > <File name="SplitContainerProviderTest.cs" subtype="Code" buildaction="Compile" /> > <File name="SplitterProviderTest.cs" subtype="Code" buildaction="Compile" /> >+ <File name="MonthCalendarProviderTest.cs" subtype="Code" buildaction="Compile" /> >+ <File name="ToolBarProviderTest.cs" subtype="Code" buildaction="Compile" /> > </Contents> > <References> > <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> >Index: UIAutomationWinformsTests/Makefile.am >=================================================================== >--- UIAutomationWinformsTests/Makefile.am (revision 120577) >+++ UIAutomationWinformsTests/Makefile.am (working copy) >@@ -87,6 +87,7 @@ > TextBoxBaseProviderTest.cs \ > TextBoxProviderTest.cs \ > TextRangeProviderTest.cs \ >+ ToolBarProviderTest.cs \ > ToolStripComboBoxProviderTest.cs \ > ToolStripDropDownItemProviderTest.cs \ > ToolStripLabelProviderTest.cs \ >Index: UIAutomationWinformsTests/ToolBarProviderTest.cs >=================================================================== >--- UIAutomationWinformsTests/ToolBarProviderTest.cs (revision 0) >+++ UIAutomationWinformsTests/ToolBarProviderTest.cs (revision 0) >@@ -0,0 +1,168 @@ >+// Permission is hereby granted, free of charge, to any person obtaining >+// a copy of this software and associated documentation files (the >+// "Software"), to deal in the Software without restriction, including >+// without limitation the rights to use, copy, modify, merge, publish, >+// distribute, sublicense, and/or sell copies of the Software, and to >+// permit persons to whom the Software is furnished to do so, subject to >+// the following conditions: >+// >+// The above copyright notice and this permission notice shall be >+// included in all copies or substantial portions of the Software. >+// >+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND >+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE >+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION >+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION >+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >+// >+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) >+// >+// Authors: >+// Neville Gao <nevillegao@gmail.com> >+// >+ >+using System; >+using System.Collections.Generic; >+using System.Windows.Forms; >+using System.Windows.Automation; >+using System.Windows.Automation.Provider; >+using Mono.UIAutomation.Winforms; >+using NUnit.Framework; >+ >+namespace MonoTests.Mono.UIAutomation.Winforms >+{ >+ [TestFixture] >+ public class ToolBarProviderTest : BaseProviderTest >+ { >+ #region Test >+ >+ [Test] >+ public void BasicPropertiesTest () >+ { >+ ToolBar toolBar = new ToolBar (); >+ IRawElementProviderSimple provider = >+ ProviderFactory.GetProvider (toolBar); >+ >+ TestProperty (provider, >+ AutomationElementIdentifiers.ControlTypeProperty, >+ ControlType.ToolBar.Id); >+ >+ TestProperty (provider, >+ AutomationElementIdentifiers.LocalizedControlTypeProperty, >+ "tool bar"); >+ >+ string value = "ToolBar Name Property"; >+ toolBar.Text = value; >+ TestProperty (provider, >+ AutomationElementIdentifiers.NameProperty, >+ value); >+ } >+ >+ #endregion >+ >+ #region Navigation Test >+ >+ [Test] >+ public void NavigationTest () >+ { >+ ToolBar toolBar = (ToolBar) GetControlInstance (); >+ IRawElementProviderFragmentRoot rootProvider; >+ IRawElementProviderFragment childProvider; >+ IRawElementProviderFragment childParent; >+ >+ rootProvider = (IRawElementProviderFragmentRoot) GetProviderFromControl (toolBar); >+ >+ int index = 0, elements = 10; >+ string name = string.Empty; >+ for (; index < elements; ++index) >+ toolBar.Buttons.Add (string.Format ("Button: {0}", index)); >+ index = 0; >+ >+ childProvider = rootProvider.Navigate (NavigateDirection.FirstChild); >+ Assert.IsNotNull (childProvider, "We must have a child"); >+ >+ do { >+ childParent = childProvider.Navigate (NavigateDirection.Parent); >+ Assert.AreSame (rootProvider, childParent, >+ "Each child must have same parent"); >+ name = (string) childProvider.GetPropertyValue (AutomationElementIdentifiers.NameProperty.Id); >+ Assert.AreEqual (string.Format ("Button: {0}", index++), >+ name, "Different names"); >+ childProvider = childProvider.Navigate (NavigateDirection.NextSibling); >+ } while (childProvider != null); >+ Assert.AreEqual (elements, index, "Elements Added = Elements Navigated"); >+ >+ toolBar.Buttons.Clear (); >+ >+ childProvider = rootProvider.Navigate (NavigateDirection.FirstChild); >+ Assert.IsNull (childProvider, "We shouldn't have a child"); >+ } >+ >+ #endregion >+ >+ #region ToolBarButton Test >+ >+ [Test] >+ public void ToolBarButtonBasicPropertiesTest () >+ { >+ ToolBar toolBar = new ToolBar (); >+ IRawElementProviderFragmentRoot rootProvider = >+ (IRawElementProviderFragmentRoot) GetProviderFromControl (toolBar); >+ >+ toolBar.Buttons.Add ("Button"); >+ IRawElementProviderFragment childProvider = >+ rootProvider.Navigate (NavigateDirection.FirstChild); >+ >+ TestProperty (childProvider, >+ AutomationElementIdentifiers.ControlTypeProperty, >+ ControlType.MenuItem.Id); >+ >+ TestProperty (childProvider, >+ AutomationElementIdentifiers.LocalizedControlTypeProperty, >+ "menu item"); >+ >+ string value = "ToolBarButton Name Property"; >+ toolBar.Buttons [0].Text = value; >+ TestProperty (childProvider, >+ AutomationElementIdentifiers.NameProperty, >+ value); >+ } >+ >+ [Test] >+ public void ToolBarButtonProviderPatternTest () >+ { >+ ToolBar toolBar = new ToolBar (); >+ IRawElementProviderFragmentRoot rootProvider = >+ (IRawElementProviderFragmentRoot) GetProviderFromControl (toolBar); >+ >+ toolBar.Buttons.Add ("Button"); >+ IRawElementProviderFragment childProvider = >+ rootProvider.Navigate (NavigateDirection.FirstChild); >+ >+ object invokeProvider = >+ childProvider.GetPatternProvider (InvokePatternIdentifiers.Pattern.Id); >+ Assert.IsNotNull (invokeProvider, >+ "Not returning InvokePatternIdentifiers."); >+ Assert.IsTrue (invokeProvider is IInvokeProvider, >+ "Not returning InvokePatternIdentifiers."); >+ } >+ >+ #endregion >+ >+ #region BaseProviderTest Overrides >+ >+ protected override Control GetControlInstance () >+ { >+ return new ToolBar (); >+ } >+ >+ public override void LabeledByAndNamePropertyTest () >+ { >+ TestLabeledByAndName (false, false); >+ } >+ >+ #endregion >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 428759
: 257630 |
264052
|
264690