Skip to content

Commit a7f84c8

Browse files
authored
Merge pull request #201 from Nfactor26/adresss-multiple-issues
Adresss multiple issues
2 parents d28c427 + e3e1306 commit a7f84c8

File tree

16 files changed

+47
-80
lines changed

16 files changed

+47
-80
lines changed

src/Pixel.Automation.AppExplorer.ViewModels/PrefabBuilder/NewPrefabViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private void ValidateProperty(string propertyName)
9292
{
9393
case nameof(PrefabName):
9494
ValidateRequiredProperty(nameof(PrefabName), PrefabName);
95-
ValidatePattern("^([A-Za-z]|[._ ]){4,}$", nameof(PrefabName), PrefabName, "Name must contain only alphabets or ' ' or '_' and should be atleast 4 characters in length.");
95+
ValidatePattern("^([A-Za-z]|[_ ]){4,}$", nameof(PrefabName), PrefabName, "Name must contain only alphabets or ' ' or '_' and should be atleast 4 characters in length.");
9696
if (this.applicationDescriptionViewModel.PrefabsCollection.Any(p => p.PrefabName.Equals(PrefabName)))
9797
{
9898
AddOrAppendErrors(nameof(PrefabName), $"Prefab with name {PrefabName} already exists for application {this.applicationDescriptionViewModel.ApplicationName}");

src/Pixel.Automation.Core.Components/Entities/ControlEntity.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,16 @@ public IControlIdentity ControlDetails
134134

135135
}
136136

137-
protected abstract void InitializeFilter();
137+
/// <summary>
138+
/// Initialize the Filter Argument.
139+
/// </summary>
140+
protected virtual void InitializeFilter()
141+
{
142+
if (this.Filter == null)
143+
{
144+
this.Filter = new PredicateArgument<UIControl>() { CanChangeType = false };
145+
}
146+
}
138147

139148
public ControlEntity(string name = "Control Entity", string tag = "ControlEntity") : base(name, tag)
140149
{
@@ -194,8 +203,8 @@ protected T GetElementMatchingCriteria<T>(IEnumerable<T> foundControls)
194203
protected async Task<bool> ApplyPredicate<T>(string predicateScriptFile, T targetElement)
195204
{
196205
IScriptEngine scriptEngine = this.EntityManager.GetScriptEngine();
197-
var fn = await scriptEngine.CreateDelegateAsync<Func<IComponent, T, bool>>(predicateScriptFile);
198-
bool isMatch = fn(this, targetElement);
206+
var fn = await scriptEngine.CreateDelegateAsync<Func<IComponent, T, Task<bool>>>(predicateScriptFile);
207+
bool isMatch = await fn(this, targetElement);
199208
return isMatch;
200209
}
201210
}

src/Pixel.Automation.Core/Arguments/ArgumentExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public static class ArgumentExtensions
1515
private static readonly string setValueAction = "return ((Action<{0}>)SetValue);";
1616
private static readonly string getValueTemplate = "{0} GetValue(){1}{{{1} return default;{1}}}";
1717
private static readonly string getValueDelegate = "return ((Func<{0}>)GetValue);";
18-
private static readonly string predicateScriptTemplate = "bool IsMatch(IComponent current, {0} argument){1}{{{1} return false;{1}}}";
19-
private static readonly string predicateDelegate = "return ((Func<IComponent, {0}, bool>)IsMatch);";
18+
private static readonly string predicateScriptTemplate = "Task<bool> IsMatch(IComponent current, {0} argument){1}{{{1} return Task.FromResult(false);{1}}}";
19+
private static readonly string predicateDelegate = "return ((Func<IComponent, {0}, Task<bool>>)IsMatch);";
2020

2121
/// <summary>
2222
/// Get the value of the argument

src/Pixel.Automation.Designer.ViewModels/Modules/NativeModules.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
using Ninject.Extensions.Conventions;
1+
using Ninject;
2+
using Ninject.Extensions.Conventions;
23
using Ninject.Modules;
4+
using Pixel.Automation.Core.Interfaces;
35
using System.Reflection;
46

57
namespace Pixel.Automation.Designer.ViewModels.Modules
68
{
79
internal class NativeModules : NinjectModule
810
{
9-
private ICollection<Assembly> assemblies = new List<Assembly>();
11+
private List<Assembly> assemblies = new ();
1012

1113
public NativeModules(IEnumerable<Assembly> assemblies)
1214
{
@@ -20,6 +22,8 @@ public override void Load()
2022
foreach(var assembly in assemblies)
2123
{
2224
Kernel.Bind(x => x.From(assembly).SelectAllClasses().BindAllInterfaces().Configure(b => b.InSingletonScope()));
25+
//HighlightRectangle instance must be created on UIThread or it won't display
26+
_ = Kernel.Get<IHighlightRectangle>();
2327
}
2428
}
2529
}

src/Pixel.Automation.Designer.ViewModels/Screen/NewProjectViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void ValidateProjectName(string projectName)
9696
{
9797
ClearErrors(nameof(Name));
9898
ValidateRequiredProperty(nameof(Name), projectName);
99-
ValidatePattern("^([A-Za-z]|[._ ]){4,}$", nameof(Name), projectName, "Name must contain only alphabets or ' ' or '_' and should be atleast 4 characters in length.");
99+
ValidatePattern("^([A-Za-z]|[_ ]){4,}$", nameof(Name), projectName, "Name must contain only alphabets or ' ' or '_' and should be atleast 4 characters in length.");
100100
if(!IsNameAvailable(projectName))
101101
{
102102
this.AddOrAppendErrors(nameof(Name), "An application already exists with this name");

src/Pixel.Automation.Image.Matching.Components/ImageControlEntity.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,7 @@ public ImageSearchScope ImageSearchScope
8484
[DataMember]
8585
[Display(Name = "Area on screen", GroupName = "Search Strategy", Order = 15)]
8686
[Description("Target window within which image lookup will be restricted")]
87-
public Argument AreaOnScreen { get; set; } = new InArgument<BoundingBox>() { Mode = ArgumentMode.DataBound };
88-
89-
///<inheritdoc/>
90-
protected override void InitializeFilter()
91-
{
92-
if (this.Filter == null)
93-
{
94-
this.Filter = new PredicateArgument<BoundingBox>() { CanChangeType = false };
95-
}
96-
}
87+
public Argument AreaOnScreen { get; set; } = new InArgument<BoundingBox>() { Mode = ArgumentMode.DataBound };
9788

9889
///<inheritdoc/>
9990
public override async Task<UIControl> GetControl()

src/Pixel.Automation.Java.Access.Bridge.Components/JavaControlEntity.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
using Pixel.Automation.Core.Arguments;
2-
using Pixel.Automation.Core.Components;
1+
using Pixel.Automation.Core.Components;
32
using Pixel.Automation.Core.Controls;
43
using Pixel.Automation.Core.Enums;
54
using Serilog;
65
using System;
76
using System.Collections.Generic;
87
using System.Threading.Tasks;
9-
using WindowsAccessBridgeInterop;
108

119
namespace Pixel.Automation.Java.Access.Bridge.Components
1210
{
@@ -15,15 +13,7 @@ public class JavaControlEntity : ControlEntity
1513
private readonly ILogger logger = Log.ForContext<JavaControlEntity>();
1614

1715
private UIControl control;
18-
19-
protected override void InitializeFilter()
20-
{
21-
if (this.Filter == null)
22-
{
23-
this.Filter = new PredicateArgument<AccessibleContextNode>();
24-
}
25-
}
26-
16+
2717
/// <summary>
2818
/// Clear the located control once entity is processed
2919
/// </summary>

src/Pixel.Automation.Reference.Manager/ReferenceManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public void Initialize(string projectId, string projectVersion, IFileSystem file
4747
else
4848
{
4949
this.projectReferences = CreateDefault();
50-
_ = this.referencesRepositoryClient.AddProjectReferencesAsync(this.projectId, this.projectVersion, this.projectReferences);
50+
if(!applicationSettings.IsOfflineMode)
51+
{
52+
_ = this.referencesRepositoryClient.AddProjectReferencesAsync(this.projectId, this.projectVersion, this.projectReferences);
53+
}
5154
SaveLocal();
5255
}
5356

src/Pixel.Automation.UIA.Components/WinControlEntity.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
extern alias uiaComWrapper;
2-
using Pixel.Automation.Core.Arguments;
32
using Pixel.Automation.Core.Components;
43
using Pixel.Automation.Core.Controls;
54
using Pixel.Automation.Core.Enums;
65
using Serilog;
76
using System;
87
using System.Collections.Generic;
98
using System.Threading.Tasks;
10-
using uiaComWrapper::System.Windows.Automation;
119

1210
namespace Pixel.Automation.UIA.Components
1311
{
@@ -16,15 +14,7 @@ public class WinControlEntity : ControlEntity
1614
private readonly ILogger logger = Log.ForContext<WinControlEntity>();
1715

1816
private UIControl control;
19-
20-
protected override void InitializeFilter()
21-
{
22-
if (this.Filter == null)
23-
{
24-
this.Filter = new PredicateArgument<AutomationElement>();
25-
}
26-
}
27-
17+
2818
/// <summary>
2919
/// Clear the located control once entity is processed
3020
/// </summary>

src/Pixel.Automation.Web.Playwright.Components/WebControlEntity.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ public class WebControlEntity : ControlEntity
1111
{
1212
private readonly ILogger logger = Log.ForContext<WebControlEntity>();
1313

14-
private UIControl control;
15-
16-
protected override void InitializeFilter()
17-
{
18-
if (this.Filter == null)
19-
{
20-
this.Filter = new PredicateArgument<ILocator>();
21-
}
22-
}
14+
private UIControl control;
2315

2416
/// <summary>
2517
/// Clear the located control once entity is processed

0 commit comments

Comments
 (0)