diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-12-18 12:37:48 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-12-18 12:37:48 +0300 |
commit | dd68992381922d2397b5be056f07f4f6d4eb4431 (patch) | |
tree | 6f51e1579f920b0e8f45ccb4314cc018f3218403 /main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest | |
parent | 6f9f0ce2cdc473b15e780eff388049387cab6d79 (diff) | |
parent | cb1a77e281e838e4a3a4947f99522f6673843cc4 (diff) |
Merge remote-tracking branch 'origin/master' into roslyn-nogtkshell
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest')
3 files changed, 32 insertions, 3 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs index 20a71e2df5..45b3bc22ea 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs @@ -64,6 +64,7 @@ namespace MonoDevelop.Components.AutoTest public abstract bool EnterText (string text); public abstract bool Toggle (bool active); public abstract void Flash (); + public abstract void SetProperty (string propertyName, object value); // More specific actions for complicated widgets @@ -105,6 +106,17 @@ namespace MonoDevelop.Components.AutoTest return children; } + public void SetProperty (object o, string propertyName, object value) + { + // Find the property for the name + PropertyInfo propertyInfo = o.GetType().GetProperty(propertyName, + BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); + + if (propertyInfo != null && propertyInfo.CanRead && !propertyInfo.GetIndexParameters ().Any ()) { + propertyInfo.SetValue (o, value); + } + } + /// <summary> /// Convenience function to add an attribute to an element /// </summary> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestClientSession.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestClientSession.cs index a1f5f0bb1e..81878d1ab2 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestClientSession.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestClientSession.cs @@ -363,6 +363,14 @@ namespace MonoDevelop.Components.AutoTest } } + public void SetProperty (Func<AppQuery, AppQuery> query, string propertyName, object value) + { + AppResult[] results = Query (query); + foreach (var result in results) { + session.SetProperty (result, propertyName, value); + } + } + public bool SetActiveConfiguration (Func<AppQuery, AppQuery> query, string configuration) { AppResult[] results = Query (query); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs index a4fb16bb70..805b29718d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs @@ -108,7 +108,7 @@ namespace MonoDevelop.Components.AutoTest object res = null; Exception error = null; - if (DispatchService.IsGuiThread) { + if (Runtime.IsMainThread) { res = del (); return safe ? SafeObject (res) : res; } @@ -182,7 +182,7 @@ namespace MonoDevelop.Components.AutoTest public void TakeScreenshot (string screenshotPath) { #if MAC - DispatchService.GuiDispatch (delegate { + Runtime.RunInMainThread (delegate { try { IntPtr handle = CGDisplayCreateImage (MainDisplayID ()); CoreGraphics.CGImage screenshot = ObjCRuntime.Runtime.GetINativeObject <CoreGraphics.CGImage> (handle, true); @@ -325,7 +325,7 @@ namespace MonoDevelop.Components.AutoTest public void ExecuteOnIdle (Action idleFunc, bool wait = true, int timeout = 20000) { - if (DispatchService.IsGuiThread) { + if (Runtime.IsMainThread) { idleFunc (); return; } @@ -558,6 +558,15 @@ namespace MonoDevelop.Components.AutoTest } } + public void SetProperty (AppResult result, string name, object o) + { + try { + ExecuteOnIdle (() => result.SetProperty (name, o)); + } catch (TimeoutException e) { + ThrowOperationTimeoutException ("SetProperty", result.SourceQuery, result, e); + } + } + public bool SetActiveConfiguration (AppResult result, string configuration) { bool success = false; |