public bool SetExtents(int x, int y, int width, int height, Atk.CoordType coordType) { if (transformProvider == null) { transformProvider = (ITransformProvider)resource.Provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); } if ((transformProvider != null) && (transformProvider.CanResize) && (transformProvider.CanMove)) { try { transformProvider.Move(x, y); } catch (InvalidOperationException e) { Log.Debug(e); } try { transformProvider.Resize(width, height); } catch (InvalidOperationException e) { Log.Debug(e); } return(true); } return(false); }
public void ResizeTest() { using (Form f = new Form()) { IRawElementProviderFragment provider = (IRawElementProviderFragment) ProviderFactory.GetProvider(f); ITransformProvider transform = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); f.Show(); // To create Handle VerifyResizeFail(f, transform, FormBorderStyle.Fixed3D); VerifyResizeFail(f, transform, FormBorderStyle.FixedDialog); VerifyResizeFail(f, transform, FormBorderStyle.FixedSingle); VerifyResizeFail(f, transform, FormBorderStyle.FixedToolWindow); f.FormBorderStyle = FormBorderStyle.None; transform.Resize(100, 200); Assert.AreEqual(100, f.Width, "Width"); Assert.AreEqual(200, f.Height, "Height"); // Problematic...getting 110 for width! /*f.FormBorderStyle = FormBorderStyle.Sizable; * transform.Resize (35.7, 10); * Assert.AreEqual (36, f.Width, "Width"); * Assert.AreEqual (10, f.Height, "Height");*/ f.FormBorderStyle = FormBorderStyle.SizableToolWindow; transform.Resize(1234, 500.2); Assert.AreEqual(1234, f.Width, "Width"); Assert.AreEqual(500, f.Height, "Height"); } }
public void MoveTest() { using (Form f = new Form()) { IRawElementProviderFragment provider = (IRawElementProviderFragment) ProviderFactory.GetProvider(f); ITransformProvider transform = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); //f.Show (); transform.Move(15, 20); Assert.AreEqual(15, f.Location.X, "X, default form"); Assert.AreEqual(20, f.Location.Y, "Y, default form"); f.WindowState = FormWindowState.Maximized; VerifyMoveFail(f, transform, FormWindowState.Maximized); f.WindowState = FormWindowState.Minimized; VerifyMoveFail(f, transform, FormWindowState.Minimized); f.WindowState = FormWindowState.Normal; transform.Move(150, 100); Assert.AreEqual(150, f.Location.X, "X, normal form"); Assert.AreEqual(100, f.Location.Y, "Y, normal form"); } }
public void SplitterPanelITransformProviderCanResizeTest() { SplitContainer splitContainer = new SplitContainer(); IRawElementProviderFragmentRoot rootProvider = (IRawElementProviderFragmentRoot)GetProviderFromControl(splitContainer); IRawElementProviderFragment childProvider = rootProvider.Navigate(NavigateDirection.FirstChild); ITransformProvider transformProvider = (ITransformProvider) childProvider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); Assert.IsNotNull(transformProvider, "Not returning TransformPatternIdentifiers."); Assert.IsTrue(transformProvider.CanResize, "SplitterPanel can be resized by default."); splitContainer.Panel1Collapsed = true; splitContainer.Panel2Collapsed = false; Assert.IsFalse(transformProvider.CanResize, "SplitterPanel1 can't be resized."); splitContainer.Panel1Collapsed = false; splitContainer.Panel2Collapsed = true; Assert.IsFalse(transformProvider.CanResize, "SplitterPanel2 can't be resized."); }
public void UseAutomationPeer() { Grid g = CreateGrid(2, 2, 100.0, 100.0); GridSplitter splitter = CreateGridSplitterThroughCode(1, 1, 5.0, HorizontalAlignment.Left, null, false); GridSplitterAutomationPeer peer = ((GridSplitterAutomationPeer)GridSplitterAutomationPeer.CreatePeerForElement(splitter)); ITransformProvider transformer = (ITransformProvider)peer.GetPattern(PatternInterface.Transform); g.Children.Add(splitter); this.CreateAsyncTest(g, delegate { Assert.AreEqual(50.0, g.ColumnDefinitions[0].ActualWidth, "Definition1's default width."); Assert.AreEqual(50.0, g.ColumnDefinitions[1].ActualWidth, "Definition2's default width."); }, () => transformer.Move(10, 0), delegate { Assert.AreEqual(AutomationControlType.Thumb, peer.GetAutomationControlType(), "GridSplitter should be a thumb control type."); Assert.AreEqual(splitter.GetType().Name, peer.GetClassName(), "AutomationPeer's ClassName should be 'GridSplitter'"); Assert.AreEqual(transformer.CanMove, true, "GridSplitter can be moved"); Assert.AreEqual(transformer.CanResize, false, "GridSplitter cannot be resized"); Assert.AreEqual(transformer.CanRotate, false, "GridSplitter cannot be rotated"); Assert.AreEqual(60.0, g.ColumnDefinitions[0].ActualWidth, "Definition1's width should have been changed by the peer's move."); Assert.AreEqual(40.0, g.ColumnDefinitions[1].ActualWidth, "Definition2's width should have been changed by the peer's move."); }); }
public void SplitterPanelITransformProviderResizeTest() { SplitContainer splitContainer = new SplitContainer(); IRawElementProviderFragmentRoot rootProvider = (IRawElementProviderFragmentRoot)GetProviderFromControl(splitContainer); IRawElementProviderFragment childProvider = rootProvider.Navigate(NavigateDirection.FirstChild); ITransformProvider transformProvider = (ITransformProvider) childProvider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); Assert.IsNotNull(transformProvider, "Not returning TransformPatternIdentifiers."); try { double width1 = 50, heitht1 = 50; splitContainer.Panel1Collapsed = true; splitContainer.Panel2Collapsed = false; transformProvider.Resize(width1, heitht1); Assert.Fail("InvalidOperationException not thrown"); } catch (InvalidOperationException) { } try { double width2 = 50, heitht2 = 50; splitContainer.Panel1Collapsed = false; splitContainer.Panel2Collapsed = true; transformProvider.Resize(width2, heitht2); Assert.Fail("InvalidOperationException not thrown"); } catch (InvalidOperationException) { } }
public void ITransformProviderVerticalMoveTest() { Splitter splitter = new Splitter(); IRawElementProviderSimple provider = ProviderFactory.GetProvider(splitter); ITransformProvider transformProvider = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); Assert.IsNotNull(transformProvider, "Not returning TransformPatternIdentifiers."); Assert.AreEqual(-1, splitter.SplitPosition, "Splitter doesn't dock to any control"); double x = 50, y = 50; Panel panel = new Panel(); panel.Dock = DockStyle.Left; splitter.Dock = DockStyle.Left; Form.Controls.Add(splitter); Form.Controls.Add(panel); transformProvider.Move(x, y); Assert.AreEqual((int)x, splitter.SplitPosition, "Left position"); panel.Dock = DockStyle.Right; splitter.Dock = DockStyle.Right; transformProvider.Move(x, y); Assert.AreEqual((int)x, splitter.SplitPosition, "Right position"); }
private void VerifyResizeFail(Form f, ITransformProvider transform, FormBorderStyle style) { f.FormBorderStyle = style; try { transform.Resize(10, 10); Assert.Fail("Expected InvalidOperationException"); } catch (InvalidOperationException) { // Expected } catch (Exception e) { Assert.Fail("Expected InvalidOperationException, instead got this exception: " + e.Message); } }
private void VerifyMoveFail(Form f, ITransformProvider transform, FormWindowState state) { f.WindowState = state; try { transform.Move(10, 10); Assert.Fail("Expected InvalidOperationException"); } catch (InvalidOperationException) { // Expected } catch (Exception e) { Assert.Fail("Expected InvalidOperationException, instead got this exception: " + e.Message); } }
public void CanRotateTest() { using (Form f = new Form()) { IRawElementProviderFragment provider = (IRawElementProviderFragment) ProviderFactory.GetProvider(f); ITransformProvider transform = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); Assert.IsFalse(transform.CanRotate, "Should always be false"); } }
public void ITransformProviderCanMoveTest() { Splitter splitter = new Splitter(); IRawElementProviderSimple provider = ProviderFactory.GetProvider(splitter); ITransformProvider transformProvider = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); Assert.IsNotNull(transformProvider, "Not returning TransformPatternIdentifiers."); Assert.IsTrue(transformProvider.CanMove, "Splitter can be moved."); }
public Window (IRawElementProviderSimple provider) : base (provider) { if (provider != null) Role = Atk.Role.Frame; balloonWindow = (bool)(provider.GetPropertyValue (AutomationElementIdentifiers.IsNotifyIconProperty.Id) != null); rootProvider = (IRawElementProviderFragmentRoot) provider; if (rootProvider != null && balloonWindow) { Role = Atk.Role.Alert; Name = (string) provider.GetPropertyValue (AutomationElementIdentifiers.HelpTextProperty.Id); } transformProvider = (ITransformProvider) provider.GetPatternProvider (TransformPatternIdentifiers.Pattern.Id); windowProvider = (IWindowProvider) provider.GetPatternProvider (WindowPatternIdentifiers.Pattern.Id); }
public void SplitterPanelITransformProviderCanRotateTest() { SplitContainer splitContainer = new SplitContainer(); IRawElementProviderFragmentRoot rootProvider = (IRawElementProviderFragmentRoot)GetProviderFromControl(splitContainer); IRawElementProviderFragment childProvider = rootProvider.Navigate(NavigateDirection.FirstChild); ITransformProvider transformProvider = (ITransformProvider) childProvider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); Assert.IsNotNull(transformProvider, "Not returning TransformPatternIdentifiers."); Assert.IsFalse(transformProvider.CanRotate, "SplitterPanel can't be rotated."); }
public void ITransformProviderRotateTest() { Splitter splitter = new Splitter(); IRawElementProviderSimple provider = ProviderFactory.GetProvider(splitter); ITransformProvider transformProvider = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); Assert.IsNotNull(transformProvider, "Not returning TransformPatternIdentifiers."); try { double degrees = 50; transformProvider.Rotate(degrees); Assert.Fail("InvalidOperationException not thrown"); } catch (InvalidOperationException) { } }
public void RotateTest() { using (Form f = new Form()) { IRawElementProviderFragment provider = (IRawElementProviderFragment) ProviderFactory.GetProvider(f); ITransformProvider transform = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); try { transform.Rotate(1); Assert.Fail("Expected InvalidOperationException"); } catch (InvalidOperationException) { // Expected } catch (Exception e) { Assert.Fail("Expected InvalidOperationException, instead got this exception: " + e.Message); } } }
public void ITransformProvider_Methods() { DataGridColumnHeader fe = CreateConcreteFrameworkElement() as DataGridColumnHeader; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); ITransformProvider transform = peer.GetPattern(PatternInterface.Invoke) as ITransformProvider; Assert.IsNotNull(transform, "#0"); Assert.IsFalse(transform.CanMove, "#1"); Assert.IsTrue(transform.CanResize, "#2"); Assert.IsFalse(transform.CanRotate, "#3"); // No errors or exceptions should happen transform.Move(10, 10); transform.Resize(100, 1000); transform.Rotate(10); }
public bool SetSize(int width, int height) { if (transformProvider == null) { transformProvider = (ITransformProvider)resource.Provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); } if ((transformProvider != null) && (transformProvider.CanResize)) { try { transformProvider.Resize(width, height); } catch (InvalidOperationException e) { Log.Debug(e); } return(true); } return(false); }
public Window(IRawElementProviderSimple provider) : base(provider) { if (provider != null) { Role = Atk.Role.Frame; } balloonWindow = (bool)(provider.GetPropertyValue(AutomationElementIdentifiers.IsNotifyIconProperty.Id) != null); rootProvider = (IRawElementProviderFragmentRoot)provider; if (rootProvider != null && balloonWindow) { Role = Atk.Role.Alert; Name = (string)provider.GetPropertyValue(AutomationElementIdentifiers.HelpTextProperty.Id); } transformProvider = (ITransformProvider)provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); windowProvider = (IWindowProvider)provider.GetPatternProvider(WindowPatternIdentifiers.Pattern.Id); }
public void SplitterPanelITransformProviderRotateTest() { SplitContainer splitContainer = new SplitContainer(); IRawElementProviderFragmentRoot rootProvider = (IRawElementProviderFragmentRoot)GetProviderFromControl(splitContainer); IRawElementProviderFragment childProvider = rootProvider.Navigate(NavigateDirection.FirstChild); ITransformProvider transformProvider = (ITransformProvider) childProvider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); Assert.IsNotNull(transformProvider, "Not returning TransformPatternIdentifiers."); try { double degrees = 50; transformProvider.Rotate(degrees); Assert.Fail("InvalidOperationException not thrown"); } catch (InvalidOperationException) { } }
// FIXME: Need to patch SWF.Form.WindowState public void CanMoveTest() { using (Form f = new Form()) { // f.Show (); // To create Handle IRawElementProviderFragment provider = (IRawElementProviderFragment) ProviderFactory.GetProvider(f); ITransformProvider transform = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); //f.Show (); Assert.IsTrue(transform.CanMove, "True by default"); bridge.ResetEventLists(); f.WindowState = FormWindowState.Maximized; // Assert.IsNotNull (bridge.GetAutomationPropertyEventFrom (provider, // TransformPatternIdentifiers.CanMoveProperty.Id), // "CanMoveProperty.0"); Assert.IsFalse(transform.CanMove, "Maximized"); bridge.ResetEventLists(); f.WindowState = FormWindowState.Minimized; // Assert.IsNotNull (bridge.GetAutomationPropertyEventFrom (provider, // TransformPatternIdentifiers.CanMoveProperty.Id), // "CanMoveProperty.1"); Assert.IsFalse(transform.CanMove, "Minimized"); bridge.ResetEventLists(); f.WindowState = FormWindowState.Normal; // Assert.IsNotNull (bridge.GetAutomationPropertyEventFrom (provider, // TransformPatternIdentifiers.CanMoveProperty.Id), // "CanMoveProperty.2"); Assert.IsTrue(transform.CanMove, "Normal"); } }
public bool SetSize (int width, int height) { if (transformProvider == null) transformProvider = (ITransformProvider) resource.Provider.GetPatternProvider (TransformPatternIdentifiers.Pattern.Id); if ((transformProvider != null) && (transformProvider.CanResize)) { try { transformProvider.Resize (width, height); } catch (InvalidOperationException e) { Log.Debug (e); } return true; } return false; }
public bool SetPosition (int x, int y, Atk.CoordType coordType) { if (transformProvider == null) transformProvider = (ITransformProvider) resource.Provider.GetPatternProvider (TransformPatternIdentifiers.Pattern.Id); if ((transformProvider != null) && (transformProvider.CanMove)) { try { transformProvider.Move (x, y); } catch (InvalidOperationException e) { Log.Debug (e); } return true; } return false; }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors private TransformProviderWrapper(AutomationPeer peer, ITransformProvider iface) { _peer = peer; _iface = iface; }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors private TransformProviderWrapper( AutomationPeer peer, ITransformProvider iface ) { _peer = peer; _iface = iface; }
public TransformPatternWrapper (ITransformProvider provider) { this.provider = provider; }
private void VerifyResizeFail (Form f, ITransformProvider transform, FormBorderStyle style) { f.FormBorderStyle = style; try { transform.Resize (10, 10); Assert.Fail ("Expected InvalidOperationException"); } catch (InvalidOperationException) { // Expected } catch (Exception e){ Assert.Fail ("Expected InvalidOperationException, instead got this exception: " + e.Message); } }
private void VerifyMoveFail (Form f, ITransformProvider transform, FormWindowState state) { f.WindowState = state; try { transform.Move (10, 10); Assert.Fail ("Expected InvalidOperationException"); } catch (InvalidOperationException) { // Expected } catch (Exception e){ Assert.Fail ("Expected InvalidOperationException, instead got this exception: " + e.Message); } }
public TransformPatternWrapper(ITransformProvider provider) { this.provider = provider; }
public void CanResizeTest() { using (Form f = new Form()) { IRawElementProviderFragment provider = (IRawElementProviderFragment) ProviderFactory.GetProvider(f); ITransformProvider transform = (ITransformProvider) provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id); f.Show(); // To create Handle Assert.IsTrue(transform.CanResize, "True by default"); bridge.ResetEventLists(); f.FormBorderStyle = FormBorderStyle.Fixed3D; Assert.IsFalse(transform.CanResize, "FormBorderStyle.Fixed3D"); Assert.IsNotNull(bridge.GetAutomationPropertyEventFrom(provider, TransformPatternIdentifiers.CanResizeProperty.Id), "CanResizeProperty.0"); bridge.ResetEventLists(); f.FormBorderStyle = FormBorderStyle.FixedDialog; Assert.IsFalse(transform.CanResize, "FormBorderStyle.FixedDialog"); Assert.IsNull(bridge.GetAutomationPropertyEventFrom(provider, TransformPatternIdentifiers.CanResizeProperty.Id), "CanResizeProperty.1"); bridge.ResetEventLists(); f.FormBorderStyle = FormBorderStyle.FixedSingle; Assert.IsFalse(transform.CanResize, "FormBorderStyle.FixedSingle"); Assert.IsNull(bridge.GetAutomationPropertyEventFrom(provider, TransformPatternIdentifiers.CanResizeProperty.Id), "CanResizeProperty.2"); bridge.ResetEventLists(); f.FormBorderStyle = FormBorderStyle.FixedToolWindow; Assert.IsFalse(transform.CanResize, "FormBorderStyle.FixedToolWindow"); Assert.IsNull(bridge.GetAutomationPropertyEventFrom(provider, TransformPatternIdentifiers.CanResizeProperty.Id), "CanResizeProperty.3"); bridge.ResetEventLists(); f.FormBorderStyle = FormBorderStyle.None; Assert.IsTrue(transform.CanResize, "FormBorderStyle.None"); Assert.IsNotNull(bridge.GetAutomationPropertyEventFrom(provider, TransformPatternIdentifiers.CanResizeProperty.Id), "CanResizeProperty.4"); bridge.ResetEventLists(); f.FormBorderStyle = FormBorderStyle.Sizable; Assert.IsTrue(transform.CanResize, "FormBorderStyle.Sizable"); // No events raised, same value Assert.IsNull(bridge.GetAutomationPropertyEventFrom(provider, TransformPatternIdentifiers.CanResizeProperty.Id), "CanResizeProperty.5"); bridge.ResetEventLists(); f.FormBorderStyle = FormBorderStyle.SizableToolWindow; Assert.IsTrue(transform.CanResize, "FormBorderStyle.SizableToolWindow"); // No events raised, same value Assert.IsNull(bridge.GetAutomationPropertyEventFrom(provider, TransformPatternIdentifiers.CanResizeProperty.Id), "CanResizeProperty.6"); } }