PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/Rendering/BasicTests/GraphicsTests.cs

#
C# | 87 lines | 68 code | 5 blank | 14 comment | 2 complexity | 5d1fde6fcd9a49be39396d4ed770943a MD5 | raw file
Possible License(s): Apache-2.0
  1. using Delta.Engine;
  2. using Delta.Utilities.Datatypes;
  3. using NUnit.Framework;
  4. namespace Delta.Rendering.BasicTests
  5. {
  6. internal class GraphicsTests
  7. {
  8. #region ClearColor (Static)
  9. /// <summary>
  10. /// Clear color: Simply test if the clear color is set properly.
  11. /// </summary>
  12. [Test]
  13. public static void ClearColor()
  14. {
  15. Color[] colors =
  16. {
  17. Color.Red,
  18. Color.Green,
  19. Color.Blue,
  20. Color.Yellow,
  21. Color.White,
  22. Color.Grey,
  23. Color.Black
  24. };
  25. int currentColorIndex = 0;
  26. Application.Start(delegate
  27. {
  28. if (Time.EverySecond)
  29. {
  30. currentColorIndex++;
  31. currentColorIndex %= colors.Length;
  32. Application.BackgroundColor = colors[currentColorIndex];
  33. }
  34. });
  35. }
  36. #endregion
  37. #region ClearBackgroundInsideLoop (Static)
  38. /// <summary>
  39. /// ClearBackgroundInsideLoop
  40. /// </summary>
  41. [Test]
  42. public static void ClearBackgroundInsideLoop()
  43. {
  44. Application.Start(delegate
  45. {
  46. Application.BackgroundColor = Color.Green;
  47. });
  48. }
  49. #endregion
  50. #region TestSolidColors (Static)
  51. /// <summary>
  52. /// Test solid colors
  53. /// </summary>
  54. [Test]
  55. public static void TestSolidColors()
  56. {
  57. Application.Start(delegate
  58. {
  59. if (Time.EverySecond)
  60. {
  61. Application.BackgroundColor = Color.NextSolidColor;
  62. }
  63. });
  64. }
  65. #endregion
  66. #region InitDevice (LongRunning)
  67. /// <summary>
  68. /// Initialize device, simply tests if we can initialize a graphics module.
  69. /// </summary>
  70. [Test, Category("Visual")]
  71. public static void InitDevice()
  72. {
  73. Application.Start(delegate
  74. {
  75. // Make sure that graphic is initialized
  76. // And immediately quit the app again
  77. Application.Quit();
  78. });
  79. }
  80. #endregion
  81. }
  82. }