4 using System.Threading.Tasks;
7 using SiliconStudio.Core.Mathematics;
8 using SiliconStudio.Paradox.Games;
10 namespace SiliconStudio.
Paradox.Graphics.Regression
15 #region Public properties
21 protected TestContext CurrentTestContext {
get; set; }
25 #region Public members
39 private bool screenshotAutomationEnabled;
52 #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP
56 ImageTester.ImageTestResultConnection.BuildNumber = buildNumber;
66 #region public methods
74 if (textureToSave == null)
77 TestGameLogger.Info(
@"Saving non null image");
78 var testName = CurrentTestContext != null ? CurrentTestContext.Test.FullName : null;
79 TestGameLogger.Info(
@"saving remotely.");
80 using (var image = textureToSave.GetDataAsImage())
88 TestGameLogger.Error(
@"An error occurred when trying to send the data to the server.");
99 TestGameLogger.Info(
@"Saving the backbuffer");
106 public bool ScreenShotAutomationEnabled
110 return screenshotAutomationEnabled;
114 FrameGameSystem.Visible = value;
115 FrameGameSystem.Enabled = value;
116 screenshotAutomationEnabled = value;
122 #region Protected methods
126 await base.LoadContent();
128 Window.Position = Int2.Zero;
130 #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP
132 ImageTester.ImageTestResultConnection.DeviceName +=
"_" + GraphicsDevice.Adapter.Description;
135 Script.Add(RegisterTestsInternal);
138 private Task RegisterTestsInternal()
142 return Task.FromResult(
true);
153 if (!ScreenShotAutomationEnabled)
171 game.CurrentTestContext = TestContext.CurrentContext;
173 game.ScreenShotAutomationEnabled = !ForceInteractiveMode;
175 GameTester.RunGameTest(game);
178 Assert.IsTrue(ImageTester.RequestImageComparisonStatus(game.CurrentTestContext.Test.FullName),
"The image comparison returned false.");
183 #region Private methods
192 var currentVersion = CurrentVersion.ToString();
193 if (CurrentVersionExtra != null)
194 currentVersion += CurrentVersionExtra;
197 var frameIndex = FrameIndex++;
199 ImageTester.SendImage(
new TestResultImage { CurrentVersion = currentVersion, Frame = frameIndex.ToString(),
Image = image, TestName = testName });
204 #region Helper structures and classes
217 return Name +
" " + Serial +
" " + PlatformPermutator.GetPlatformName(Platform);
void SendImage(Image image, string testName)
Send the data of the test to the server.
static ImageTestResultConnection ImageTestResultConnection
int CurrentVersion
The current version of the test
override async Task LoadContent()
Loads the content.
Provides method to instantiate an image 1D/2D/3D supporting TextureArray and mipmaps on the CPU or to...
RenderTarget BackBuffer
Gets the back buffer sets by the current Presenter setup on this device.
static bool ForceInteractiveMode
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
bool ScreenShotAutomationEnabled
Gets or sets the value indicating if the screen shots automation should be enabled or not...
virtual void RegisterTests()
Method to register the tests.
Current timing used for variable-step (real time) or fixed-step (game time) games.
void SaveBackBuffer()
Save the image locally or on the server.
bool TakeSnapshot
Flag stating that a screenshot should be taken.
bool AllTestsCompleted
Flag stating that all the tests have been rendered.
override void Draw(GameTime gameTime)
Loop through all the tests and save the images.
readonly Texture Texture
The underlying texture.
string CurrentVersionExtra
The current version extra parameter (concatenated to CurrentVersionNumber).
static void RunGameTest(GraphicsTestBase game)
void SaveImage(Texture textureToSave)
Save the image locally or on the server.
override string ToString()
Base class for texture resources.
A structure to store information about the connected test devices.