1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-01 05:10:50 +01:00
MLEM/Tests/TestGame.cs
Ell 50e864b94f
Fixed stack overflow related to panel scrolling and scrollbar auto hiding (and improved build scripts) (#28)
* add a test to recreate the issue

* fixed deploy-demo running on pull requests

* restructure cake script to run tests separately

* actually name the test step correctly

* also run the build task separately

* made all tasks explicitly depend on prepare

* install android workload manually, rather than as part of cake

* Revert "install android workload manually, rather than as part of cake"

This reverts commit 101d6d3eac.

* don't clear a panel's scroll bar max history between area updates

* added changelog entry
2024-10-27 00:46:15 +02:00

61 lines
1.5 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MLEM.Data.Content;
using MLEM.Font;
using MLEM.Startup;
using NUnit.Framework;
namespace Tests;
public class TestGame : MlemGame {
public RawContentManager RawContent { get; private set; }
private TestGame() {
#if KNI
// allow textures larger than 4096x4096 for our texture packer tests
this.GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.FL11_0;
#endif
}
protected override void LoadContent() {
base.LoadContent();
this.RawContent = new RawContentManager(this.Services, this.Content.RootDirectory);
// make sure that the viewport is always the same size, since RunOneFrame doesn't ensure window size is correct
this.UiSystem.Viewport = new Rectangle(0, 0, 1280, 720);
// we use precompiled fonts and kni uses a different asset compilation system, so we just have both stored
this.UiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>(
#if KNI
"TestFontKni"
#else
"TestFont"
#endif
));
}
public static TestGame Create() {
var game = new TestGame();
game.RunOneFrame();
return game;
}
}
public class GameTestFixture {
protected TestGame Game { get; private set; }
[SetUp]
public void SetUpGame() {
this.Game = TestGame.Create();
}
[TearDown]
public void TearDownGame() {
this.Game?.Dispose();
this.Game = null;
}
}