Beispiel #1
0
        protected void PerformTest(Action <Game> testAction, GraphicsProfile?profileOverride = null, bool takeSnapshot = false)
        {
            // create the game instance
            var typeGame = GetType();
            var game     = (GameTestBase)Activator.CreateInstance(typeGame);

            if (profileOverride.HasValue)
            {
                game.GraphicsDeviceManager.PreferredGraphicsProfile = new[] { profileOverride.Value }
            }
            ;

            // register the tests.
            game.FrameGameSystem.IsUnitTestFeeding = true;
            game.FrameGameSystem.Draw(() => testAction(game));
            if (takeSnapshot)
            {
                game.FrameGameSystem.TakeScreenshot();
            }

            RunGameTest(game);
        }
 public override void Validate(GraphicsProfile?targetProf)
 {
     throw new NotImplementedException();
 }
Beispiel #3
0
        protected void PerformDrawTest(Action <Game, RenderDrawContext, RenderFrame> drawTestAction, GraphicsProfile?profileOverride = null, string subTestName = null, bool takeSnapshot = true)
        {
            // create the game instance
            var typeGame = GetType();
            var game     = (GameTestBase)Activator.CreateInstance(typeGame);

            if (profileOverride.HasValue)
            {
                game.GraphicsDeviceManager.PreferredGraphicsProfile = new[] { profileOverride.Value }
            }
            ;

            // register the tests.
            game.FrameGameSystem.IsUnitTestFeeding = true;
            var testName = TestContext.CurrentContext.Test.FullName + subTestName;

            if (takeSnapshot)
            {
                game.FrameGameSystem.TakeScreenshot(null, testName);
            }

            // add the render callback
            var graphicsCompositor = new SceneGraphicsCompositorLayers
            {
                Master =
                {
                    Renderers     =
                    {
                        new ClearRenderFrameRenderer {
                            Color = Color.Green, Name = "Clear frame"
                        },
                        new SceneDelegateRenderer((context, frame) => drawTestAction(game, context, frame)),
                    }
                }
            };
            var scene = new Scene {
                Settings = { GraphicsCompositor = graphicsCompositor }
            };

            game.SceneSystem.SceneInstance = new SceneInstance(Services, scene);

            RunGameTest(game);
        }
 /// <summary>
 /// Verifies that all contents of this texture are present, correct and match the capabilities of the device.
 /// </summary>
 /// <param name="targetProfile">The profile identifier that defines the capabilities of the device.</param>
 public abstract void Validate(GraphicsProfile?targetProfile);
Beispiel #5
0
        protected void PerformDrawTest(Action <GameTestBase, RenderDrawContext> drawTestAction, GraphicsProfile?profileOverride = null, string subTestName = null, bool takeSnapshot = true)
        {
            // create the game instance
            var typeGame = GetType();
            var game     = (GameTestBase)Activator.CreateInstance(typeGame);

            if (profileOverride.HasValue)
            {
                game.GraphicsDeviceManager.PreferredGraphicsProfile = new[] { profileOverride.Value }
            }
            ;

            // register the tests.
            game.FrameGameSystem.IsUnitTestFeeding = true;
            if (takeSnapshot)
            {
                game.FrameGameSystem.TakeScreenshot();
            }

            // setup empty scene
            var scene = new Scene();

            game.SceneSystem.SceneInstance = new SceneInstance(Services, scene);

            // add the render callback
            game.SceneSystem.GraphicsCompositor = new GraphicsCompositor
            {
                Game = new DelegateSceneRenderer(context => drawTestAction(game, context)),
            };

            RunGameTest(game);
        }