Attempt to fix Linux headless Test run with SDL
This commit is contained in:
@@ -38,7 +38,7 @@ jobs:
|
||||
dotnet msbuild Source/Tools/Flax.Build.Tests/Flax.Build.Tests.csproj /m /t:Restore,Build /p:Configuration=Debug /p:Platform=AnyCPU /nologo
|
||||
- name: Test
|
||||
run: |
|
||||
${GITHUB_WORKSPACE}/Binaries/Editor/Linux/Development/FlaxTests
|
||||
${GITHUB_WORKSPACE}/Binaries/Editor/Linux/Development/FlaxTests -headless
|
||||
dotnet test -f net8.0 Binaries/Tests/Flax.Build.Tests.dll
|
||||
cp Binaries/Editor/Linux/Development/FlaxEngine.CSharp.dll Binaries/Tests
|
||||
cp Binaries/Editor/Linux/Development/FlaxEngine.CSharp.runtimeconfig.json Binaries/Tests
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
.\Binaries\Editor\Win64\Development\FlaxTests.exe
|
||||
.\Binaries\Editor\Win64\Development\FlaxTests.exe -headless
|
||||
if(!$?) { Write-Host "Tests failed with exit code $LastExitCode" -ForegroundColor Red; Exit $LastExitCode }
|
||||
dotnet test -f net8.0 Binaries\Tests\Flax.Build.Tests.dll
|
||||
xcopy /y Binaries\Editor\Win64\Development\FlaxEngine.CSharp.dll Binaries\Tests
|
||||
|
||||
@@ -407,7 +407,6 @@ namespace FlaxEditor
|
||||
|
||||
// Close splash and show main window
|
||||
CloseSplashScreen();
|
||||
Assert.IsNotNull(Windows.MainWindow);
|
||||
if (!IsHeadlessMode)
|
||||
{
|
||||
Windows.MainWindow.Show();
|
||||
|
||||
@@ -481,6 +481,8 @@ namespace FlaxEditor.Modules
|
||||
/// <inheritdoc />
|
||||
public override void OnInit()
|
||||
{
|
||||
if (Editor.IsHeadlessMode)
|
||||
return;
|
||||
Editor.Windows.MainWindowClosing += OnMainWindowClosing;
|
||||
var mainWindow = Editor.Windows.MainWindow.GUI;
|
||||
|
||||
|
||||
@@ -758,36 +758,39 @@ namespace FlaxEditor.Modules
|
||||
|
||||
_windowsLayoutPath = StringUtils.CombinePaths(Globals.ProjectCacheFolder, "WindowsLayout.xml");
|
||||
|
||||
// Create main window
|
||||
var settings = CreateWindowSettings.Default;
|
||||
settings.Title = "Flax Editor";
|
||||
settings.Size = Platform.DesktopSize * 0.75f;
|
||||
settings.MinimumSize = new Float2(200, 150);
|
||||
settings.StartPosition = WindowStartPosition.CenterScreen;
|
||||
settings.ShowAfterFirstPaint = true;
|
||||
|
||||
if (Utilities.Utils.UseCustomWindowDecorations(isMainWindow: true))
|
||||
if (!Editor.IsHeadlessMode)
|
||||
{
|
||||
settings.HasBorder = false;
|
||||
// Create main window
|
||||
var settings = CreateWindowSettings.Default;
|
||||
settings.Title = "Flax Editor";
|
||||
settings.Size = Platform.DesktopSize * 0.75f;
|
||||
settings.MinimumSize = new Float2(200, 150);
|
||||
settings.StartPosition = WindowStartPosition.CenterScreen;
|
||||
settings.ShowAfterFirstPaint = true;
|
||||
|
||||
if (Utilities.Utils.UseCustomWindowDecorations(isMainWindow: true))
|
||||
{
|
||||
settings.HasBorder = false;
|
||||
#if PLATFORM_WINDOWS && !PLATFORM_SDL
|
||||
// Skip OS sizing frame and implement it using LeftButtonHit
|
||||
settings.HasSizingFrame = false;
|
||||
// Skip OS sizing frame and implement it using LeftButtonHit
|
||||
settings.HasSizingFrame = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if PLATFORM_LINUX && !PLATFORM_SDL
|
||||
settings.HasBorder = false;
|
||||
settings.HasBorder = false;
|
||||
#endif
|
||||
MainWindow = Platform.CreateWindow(ref settings);
|
||||
if (MainWindow == null)
|
||||
{
|
||||
Editor.LogError("Failed to create editor main window!");
|
||||
return;
|
||||
}
|
||||
UpdateWindowTitle();
|
||||
MainWindow = Platform.CreateWindow(ref settings);
|
||||
if (MainWindow == null)
|
||||
{
|
||||
Editor.LogError("Failed to create editor main window!");
|
||||
return;
|
||||
}
|
||||
UpdateWindowTitle();
|
||||
|
||||
// Link for main window events
|
||||
MainWindow.Closing += MainWindow_OnClosing;
|
||||
MainWindow.Closed += MainWindow_OnClosed;
|
||||
// Link for main window events
|
||||
MainWindow.Closing += MainWindow_OnClosing;
|
||||
MainWindow.Closed += MainWindow_OnClosed;
|
||||
}
|
||||
|
||||
// Create default editor windows
|
||||
ContentWin = new ContentWindow(Editor);
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
#include <SDL3/SDL_system.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
|
||||
#if PLATFORM_LINUX
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#endif
|
||||
|
||||
#define DefaultDPI 96
|
||||
|
||||
namespace SDLImpl
|
||||
@@ -106,10 +102,16 @@ bool SDLPlatform::Init()
|
||||
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1"); // Allow screensaver in Editor when idle
|
||||
#endif
|
||||
|
||||
SDL_InitFlags initFlags = SDL_INIT_VIDEO | SDL_INIT_GAMEPAD;
|
||||
#if PLATFORM_HAS_HEADLESS_MODE
|
||||
if (CommandLine::Options.Headless.GetValue())
|
||||
initFlags &= ~SDL_INIT_VIDEO;
|
||||
#endif
|
||||
|
||||
//if (InitInternal())
|
||||
// return true;
|
||||
|
||||
if (!SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD))
|
||||
if (!SDL_InitSubSystem(initFlags))
|
||||
Platform::Fatal(String::Format(TEXT("Failed to initialize SDL: {0}."), String(SDL_GetError())));
|
||||
|
||||
#if PLATFORM_LINUX || PLATFORM_WEB
|
||||
|
||||
Reference in New Issue
Block a user