diff options
author | iain <iain.holmes@xamarin.com> | 2015-12-15 21:45:04 +0300 |
---|---|---|
committer | iain <iain.holmes@xamarin.com> | 2015-12-15 21:45:04 +0300 |
commit | 9bad3e3cefde74221987a1cda162a329f26b7e23 (patch) | |
tree | 232b2823544579d825692938f8736bf16076ea51 /main | |
parent | 644f03c575aed97736c5b8d55ce48c97ae010441 (diff) | |
parent | b70a47116885fd45ac413a1e8a4178d4d1031aee (diff) |
Merge pull request #1185 from iainx/set-property
[AutoTest] Add a method to set a property on a queried object
Diffstat (limited to 'main')
7 files changed, 54 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkTreeModelResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkTreeModelResult.cs index bf7a4fd98b..9be5713e4d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkTreeModelResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkTreeModelResult.cs @@ -25,6 +25,7 @@ // THE SOFTWARE. using System; using System.Collections.Generic; +using System.Reflection; using Gtk; using System.Linq; @@ -272,6 +273,15 @@ namespace MonoDevelop.Components.AutoTest.Results } return false; } + + public override void SetProperty (string propertyName, object value) + { + if (resultIter.HasValue) { + var modelValue = TModel.GetValue ((TreeIter)resultIter, Column); + + SetProperty (modelValue, propertyName, value); + } + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkWidgetResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkWidgetResult.cs index 50d4f4b082..99d00e3ae4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkWidgetResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkWidgetResult.cs @@ -473,6 +473,11 @@ namespace MonoDevelop.Components.AutoTest.Results return true; }); } + + public override void SetProperty (string propertyName, object value) + { + SetProperty (resultWidget, propertyName, value); + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/NSObjectResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/NSObjectResult.cs index 8df790e36c..d760b57158 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/NSObjectResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/NSObjectResult.cs @@ -244,6 +244,11 @@ namespace MonoDevelop.Components.AutoTest.Results } + public override void SetProperty (string propertyName, object value) + { + SetProperty (ResultObject, propertyName, value); + } + #region MacPlatform.MacIntegration.MainToolbar.SelectorView public override bool SetActiveConfiguration (string configurationName) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/ObjectResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/ObjectResult.cs index 683b697037..fc276a5394 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/ObjectResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/ObjectResult.cs @@ -122,5 +122,10 @@ namespace MonoDevelop.Components.AutoTest.Results { } + + public override void SetProperty (string propertyName, object newValue) + { + SetProperty (value, propertyName, newValue); + } } } 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 21ed5b9ef1..805b29718d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs @@ -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; |