Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Graphics.Tests MaterialTests
Namespace: DeltaEngine.Graphics.Tests
Assembly: DeltaEngine.Graphics.Tests (in DeltaEngine.Graphics.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The MaterialTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
MaterialTests | Initializes a new instance of the MaterialTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
CreateCustomMaterial | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
LoadSavedMaterial | ||
LoadSavedMaterialWithClearPadding | ||
LoadSavedMaterialWithPadding | ||
LoadSavedMaterialWithRotation | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
SetRenderSize |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, CloseAfterFirstFrame] public void CreateCustomMaterial() { var shader = ContentLoader.Create<Shader>( new ShaderCreationData(ShaderFlags.Position2DTextured)); var image = ContentLoader.Create<Image>(new ImageCreationData(Size.One)); var generatedMaterial = new Material(shader, image); Assert.IsNotNull(generatedMaterial); Assert.AreEqual(shader, generatedMaterial.Shader); Assert.IsNotNull(generatedMaterial.DiffuseMap); Assert.AreEqual(ScreenSpace.Current.FromPixelSpace(Size.One), generatedMaterial.MaterialRenderSize); }
[Test, CloseAfterFirstFrame] public void LoadSavedMaterial() { var loadedMaterial = ContentLoader.Load<Material>("DefaultMaterial"); Assert.AreEqual("DefaultMaterial", loadedMaterial.Name); Assert.IsTrue(loadedMaterial.Shader.Name.Contains(loadedMaterial.Shader.Flags.ToString()), loadedMaterial.Shader.Name); Assert.AreEqual("DeltaEngineLogo", loadedMaterial.DiffuseMap.Name); Assert.AreEqual(Color.White, loadedMaterial.DefaultColor); }
[Test, CloseAfterFirstFrame] public void LoadSavedMaterialWithPadding() { var loadedMaterial = ContentLoader.Load<Material>("DefaultMaterial"); loadedMaterial.RenderingCalculator = new RenderingCalculator(new AtlasRegion { PadLeft = 0.5f, PadRight = 0.5f, PadTop = 0.5f, PadBottom = 0.5f, IsRotated = false }); RenderingData result = loadedMaterial.RenderingCalculator.GetUVAndDrawArea( Rectangle.HalfCentered, Rectangle.One); Assert.AreEqual(result.RequestedUserUV, Rectangle.HalfCentered); }
[Test, CloseAfterFirstFrame] public void LoadSavedMaterialWithClearPadding() { var loadedMaterial = ContentLoader.Load<Material>("DefaultMaterial"); loadedMaterial.RenderingCalculator = new RenderingCalculator(new AtlasRegion { PadLeft = 0, PadRight = 0, PadTop = 0, PadBottom = 0, IsRotated = false }); var result = loadedMaterial.RenderingCalculator.GetUVAndDrawArea(Rectangle.HalfCentered, Rectangle.One); Assert.AreEqual(result.RequestedUserUV, Rectangle.HalfCentered); }
[Test, CloseAfterFirstFrame] public void LoadSavedMaterialWithRotation() { var loadedMaterial = ContentLoader.Load<Material>("DefaultMaterial"); loadedMaterial.RenderingCalculator = new RenderingCalculator(new AtlasRegion { PadLeft = 0.5f, PadRight = 0.5f, PadTop = 0.5f, PadBottom = 0.5f, IsRotated = true }); var result = loadedMaterial.RenderingCalculator.GetUVAndDrawArea(Rectangle.HalfCentered, Rectangle.One); Assert.AreEqual(result.RequestedUserUV, Rectangle.HalfCentered); }
[Test, CloseAfterFirstFrame] public void SetRenderSize() { var loadedMaterial = ContentLoader.Load<Material>("DefaultMaterial"); loadedMaterial.RenderSizeMode = RenderSizeMode.PixelBased; var pixelBasedSize = ScreenSpace.Current.ToPixelSpace(loadedMaterial.MaterialRenderSize); Assert.AreEqual(new Size(128), pixelBasedSize); SetPixelModeAndCheckTargetResolution(loadedMaterial, RenderSizeMode.SizeFor800X480, 800); SetPixelModeAndCheckTargetResolution(loadedMaterial, RenderSizeMode.SizeFor1024X768, 1024); SetPixelModeAndCheckTargetResolution(loadedMaterial, RenderSizeMode.SizeFor1280X720, 1280); SetPixelModeAndCheckTargetResolution(loadedMaterial, RenderSizeMode.SizeFor1920X1080, 1920); SetPixelModeAndCheckTargetResolution(loadedMaterial, RenderSizeMode.SizeForSettingsResolution, Settings.DefaultResolution.Width); }
See Also