aboutsummaryrefslogtreecommitdiffstatsci
path: root/unitTests/TestBackend.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-01-28 07:24:29 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-01-28 07:24:29 +0100
commit90015b93cd8d06f35d211ce65e2c9000e5fb4336 (patch)
tree9ad0b27290d02414dd0ab5a323bf522d54d0be7d /unitTests/TestBackend.cs
parentc9a6611afb5943153b82ef8d1a9bad0c589baf8a (diff)
unit test with iFace updates (layouting/clipping/drawing), chmod clean
Diffstat (limited to 'unitTests/TestBackend.cs')
-rw-r--r--unitTests/TestBackend.cs87
1 files changed, 87 insertions, 0 deletions
diff --git a/unitTests/TestBackend.cs b/unitTests/TestBackend.cs
new file mode 100644
index 00000000..b4b21645
--- /dev/null
+++ b/unitTests/TestBackend.cs
@@ -0,0 +1,87 @@
+// Copyright (c) 2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+using System.Globalization;
+using Crow;
+using NUnit.Framework;
+
+namespace unitTests
+{
+ public class TestInterface : Interface
+ {
+ public TestInterface (int width = 800, int height = 600, IBackend _backend = null)
+ : base (width, height, _backend, false) {
+ backend.Init (this);
+ }
+ public bool IsRunning {
+ get => running;
+ set { running = value; }
+ }
+ }
+ [TestFixture]
+ public class TestBackend : IBackend
+ {
+ TestInterface iFace;
+
+ [OneTimeSetUp]
+ public void Init ()
+ {
+ iFace = new TestInterface (800, 600, this);
+ iFace.Init ();
+ iFace.IsRunning = true;
+ }
+
+ [OneTimeTearDown]
+ public void Cleanup ()
+ {
+ iFace.IsRunning = false;
+ }
+
+ //[SetUp] public void InitTest (){}
+ //[TearDown] public void CleanupTest (){}
+
+ [Test]
+ public void Widget ()
+ => Assert.DoesNotThrow (()
+ => { iFace.LoadIMLFragment (@"<Widget/>"); iFace.Update (); }
+ , "iFace load IML fragment failed");
+ [Test]
+ public void Label ()
+ => Assert.DoesNotThrow (()
+ => { iFace.LoadIMLFragment (@"<Label Text='this is a test string'/>"); iFace.Update (); }
+ , "iFace load IML fragment failed");
+
+ [Test]
+ public void TemplatedControl ()
+ => Assert.DoesNotThrow (()
+ => { iFace.LoadIMLFragment (@"<CheckBox IsChecked='true'/>"); iFace.Update (); }
+ , "iFace load IML fragment failed");
+
+ #region IBackend implementation
+ public MouseCursor Cursor { set { } }
+
+ public bool Shift => false;
+
+ public bool Ctrl => false;
+
+ public bool Alt => false;
+
+ public void CleanUp () {}
+
+ public void Flush () {}
+
+ public void Init (Interface iFace)
+ {
+ iFace.surf = new Crow.Cairo.ImageSurface (Crow.Cairo.Format.Argb32, iFace.ClientRectangle.Width, iFace.ClientRectangle.Height);
+ }
+
+ public bool IsDown (Key key) => false;
+
+ public void ProcessEvents ()
+ {
+
+ }
+ #endregion
+ }
+}