浏览代码

Rewritten this unit test.

BDisp 1 年之前
父节点
当前提交
75669a4a76
共有 1 个文件被更改,包括 60 次插入60 次删除
  1. 60 60
      UnitTests/Views/LabelTests.cs

+ 60 - 60
UnitTests/Views/LabelTests.cs

@@ -215,66 +215,66 @@ public class LabelTests
         Assert.Equal (KeyCode.Null, label.HotKey);
     }
 
-    //    [Fact]
-    //    [AutoInitShutdown]
-    //    public void Label_Draw_Fill_Remaining_AutoSize_True ()
-    //    {
-    //        var label = new Label { Text = "This label needs to be cleared before rewritten." };
-
-    //        var tf1 = new TextFormatter { Direction = TextDirection.LeftRight_TopBottom };
-    //        tf1.Text = "This TextFormatter (tf1) without fill will not be cleared on rewritten.";
-    //        Size tf1Size = tf1.Size;
-
-    //        var tf2 = new TextFormatter { Direction = TextDirection.LeftRight_TopBottom, FillRemaining = true };
-    //        tf2.Text = "This TextFormatter (tf2) with fill will be cleared on rewritten.";
-    //        Size tf2Size = tf2.Size;
-
-    //        var top = new Toplevel ();
-    //        top.Add (label);
-    //        Application.Begin (top);
-
-    //        Assert.True (label.AutoSize);
-
-    //        tf1.Draw (
-    //                  new Rectangle (new Point (0, 1), tf1Size),
-    //                  label.GetNormalColor (),
-    //                  label.ColorScheme.HotNormal
-    //                 );
-
-    //        tf2.Draw (new Rectangle (new Point (0, 2), tf2Size), label.GetNormalColor (), label.ColorScheme.HotNormal);
-
-    //        TestHelpers.AssertDriverContentsWithFrameAre (
-    //                                                      @"
-    //This label needs to be cleared before rewritten.                       
-    //This TextFormatter (tf1) without fill will not be cleared on rewritten.
-    //This TextFormatter (tf2) with fill will be cleared on rewritten.       
-    //",
-    //                                                      _output
-    //                                                     );
-
-    //        label.Text = "This label is rewritten.";
-    //        label.Draw ();
-
-    //        tf1.Text = "This TextFormatter (tf1) is rewritten.";
-
-    //        tf1.Draw (
-    //                  new Rectangle (new Point (0, 1), tf1Size),
-    //                  label.GetNormalColor (),
-    //                  label.ColorScheme.HotNormal
-    //                 );
-
-    //        tf2.Text = "This TextFormatter (tf2) is rewritten.";
-    //        tf2.Draw (new Rectangle (new Point (0, 2), tf2Size), label.GetNormalColor (), label.ColorScheme.HotNormal);
-
-    //        TestHelpers.AssertDriverContentsWithFrameAre (
-    //                                                      @"
-    //This label is rewritten.                                               
-    //This TextFormatter (tf1) is rewritten.will not be cleared on rewritten.
-    //This TextFormatter (tf2) is rewritten.                                 
-    //",
-    //                                                      _output
-    //                                                     );
-    //    }
+    [Fact]
+    [AutoInitShutdown]
+    public void Label_Draw_Fill_Remaining_AutoSize_False ()
+    {
+        Size tfSize = new Size (80, 1);
+
+        var label = new Label { Text = "This label needs to be cleared before rewritten.", Width = tfSize.Width, Height = tfSize.Height };
+
+        var tf1 = new TextFormatter { Direction = TextDirection.LeftRight_TopBottom, Size = tfSize };
+        tf1.Text = "This TextFormatter (tf1) without fill will not be cleared on rewritten.";
+
+        var tf2 = new TextFormatter { Direction = TextDirection.LeftRight_TopBottom, Size = tfSize, FillRemaining = true };
+        tf2.Text = "This TextFormatter (tf2) with fill will be cleared on rewritten.";
+
+        var top = new Toplevel ();
+        top.Add (label);
+        Application.Begin (top);
+
+        Assert.False (label.TextFormatter.AutoSize);
+        Assert.False (tf1.AutoSize);
+        Assert.False (tf2.AutoSize);
+        Assert.False (label.TextFormatter.FillRemaining);
+        Assert.False (tf1.FillRemaining);
+        Assert.True (tf2.FillRemaining);
+
+        tf1.Draw (new Rectangle (new Point (0, 1), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
+
+        tf2.Draw (new Rectangle (new Point (0, 2), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
+
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"
+This label needs to be cleared before rewritten.                       
+This TextFormatter (tf1) without fill will not be cleared on rewritten.
+This TextFormatter (tf2) with fill will be cleared on rewritten.       ",
+                                                      _output
+                                                     );
+
+        Assert.False (label.NeedsDisplay);
+        Assert.False (label.LayoutNeeded);
+        Assert.False (label.SubViewNeedsDisplay);
+        label.Text = "This label is rewritten.";
+        Assert.True (label.NeedsDisplay);
+        Assert.True (label.LayoutNeeded);
+        Assert.False (label.SubViewNeedsDisplay);
+        label.Draw ();
+
+        tf1.Text = "This TextFormatter (tf1) is rewritten.";
+        tf1.Draw (new Rectangle (new Point (0, 1), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
+
+        tf2.Text = "This TextFormatter (tf2) is rewritten.";
+        tf2.Draw (new Rectangle (new Point (0, 2), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
+
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"
+This label is rewritten.                                               
+This TextFormatter (tf1) is rewritten.will not be cleared on rewritten.
+This TextFormatter (tf2) is rewritten.                                 ",
+                                                      _output
+                                                     );
+    }
 
     [Fact]
     [AutoInitShutdown]