Skip to content

Commit

Permalink
Merge branch 'main' into fix-17400
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz committed Oct 11, 2023
2 parents 2692832 + a2d80a5 commit 447e8fd
Show file tree
Hide file tree
Showing 40 changed files with 1,614 additions and 1,613 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
![.NET MAUI Weather App on all platforms](Assets/maui-weather-hero-sm.png)

## Current News

* October 10, 2023 - [Announcing .NET MAUI in .NET 8 Release Candidate 2: More Quality](https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-in-dotnet-8-rc-2/)
* September 12, 2023 - [Announcing .NET MAUI in .NET 8 Release Candidate 1: Quality](https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-in-dotnet-8-rc-1)
* August 8, 2023 - [Announcing .NET MAUI in .NET 8 Preview 7: Keyboard Accelerators](https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-in-dotnet-8-preview-7/)

Follow the [.NET MAUI Blog](https://devblogs.microsoft.com/dotnet/category/net-maui/) and visit the [News](https://github.com/dotnet/maui/wiki/News) wiki page for more news and updates.

Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/UITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public override IConfig GetTestConfig()

IConfig config = new Config();
config.SetProperty("AppId", "com.microsoft.maui.uitests");

switch (_testDevice)
{
case TestDevice.iOS:
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/tests/UITests/UtilExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void Back(this UITestContextBase testBase)
testBase.App.FindElement("NavigationViewBackButton").Click();
}
}

public static void NavigateToGallery(this IApp app, string page)
{
app.WaitForElement(goToTestButtonId, "Timed out waiting for Go To Test button to appear", TimeSpan.FromMinutes(2));
Expand Down Expand Up @@ -65,7 +65,7 @@ public static int CenterX(this Rectangle rect)

public static int CenterY(this Rectangle rect)
{
return rect.Y + rect.Height/ 2;
return rect.Y + rect.Height / 2;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,84 @@

namespace UITest.Appium
{
public class AppiumCatalystPointerActions : ICommandExecutionGroup
{
const string DoubleClickCommand = "doubleClick";
const string DragAndDropCommand = "dragAndDrop";
public class AppiumCatalystPointerActions : ICommandExecutionGroup
{
const string DoubleClickCommand = "doubleClick";
const string DragAndDropCommand = "dragAndDrop";

readonly List<string> _commands = new()
{
DoubleClickCommand,
DragAndDropCommand,
};
readonly AppiumApp _appiumApp;
readonly List<string> _commands = new()
{
DoubleClickCommand,
DragAndDropCommand,
};
readonly AppiumApp _appiumApp;

public AppiumCatalystPointerActions(AppiumApp appiumApp)
{
_appiumApp = appiumApp;
}
public AppiumCatalystPointerActions(AppiumApp appiumApp)
{
_appiumApp = appiumApp;
}

public bool IsCommandSupported(string commandName)
{
return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase);
}
public bool IsCommandSupported(string commandName)
{
return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase);
}

public CommandResponse Execute(string commandName, IDictionary<string, object> parameters)
{
return commandName switch
{
DoubleClickCommand => DoubleClick(parameters),
DragAndDropCommand => DragAndDrop(parameters),
_ => CommandResponse.FailedEmptyResponse,
};
}
public CommandResponse Execute(string commandName, IDictionary<string, object> parameters)
{
return commandName switch
{
DoubleClickCommand => DoubleClick(parameters),
DragAndDropCommand => DragAndDrop(parameters),
_ => CommandResponse.FailedEmptyResponse,
};
}

CommandResponse DoubleClick(IDictionary<string, object> parameters)
{
var element = GetAppiumElement(parameters["element"]);
CommandResponse DoubleClick(IDictionary<string, object> parameters)
{
var element = GetAppiumElement(parameters["element"]);

if (element != null)
{
_appiumApp.Driver.ExecuteScript("macos: doubleClick", new Dictionary<string, object>
{
{ "elementId", element.Id },
});
}
return CommandResponse.SuccessEmptyResponse;
}
if (element != null)
{
_appiumApp.Driver.ExecuteScript("macos: doubleClick", new Dictionary<string, object>
{
{ "elementId", element.Id },
});
}
return CommandResponse.SuccessEmptyResponse;
}

CommandResponse DragAndDrop(IDictionary<string, object> actionParams)
{
AppiumElement? sourceAppiumElement = GetAppiumElement(actionParams["sourceElement"]);
AppiumElement? destinationAppiumElement = GetAppiumElement(actionParams["destinationElement"]);
CommandResponse DragAndDrop(IDictionary<string, object> actionParams)
{
AppiumElement? sourceAppiumElement = GetAppiumElement(actionParams["sourceElement"]);
AppiumElement? destinationAppiumElement = GetAppiumElement(actionParams["destinationElement"]);

if (sourceAppiumElement != null && destinationAppiumElement != null)
{
_appiumApp.Driver.ExecuteScript("macos: clickAndDragAndHold", new Dictionary<string, object>
{
{ "holdDuration", .1 }, // Length of time to hold before releasing
if (sourceAppiumElement != null && destinationAppiumElement != null)
{
_appiumApp.Driver.ExecuteScript("macos: clickAndDragAndHold", new Dictionary<string, object>
{
{ "holdDuration", .1 }, // Length of time to hold before releasing
{ "duration", 1 }, // Length of time to hold after click before start dragging
{ "velocity", 2500 }, // How fast to drag
{ "sourceElementId", sourceAppiumElement.Id },
{ "destinationElementId", destinationAppiumElement.Id },
});
return CommandResponse.SuccessEmptyResponse;
}
return CommandResponse.FailedEmptyResponse;
}
{ "destinationElementId", destinationAppiumElement.Id },
});
return CommandResponse.SuccessEmptyResponse;
}
return CommandResponse.FailedEmptyResponse;
}

static AppiumElement? GetAppiumElement(object element)
{
if (element is AppiumElement appiumElement)
{
return appiumElement;
}
else if (element is AppiumDriverElement driverElement)
{
return driverElement.AppiumElement;
}
static AppiumElement? GetAppiumElement(object element)
{
if (element is AppiumElement appiumElement)
{
return appiumElement;
}
else if (element is AppiumDriverElement driverElement)
{
return driverElement.AppiumElement;
}

return null;
}
}
return null;
}
}
}
38 changes: 19 additions & 19 deletions src/TestUtils/src/UITest.Appium/Actions/AppiumCommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

