2
0
Эх сурвалжийг харах

Fixed textformatter tests

Tigger Kindel 2 жил өмнө
parent
commit
561579584f

+ 7 - 3
UICatalog/Scenarios/Generic.cs

@@ -17,9 +17,12 @@ namespace UICatalog.Scenarios {
 			//    that reads "Press <hotkey> to Quit". Access this Window with `this.Win`.
 			//    that reads "Press <hotkey> to Quit". Access this Window with `this.Win`.
 			//  - Sets the Theme & the ColorScheme property of `this.Win` to `colorScheme`.
 			//  - Sets the Theme & the ColorScheme property of `this.Win` to `colorScheme`.
 			// To override this, implement an override of `Init`.
 			// To override this, implement an override of `Init`.
+			
 			//base.Init ();
 			//base.Init ();
+			
 			// A common, alternate, implementation where `this.Win` is not used is below. This code
 			// A common, alternate, implementation where `this.Win` is not used is below. This code
-			// leverages ConfigurationManager to borrow the color scheme settings from UICatalog
+			// leverages ConfigurationManager to borrow the color scheme settings from UICatalog:
+			
 			Application.Init ();
 			Application.Init ();
 			ConfigurationManager.Themes.Theme = Theme;
 			ConfigurationManager.Themes.Theme = Theme;
 			ConfigurationManager.Apply ();
 			ConfigurationManager.Apply ();
@@ -31,14 +34,15 @@ namespace UICatalog.Scenarios {
 			// Put scenario code here (in a real app, this would be the code
 			// Put scenario code here (in a real app, this would be the code
 			// that would setup the app before `Application.Run` is called`).
 			// that would setup the app before `Application.Run` is called`).
 			// With a Scenario, after UI Catalog calls `Scenario.Setup` it calls
 			// With a Scenario, after UI Catalog calls `Scenario.Setup` it calls
-			// `Scenario.Run` which calls `Application.Run`.
-			// Example:
+			// `Scenario.Run` which calls `Application.Run`. Example:
+
 			var button = new Button ("Press me!") {
 			var button = new Button ("Press me!") {
 				AutoSize = false,
 				AutoSize = false,
 				X = Pos.Center (),
 				X = Pos.Center (),
 				Y = Pos.Center (),
 				Y = Pos.Center (),
 			};
 			};
 			Win.Add (button);
 			Win.Add (button);
+
 		}
 		}
 	}
 	}
 }
 }

+ 12 - 9
UnitTests/Text/TextFormatterTests.cs

@@ -3060,8 +3060,6 @@ Demo Simple Rune
 			Application.Top.Add (label);
 			Application.Top.Add (label);
 			Application.Begin (Application.Top);
 			Application.Begin (Application.Top);
 
 
-			Assert.True (label.AutoSize);
-			Assert.Equal (new Rect (0, 0, 1, 16), label.Frame);
 			Assert.NotNull (label.Width);
 			Assert.NotNull (label.Width);
 			Assert.NotNull (label.Height);
 			Assert.NotNull (label.Height);
 
 
@@ -3115,9 +3113,6 @@ e
 			Application.Top.Add (label);
 			Application.Top.Add (label);
 			Application.Begin (Application.Top);
 			Application.Begin (Application.Top);
 
 
-			Assert.True (label.AutoSize);
-			Assert.Equal (new Rect (0, 0, 2, 7), label.Frame);
-
 			var expected = @"
 			var expected = @"
@@ -4176,7 +4171,7 @@ This TextFormatter (tf2) is rewritten.
 			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
 			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
 
 
 			var expected = @"
 			var expected = @"
-┌ 𝔹 ────┐
+┌┤𝔹├────┐
 │𝔹      │
 │𝔹      │
 │𝔹      │
 │𝔹      │
 └────────┘";
 └────────┘";
@@ -4194,7 +4189,7 @@ This TextFormatter (tf2) is rewritten.
 			};
 			};
 
 
 			TestHelpers.AssertDriverColorsAre (@"
 			TestHelpers.AssertDriverColorsAre (@"
-0222200000
+0022000000
 0000000000
 0000000000
 0111000000
 0111000000
 0000000000", expectedColors);
 0000000000", expectedColors);
@@ -4292,7 +4287,8 @@ t     ", output);
 		[Fact, AutoInitShutdown]
 		[Fact, AutoInitShutdown]
 		public void Draw_Negative_Bounds_Horizontal_Without_New_Lines ()
 		public void Draw_Negative_Bounds_Horizontal_Without_New_Lines ()
 		{
 		{
-			var subView = new View () { Id = "subView", Y = 1, Width = 7, Text = "subView" };
+			// BUGBUG: This previously assumed the default height of a View was 1. 
+			var subView = new View () { Id = "subView", Y = 1, Width = 7, Height = 1, Text = "subView" };
 			var view = new View () { Id = "view", Width = 20, Height = 2, Text = "01234567890123456789" };
 			var view = new View () { Id = "view", Width = 20, Height = 2, Text = "01234567890123456789" };
 			view.Add (subView);
 			view.Add (subView);
 			var content = new View () { Id = "content", Width = 20, Height = 20 };
 			var content = new View () { Id = "content", Width = 20, Height = 20 };
@@ -4301,7 +4297,13 @@ t     ", output);
 			container.Add (content);
 			container.Add (content);
 			var top = Application.Top;
 			var top = Application.Top;
 			top.Add (container);
 			top.Add (container);
-			Application.Driver.Clip = container.Frame;
+			// BUGBUG: v2 - it's bogus to reference .Frame before BeginInit. And why is the clip being set anyway???
+
+			void Top_LayoutComplete (object sender, LayoutEventArgs e)
+			{
+				Application.Driver.Clip = container.Frame;
+			}
+			top.LayoutComplete += Top_LayoutComplete;
 			Application.Begin (top);
 			Application.Begin (top);
 
 
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
@@ -4329,6 +4331,7 @@ t     ", output);
 			TestHelpers.AssertDriverContentsWithFrameAre ("", output);
 			TestHelpers.AssertDriverContentsWithFrameAre ("", output);
 		}
 		}
 
 
+
 		[Fact, AutoInitShutdown]
 		[Fact, AutoInitShutdown]
 		public void Draw_Negative_Bounds_Horizontal_With_New_Lines ()
 		public void Draw_Negative_Bounds_Horizontal_With_New_Lines ()
 		{
 		{