Skip to content

Commit 4639cbe

Browse files
committed
chore: windows ps1
1 parent 3d272ab commit 4639cbe

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

.github/workflows/ui-tests.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,17 @@ jobs:
7373
- uses: actions/download-artifact@v4
7474
with:
7575
name: Build-${{ matrix.targetPlatform }}
76+
path: sample/Tests
7677
- uses: actions/setup-python@v4
7778
with:
7879
python-version: "3.10"
7980
- name: Install dependencies
8081
run: pip install -r "sample/Tests/requirements.txt"
8182
- name: Run UI tests
8283
env:
83-
UNITY_APP_PATH: ${{ github.workspace }}/SampleApp.app
84+
UNITY_APP_PATH: SampleApp.app
8485
UNITY_APP_NAME: SampleApp
8586
MAILSLURP_API_KEY: ${{ secrets.MAILSLURP_API_KEY }}
8687
working-directory: sample/Tests
87-
run: |
88-
chmod -R 755 ${{ github.workspace }}/SampleApp.app
89-
chmod +x ${{ matrix.test_script }}
90-
./${{ matrix.test_script }}
88+
run: ./${{ matrix.test_script }}
9189

sample/Tests/switch-app.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
param (
2+
[string]$appName
3+
)
4+
5+
Add-Type @"
6+
using System;
7+
using System.Runtime.InteropServices;
8+
public class User32 {
9+
[DllImport("user32.dll")]
10+
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
11+
[DllImport("user32.dll")]
12+
[return: MarshalAs(UnmanagedType.Bool)]
13+
public static extern bool SetForegroundWindow(IntPtr hWnd);
14+
}
15+
"@
16+
17+
$hWnd = [User32]::FindWindow([NullString]::Value, $appName)
18+
if ($hWnd -ne [IntPtr]::Zero) {
19+
[User32]::SetForegroundWindow($hWnd) | Out-Null
20+
} else {
21+
Write-Output "Window not found"
22+
}

sample/Tests/test_windows.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Stop-SampleApp {
1313
# Function to start the Unity sample app
1414
function Start-SampleApp {
1515
Write-Output "Starting Unity sample app..."
16-
Start-Process -FilePath "build\output\Windows64\SampleApp.exe"
16+
Start-Process -FilePath "SampleApp.exe"
1717
Start-Sleep -Seconds 10
1818
}
1919

0 commit comments

Comments
 (0)