namespace UITest.Appium
{
public class AppiumCommandExecutor : ICommandExecution
{
readonly Stack<ICommandExecutionGroup> _commands = new();
public class AppiumCommandExecutor : ICommandExecution
{
readonly Stack<ICommandExecutionGroup> _commands = new();

public void AddCommandGroup(ICommandExecutionGroup commandExecuteGroup)
{
_commands.Push(commandExecuteGroup);
}
public void AddCommandGroup(ICommandExecutionGroup commandExecuteGroup)
{
_commands.Push(commandExecuteGroup);
}

public CommandResponse Execute(string commandName, IDictionary<string, object> parameters)
{
foreach (var command in _commands)
{
if (command.IsCommandSupported(commandName))
{
return command.Execute(commandName, parameters);
}
}
public CommandResponse Execute(string commandName, IDictionary<string, object> parameters)
{
foreach (var command in _commands)
{
if (command.IsCommandSupported(commandName))
{
return command.Execute(commandName, parameters);
}
}

return CommandResponse.FailedEmptyResponse;
}
}
return CommandResponse.FailedEmptyResponse;
}
}
}
114 changes: 57 additions & 57 deletions src/TestUtils/src/UITest.Appium/Actions/AppiumGeneralActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,61 @@

namespace UITest.Appium
{
public class AppiumGeneralActions : ICommandExecutionGroup
{
const string GetAttributeCommand = "getAttribute";
const string GetRectCommand = "getRect";

readonly List<string> _commands = new()
{
GetAttributeCommand,
GetRectCommand,
};

public bool IsCommandSupported(string commandName)
{
return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase);
}

public CommandResponse Execute(string commandName, IDictionary<string, object> parameters)
{
return commandName switch
{
GetAttributeCommand => GetAttribute(parameters),
GetRectCommand => GetRect(parameters),
_ => CommandResponse.FailedEmptyResponse,
};
}

CommandResponse GetRect(IDictionary<string, object> parameters)
{
var element = parameters["element"];

if (element is AppiumElement appiumElement)
{
return new CommandResponse(appiumElement.Rect, CommandResponseResult.Success);
}
else if (element is AppiumDriverElement driverElement)
{
return new CommandResponse(driverElement.AppiumElement.Rect, CommandResponseResult.Success);
}
return CommandResponse.FailedEmptyResponse;
}

CommandResponse GetAttribute(IDictionary<string, object> parameters)
{
var element = parameters["element"];
var attributeName = (string)parameters["attributeName"];
if (element is AppiumElement appiumElement)
{
return new CommandResponse(appiumElement.GetAttribute(attributeName), CommandResponseResult.Success);
}
else if (element is AppiumDriverElement driverElement)
{
return new CommandResponse(driverElement.AppiumElement.GetAttribute(attributeName), CommandResponseResult.Success);
}
return CommandResponse.FailedEmptyResponse;
}
}
public class AppiumGeneralActions : ICommandExecutionGroup
{
const string GetAttributeCommand = "getAttribute";
const string GetRectCommand = "getRect";

readonly List<string> _commands = new()
{
GetAttributeCommand,
GetRectCommand,
};

public bool IsCommandSupported(string commandName)
{
return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase);
}

public CommandResponse Execute(string commandName, IDictionary<string, object> parameters)
{
return commandName switch
{
GetAttributeCommand => GetAttribute(parameters),
GetRectCommand => GetRect(parameters),
_ => CommandResponse.FailedEmptyResponse,
};
}

CommandResponse GetRect(IDictionary<string, object> parameters)
{
var element = parameters["element"];

if (element is AppiumElement appiumElement)
{
return new CommandResponse(appiumElement.Rect, CommandResponseResult.Success);
}
else if (element is AppiumDriverElement driverElement)
{
return new CommandResponse(driverElement.AppiumElement.Rect, CommandResponseResult.Success);
}
return CommandResponse.FailedEmptyResponse;
}

CommandResponse GetAttribute(IDictionary<string, object> parameters)
{
var element = parameters["element"];
var attributeName = (string)parameters["attributeName"];

if (element is AppiumElement appiumElement)
{
return new CommandResponse(appiumElement.GetAttribute(attributeName), CommandResponseResult.Success);
}
else if (element is AppiumDriverElement driverElement)
{
return new CommandResponse(driverElement.AppiumElement.GetAttribute(attributeName), CommandResponseResult.Success);
}
return CommandResponse.FailedEmptyResponse;
}
}
}

0 comments on commit 447e8fd

Please sign in to comment.