Skip to content

Commit

Permalink
Merge branch 'master' into BuildWin2025
Browse files Browse the repository at this point in the history
  • Loading branch information
jbe2277 committed Feb 2, 2025
2 parents a48f560 + fe53c25 commit 81d713c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/NewsReader.CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ jobs:
dotnet publish -f:net9.0-windows10.0.19041.0 -c:Release -p:ApplicationDisplayVersion=${{ needs.GetVersion.outputs.version }} -p:ApplicationVersion=0
iOS:
runs-on: macos-14
runs-on: macos-15
needs: GetVersion
steps:
- name: 🔖 Check-out
uses: actions/checkout@v4

- name: ⚙️ Set Xcode version
run: |
XCODE_ROOT=/Applications/Xcode_16.1.app
XCODE_ROOT=/Applications/Xcode_16.2.app
echo "MD_APPLE_SDK_ROOT=$XCODE_ROOT" >> $GITHUB_ENV # set environment variable to specify Xcode for Mono and Xamarin
sudo xcode-select -s $XCODE_ROOT
Expand Down
15 changes: 10 additions & 5 deletions src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ void PrintAsPdf(string fileName)

reportView.PrintButton.Click();
var version = new Version(10, 0, 22621, 0); // Windows 11 22H2
bool printCompleted = false;
if (Environment.OSVersion.Version >= version)
{
var printDialog = PrintDialog.GetDialog(Automation);
printDialog.PrinterSelector.Select(printDialog.PrintToPdf.Name);
Retry.WhileFalse(() => printDialog.PrintButton.IsEnabled, throwOnTimeout: true);
printDialog.PrintButton.Click();
var printDialog = PrintDialog.TryGetDialog(Automation);
if (printDialog is not null) // Windows 2025 Server uses legacy print dialog
{
printDialog.PrinterSelector.Select(printDialog.PrintToPdf.Name);
Retry.WhileFalse(() => printDialog.PrintButton.IsEnabled, throwOnTimeout: true);
printDialog.PrintButton.Invoke();
printCompleted = true;
}
}
else
if (!printCompleted)
{
var printDialog = window.FirstModalWindow().As<LegacyPrintDialog>();
Log.WriteLine("Printers:");
Expand Down
15 changes: 12 additions & 3 deletions src/Samples.UITest/UITest.Core/SystemViews/PrintDialog.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
using FlaUI.Core;
using FlaUI.Core.AutomationElements;
using FlaUI.Core.Conditions;
using FlaUI.Core.Definitions;
using System.Diagnostics;

namespace UITest.SystemViews;

public class PrintDialog(FrameworkAutomationElementBase element) : Window(element)
{
public static PrintDialog GetDialog(AutomationBase automation)
public static PrintDialog? TryGetDialog(AutomationBase automation)
{
var p = Process.GetProcesses().FirstOrDefault(x => x.ProcessName.Contains("PrintDialog", StringComparison.OrdinalIgnoreCase));
if (p is null) return null;
var desktop = automation.GetDesktop();
return desktop.Find(x => new AndCondition(x.ByControlType(ControlType.Window), x.ByName("Windows Print"))).As<PrintDialog>();
var topLevel = desktop.FindAllChildren(x => x.ByControlType(ControlType.Window));
AutomationElement? printDialog = null;
foreach (var x in topLevel)
{
printDialog = x.FindFirstChild(x => x.ByProcessId(p.Id)); // It is a Window on the second level with process name "PrintDialog"
if (printDialog is not null) break;
}
return printDialog?.As<PrintDialog>();
}

public ComboBox PrinterSelector => this.Find("printerSelector").AsComboBox();
Expand Down
15 changes: 10 additions & 5 deletions src/Samples.UITest/Writer.Test/Tests/WriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,19 @@ void PrintAsPdf(string fileName)

printPreviewTab.PrintButton.Click();
var version = new Version(10, 0, 22621, 0); // Windows 11 22H2
bool printCompleted = false;
if (Environment.OSVersion.Version >= version)
{
var printDialog = PrintDialog.GetDialog(Automation);
printDialog.PrinterSelector.Select(printDialog.PrintToPdf.Name);
Retry.WhileFalse(() => printDialog.PrintButton.IsEnabled, throwOnTimeout: true);
printDialog.PrintButton.Click();
var printDialog = PrintDialog.TryGetDialog(Automation);
if (printDialog is not null) // Windows 2025 Server uses legacy print dialog
{
printDialog.PrinterSelector.Select(printDialog.PrintToPdf.Name);
Retry.WhileFalse(() => printDialog.PrintButton.IsEnabled, throwOnTimeout: true);
printDialog.PrintButton.Invoke();
printCompleted = true;
}
}
else
if (!printCompleted)
{
var printDialog = window.FirstModalWindow().As<LegacyPrintDialog>();
printDialog.PrinterList.Select(printDialog.PrintToPdf.Text);
Expand Down

0 comments on commit 81d713c

Please sign in to comment.