Files
Tig d303943809 Fixes #4004 & #4445 - Merge of Application.ForceDriver and Driver.Force16Colors and windows" broken in conhost and cmd (#4448)
* Fixes #4004. Driver "windows" broken in conhost and cmd

* Fix unit tests

* Remove IsVirtualTerminal from IApplication. Add IDriverInternal and IOutputInternal interfaces

* Fix result.IsSupported

* Remove internal interfaces and add them in the implementations classes

* Move Sixel from IApplication to IDriver interface it's a characteristic of the driver

* Only if IOutput is OutputBase then set the internal properties

* Prevents driver windows error on Unix system

* Fix scenario sixel error

* Comment some tests because is keyboard layout dependent and shifted key is needed to produce them (Pt)

* Add 🇵🇹 regional indicators test proving they ca be joined as only one grapheme

* SetConsoleActiveScreenBuffer is already called by the constructor and is only needed once

* Finally fixed non virtual terminal in windows driver

* Add more Sixel unit tests

* Add unit tests for OutputBase class

* Avoid emit escape sequence

* Fix assertion failure in UICatalog

* Let each driver to deal with the Sixel write

* When Shutdown is called by the static Application then the ApplicationImpl.ResetStateStatic should be also called

* Add more OutputBase with Sixel unit tests

* Fix some issues with IsVirtualTerminal and Force16Colors with unit tests improvement

* Add Sixel Detect method unit test

* Make Sixel IsSupported and SupportsTransparency consistent with more unit tests

* Fix namespaces and unit test

* Covering more ApplicationImpl Sixel unit test

* Remove DriverImplProxy because sometimes fails in parallel unit tests

* Fix Init_KeyBindings_Are_Not_Reset unit test failing

* Revert "Fix Init_KeyBindings_Are_Not_Reset unit test failing"

This reverts commit 0ab298bc56.

* Fix Force16Colors but still use Application.Force16Colors because of CM

* Enforce conditional

* Revert change

* Moving to a new file

* Add the same workaround as the All_Scenarios_Benchmark unit test

* Fixes #4440. TextView with ReadOnly as true, MoveRight doesn't select text up to the end of the line

* Fixes #4442. TextField PositionCursor doesn't treat zero width as one column

* Each character must return at least one column, with the exception of Tab.

* Add unit test for the ScrollOffset

* Each character must return at least one column, with the exception of Tab.

* Add unit test for the LeftColumn

* WIP

* Refactor DriverImpl and OutputBase for maintainability

Refactored `DriverImpl` to remove `IDisposable` and streamline event
handling, including replacing `OnSizeMonitorOnSizeChanged` with an
inline lambda. Reintroduced `SizeChanged` and updated `SetScreenSize`
to invoke it. Moved `SupportsTrueColor` from `OutputBase` to
`DriverImpl` and reintroduced `Force16Colors` with updated logic.

Reintroduced and updated several `OutputBuffer`-related properties
and methods in `DriverImpl`, including `Screen`, `Clip`, `Cols`, and
`Contents`. Moved `Clipboard` from `OutputBase` to `DriverImpl` and
initialized it with `FakeClipboard`. Simplified `Refresh` and `ToAnsi`
methods in `DriverImpl`.

Removed `Force16Colors` from `OutputBase` and simplified method
signatures, including `ToAnsi` and `BuildAnsiForRegion`. Fixed a
parameter name typo in `AppendOrWriteAttribute`. Made minor code
formatting adjustments.

These changes improve code maintainability, reduce redundancy, and
align the implementation with updated design requirements.

* Refactor Force16Colors handling and improve UICatalog

Refactored the `Force16Colors` property:
- Moved it from `DriverImpl` to `IOutput` and `OutputBase`.
- Simplified its management by removing redundant logic.
- Added `OnDriverOnForce16ColorsChanged` to handle updates.

Updated `UICatalogRunnable`:
- Replaced `Driver.Force16Colors` with `Application.Driver.Force16Colors`.
- Added an `F7` shortcut to toggle `Force16Colors`.
- Removed redundant event handlers and improved formatting.

Updated `config.json`:
- Replaced `Application.Force16Colors` with `Driver.Force16Colors`.
- Improved theme configuration formatting for readability.

Other changes:
- Removed the `force16Colors` parameter from `IOutput.ToAnsi`.
- Improved diagnostics handling in `UICatalogRunnable`.
- General code cleanup for readability and maintainability.

* Refactor `Force16Colors` access and improve null safety

Refactored `Force16Colors` property access to use `Application.Driver!`
for null safety and consistency. Updated event handlers to align with
this pattern. Replaced nullable `DrawContext?` parameters with
non-nullable `DrawContext` in `OnDrawingContent` overrides across
multiple classes to enforce stricter nullability checks.

Removed unused `_cachedCursorVisibility` field in `OutputBase.cs` and
cleaned up commented-out legacy code in `UICatalogRunnable.cs`. Updated
XML documentation to reflect method signature changes and property
references. Refactored `Shortcut` example in documentation for
consistency.

Replaced `Application.LayoutAndDraw` with `SetNeedsDraw` for marking
views as needing redraw. Performed general code cleanup to remove
redundant code and improve consistency.

* Refactor ForceDriver and Force16Colors properties

Removed `[Obsolete]` from `Application.ForceDriver`, making it a stable API. Added comments to clarify its role as a configuration property and its synchronization with `IApplication.ForceDriver`. Introduced `_forceDriver` as a private backing field.

Removed `Force16Colors` from `ApplicationImpl` and eliminated reset logic for `ForceDriver` and `Force16Colors` during shutdown, shifting state management responsibility to the library user.

Updated comments in `Driver.cs` to document `Force16Colors` as a configuration property and its synchronization with `IDriver.Force16Colors`. Retained `_force16Colors` as a private backing field for configuration overrides.

* Updated docs

* There is no way to detect Sixel transparency and so relying in VTS or Xterm with transparency

* Fix detect Sixel unit tests with the adjusting code

* Refactored Output.

* MErging

* - Added `OnDriverOnForce16ColorsChanged` method to handle `Driver.Force16ColorsChanged` events and update the `Force16Colors` property.

- Implemented `IDisposable` to ensure proper cleanup of resources, including unsubscribing from `SizeMonitor.SizeChanged` and `Driver.Force16ColorsChanged` events, and disposing of `_output`.
- Replaced inline `SizeMonitor.SizeChanged` event handler with a dedicated method, `OnSizeMonitorOnSizeChanged`, for better readability and maintainability.

- Simplified the `Screen` property by removing commented-out code and directly returning a `Rectangle` based on `OutputBuffer` dimensions.
- Updated the `Force16Colors` property to use `_output` for both getting and setting its value.
- Performed general cleanup, including removing unused code and improving code structure.

* merged

* Refactor Sixel handling with ConcurrentQueue

Replaced `List<SixelToRender>` with `ConcurrentQueue<SixelToRender>`
to improve thread safety and performance in sixel management.
Updated the `Images` class to avoid unnecessary removal and
re-creation of sixel objects by updating existing ones in place.

Refactored `Application.Sixel` to return a `ConcurrentQueue` and
introduced `GetSixels` in `IDriver` and `IOutput` for consistent
access. Updated `OutputBase` to use a private `ConcurrentQueue`
and adjusted rendering logic accordingly.

Removed legacy and redundant code, including `Application.Driver?.Sixel.Clear()`
and unused properties in `DriverImpl` and `ApplicationImpl`. Updated
tests in `OutputBaseTests` to align with the new implementation.

Added `using System.Collections.Concurrent` where necessary and
improved documentation to reflect the changes. These updates
enhance thread safety, simplify the codebase, and align with
modern concurrent programming practices.

* Tweak

* Refactor DriverImpl to use Dispose and improve modularity

Replaced `Driver.End()` with `Driver.Dispose()` across the codebase, aligning with the `IDisposable` pattern for proper resource cleanup. Updated `DriverImpl` to implement `Dispose`, ensuring event unsubscriptions and resource disposal.

Enhanced `DriverImpl` structure by organizing code into logical regions, improving modularity and readability. Refactored and reintroduced methods and properties like `Clipboard`, `Screen`, `SetScreenSize`, `Cols`, `Rows`, and others for better encapsulation.

Updated the `IDriver` interface to include `IDisposable` and reorganized it into regions. Added new methods and properties such as `Init`, `Refresh`, `Suspend`, `QueueAnsiRequest`, and `ToAnsi`.

Refactored unit tests to replace `driver.End()` with `driver.Dispose()` and ensured proper resource cleanup. Improved code comments and documentation for better clarity.

Aligned with modern C# practices, adopting features like null-coalescing operators and pattern matching. Removed redundant code, addressed some TODOs, and modularized the codebase for maintainability and extensibility.

* Refactor driver docs and update View.Driver usage

Updated `application.md` to clarify the purpose of the `View.Driver` property, replacing the obsolete `Application.Driver`. Added a reference to the "Drivers Deep Dive" documentation for further details.

Refactored the `OnDrawContent` method to use the `Driver` property, ensuring compatibility with the new driver architecture.

Added a new section, "Testing with the New Architecture," to `application.md`, highlighting the improved testability of the instance-based architecture.

Expanded and reorganized `drivers.md` to provide a detailed breakdown of the `IDriver` interface, including lifecycle, components, screen and display, color support, content buffer, drawing, cursor, input events, and ANSI escape sequences. Introduced new subsections for clarity and emphasized the modular design for maintainability.

Added a note in `drivers.md` discouraging direct access to the `Driver` and recommending higher-level abstractions like `Terminal.Gui.App.Application.Screen` and `Terminal.Gui.ViewBase.View` methods for positioning and drawing.

* Refactor IsVirtualTerminal to IsLegacyConsole

Replaced the `IsVirtualTerminal` property with `IsLegacyConsole` across the codebase to better represent legacy versus modern terminal environments. Updated logic in `SixelSupportDetector`, `DriverImpl`, and `OutputBase` to use the new property.

Refactored tests to align with the updated property, including renaming test methods, adjusting mock setups, and replacing `VirtualTerminalTests` with `LegacyConsoleTests`.

Simplified `WindowsOutput` implementation to handle console modes and sixel rendering based on `IsLegacyConsole`. Removed redundant code related to `IsVirtualTerminal`.

Improved code readability and maintainability by using more descriptive property names and ensuring consistency across the codebase. Updated `.DotSettings` with new entries.

* Update Examples/UICatalog/Scenarios/LineDrawing.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Examples/UICatalog/Scenarios/Images.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Examples/UICatalog/Scenarios/Images.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Terminal.Gui/App/IApplication.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Terminal.Gui/App/ApplicationImpl.Lifecycle.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Examples/UICatalog/Scenarios/ColorPicker.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Examples/UICatalog/Scenarios/ColorPicker.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix formatting and typo in code and documentation

Improved code readability in `LineDrawing.cs` by fixing spacing
around the ternary operator in `Width` and `Y` property assignments.
Corrected a typo in `drivers.md` by changing "Configuraiton Manager"
to "Configuration Manager" for accurate documentation.

* Test failure casued by assert left in by accident.

* Added a workaround in `OutputBase.cs` to address dirty cell handling in legacy console mode by marking all buffer cells as dirty.

Refactored `_disableMouseCb` event handling in `UICatalogRunnable.cs` to use the `Selecting` event for toggling `Application.IsMouseDisabled`. Simplified `MouseImpl.cs` by converting `App` to an auto-implemented property and removing redundant namespace usage.

Streamlined logging in `WindowsOutput.cs` by replacing verbose `Logging.Logger` calls with shorter alternatives (`Logging.Information`, `Logging.Error`, etc.).

* Update theme and remove unused ListView component

The application's default theme configuration was updated from "Light" to "Amber Phosphor" by modifying the `ConfigurationManager.RuntimeConfig` value.

Additionally, the `ListView` component in the `ExampleWindow` class was removed. This included its initialization, layout properties (`Y`, `Height`, `Width`), and its data source (["One", "Two", "Three", "Four"]).

* Increase safety timeout in NestedRunTimeoutTests to 10s

The timeout duration for the safety mechanism in the
`NestedRunTimeoutTests` class was increased from 5000ms (5s)
to 10000ms (10s). This change allows the app more time to
complete before triggering the safety timeout, reducing the
likelihood of premature termination during long-running tests.

Refactor and enhance test coverage

Refactored `Load_WithInvalidJson_AddsJsonError` test in `SourcesManagerTests.cs` to improve organization and added a note about its impact on parallel execution. Increased the safety timeout in `NestedRunTimeoutTests.cs` from 5 seconds to 10 seconds to address potential premature test timeouts.

* Handle null Driver gracefully in event subscription

Replaced `ArgumentNullException.ThrowIfNull(Driver)` with a null-check conditional in `SubscribeDriverEvents` and `UnsubscribeDriverEvents`. If `Driver` is `null`, the methods now log an error using `Logging.Error` and return early. This prevents potential exceptions and improves error handling.

---------

Co-authored-by: BDisp <bd.bdisp@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-05 17:40:48 -07:00

377 lines
12 KiB
C#
Raw Permalink Blame History

using System.Text;
using UnitTests;
using Xunit.Abstractions;
namespace DriverTests;
/// <summary>
/// Tests for the ToAnsi functionality that generates ANSI escape sequences from buffer contents.
/// </summary>
public class ToAnsiTests : FakeDriverBase
{
[Fact]
public void ToAnsi_Empty_Buffer ()
{
IDriver driver = CreateFakeDriver (10, 5);
string ansi = driver.ToAnsi ();
// Empty buffer should have newlines for each row
Assert.Contains ("\n", ansi);
// Should have 5 newlines (one per row)
Assert.Equal (5, ansi.Count (c => c == '\n'));
}
[Fact]
public void ToAnsi_Simple_Text ()
{
IDriver driver = CreateFakeDriver (10, 3);
driver.AddStr ("Hello");
driver.Move (0, 1);
driver.AddStr ("World");
string ansi = driver.ToAnsi ();
// Should contain the text
Assert.Contains ("Hello", ansi);
Assert.Contains ("World", ansi);
// Should have proper structure with newlines
string [] lines = ansi.Split (['\r', '\n'], StringSplitOptions.RemoveEmptyEntries);
Assert.Equal (3, lines.Length);
}
[Theory]
[InlineData (true, "\u001b[31m", "\u001b[34m")]
[InlineData (false, "\u001b[38;2;255;0;0m", "\u001b[38;2;0;0;255")]
public void ToAnsi_With_Colors (bool force16Colors, string expectedRed, string expectedBue)
{
IDriver driver = CreateFakeDriver (10, 2);
driver.Force16Colors = force16Colors;
// Set red foreground
driver.CurrentAttribute = new Attribute (Color.Red, Color.Black);
driver.AddStr ("Red");
driver.Move (0, 1);
// Set blue foreground
driver.CurrentAttribute = new Attribute (Color.Blue, Color.Black);
driver.AddStr ("Blue");
string ansi = driver.ToAnsi ();
Assert.True (driver.Force16Colors == force16Colors);
// Should contain ANSI color codes
Assert.Contains (expectedRed, ansi); // Red foreground
Assert.Contains (expectedBue, ansi); // Blue foreground
Assert.Contains ("Red", ansi);
Assert.Contains ("Blue", ansi);
}
[Theory (Skip = "Uses Application.")]
[InlineData (false, "\u001b[48;2;")]
[InlineData (true, "\u001b[41m")]
public void ToAnsi_With_Background_Colors (bool force16Colors, string expected)
{
IDriver driver = CreateFakeDriver (10, 2);
driver.Force16Colors = force16Colors;
// Set background color
driver.CurrentAttribute = new (Color.White, Color.Red);
driver.AddStr ("WhiteOnRed");
string ansi = driver.ToAnsi ();
/*
The ANSI escape sequence for red background (8-color) is ESC[41m <20> where ESC is \x1b (or \u001b).
Examples:
<20> C# string: "\u001b[41m" or "\x1b[41m"
<20> Reset (clear attributes): "\u001b[0m"
Notes:
<20> Bright/red background (16-color bright variant) uses ESC[101m ("\u001b[101m").
<20> For 24-bit RGB background use ESC[48;2;<r>;<g>;<b>m, e.g. "\u001b[48;2;255;0;0m" for pure red.
*/
Assert.True (driver.Force16Colors == force16Colors);
// Should contain ANSI background color code
Assert.Contains (expected, ansi); // Red background
Assert.Contains ("WhiteOnRed", ansi);
}
[Fact]
public void ToAnsi_With_Text_Styles ()
{
IDriver driver = CreateFakeDriver (10, 3);
// Bold text
driver.CurrentAttribute = new Attribute (Color.White, Color.Black, TextStyle.Bold);
driver.AddStr ("Bold");
driver.Move (0, 1);
// Italic text
driver.CurrentAttribute = new Attribute (Color.White, Color.Black, TextStyle.Italic);
driver.AddStr ("Italic");
driver.Move (0, 2);
// Underline text
driver.CurrentAttribute = new Attribute (Color.White, Color.Black, TextStyle.Underline);
driver.AddStr ("Underline");
string ansi = driver.ToAnsi ();
// Should contain ANSI style codes
Assert.Contains ("\u001b[1m", ansi); // Bold
Assert.Contains ("\u001b[3m", ansi); // Italic
Assert.Contains ("\u001b[4m", ansi); // Underline
}
[Fact]
public void ToAnsi_With_Wide_Characters ()
{
IDriver driver = CreateFakeDriver (10, 2);
// Add a wide character (Chinese character)
driver.AddStr ("??");
driver.Move (0, 1);
driver.AddStr ("??");
string ansi = driver.ToAnsi ();
Assert.Contains ("??", ansi);
Assert.Contains ("??", ansi);
}
[Fact]
public void ToAnsi_With_Unicode_Characters ()
{
IDriver driver = CreateFakeDriver (10, 2);
// Add various Unicode characters
driver.AddStr ("???"); // Greek letters
driver.Move (0, 1);
driver.AddStr ("???"); // Emoji
string ansi = driver.ToAnsi ();
Assert.Contains ("???", ansi);
Assert.Contains ("???", ansi);
}
[Theory]
[InlineData (true, "\u001b[31m", "\u001b[34m")]
[InlineData (false, "\u001b[38;2;", "\u001b[48;2;")]
public void ToAnsi_Attribute_Changes_Within_Line (bool force16Colors, string expectedRed, string expectedBlue)
{
IDriver driver = CreateFakeDriver (20, 1);
driver.Force16Colors = force16Colors;
driver.AddStr ("Normal");
driver.CurrentAttribute = new Attribute (Color.Red, Color.Black);
driver.AddStr ("Red");
driver.CurrentAttribute = new Attribute (Color.Blue, Color.Black);
driver.AddStr ("Blue");
string ansi = driver.ToAnsi ();
Assert.True (driver.Force16Colors == force16Colors);
// Should contain color changes within the line
Assert.Contains ("Normal", ansi);
Assert.Contains (expectedRed, ansi); // Red
Assert.Contains (expectedBlue, ansi); // Blue
}
[Fact]
public void ToAnsi_Large_Buffer ()
{
// Test with a larger buffer to stress performance
IDriver driver = CreateFakeDriver (200, 50);
// Fill with some content
for (int row = 0; row < 50; row++)
{
driver.Move (0, row);
driver.CurrentAttribute = new Attribute ((ColorName16)(row % 16), Color.Black);
driver.AddStr ($"Row {row:D2} content");
}
string ansi = driver.ToAnsi ();
// Should contain all rows
Assert.Contains ("Row 00", ansi);
Assert.Contains ("Row 49", ansi);
// Should have proper newlines (50 content lines + 50 newlines)
Assert.Equal (50, ansi.Count (c => c == '\n'));
}
[Fact]
public void ToAnsi_RGB_Colors ()
{
IDriver driver = CreateFakeDriver (10, 1);
// Use RGB colors (when not forcing 16 colors)
driver.Force16Colors = false;
try
{
driver.CurrentAttribute = new Attribute (new Color (255, 0, 0), new Color (0, 255, 0));
driver.AddStr ("RGB");
string ansi = driver.ToAnsi ();
// Should contain RGB color codes
Assert.Contains ("\u001b[38;2;255;0;0m", ansi); // Red foreground RGB
Assert.Contains ("\u001b[48;2;0;255;0m", ansi); // Green background RGB
}
finally
{
driver.Force16Colors = true; // Reset
}
}
[Fact]
public void ToAnsi_Force16Colors ()
{
IDriver driver = CreateFakeDriver (10, 1);
// Force 16 colors
driver.Force16Colors = true;
driver.CurrentAttribute = new Attribute (Color.Red, Color.Blue);
driver.AddStr ("16Color");
string ansi = driver.ToAnsi ();
// Should contain 16-color codes, not RGB
Assert.Contains ("\u001b[31m", ansi); // Red foreground (16-color)
Assert.Contains ("\u001b[44m", ansi); // Blue background (16-color)
Assert.DoesNotContain ("\u001b[38;2;", ansi); // No RGB codes
}
[Theory]
[InlineData (true, "\u001b[31m", "\u001b[32m", "\u001b[34m", "\u001b[33m", "\u001b[35m", "\u001b[36m")]
[InlineData (false, "\u001b[38;2;255;0;0m", "\u001b[38;2;0;128;0m", "\u001b[38;2;0;0;255", "\u001b[38;2;255;255;0m", "\u001b[38;2;255;0;255m", "\u001b[38;2;0;255;255m")]
public void ToAnsi_Multiple_Attributes_Per_Line (
bool force16Colors,
string expectedRed,
string expectedGreen,
string expectedBlue,
string expectedYellow,
string expectedMagenta,
string expectedCyan
)
{
IDriver driver = CreateFakeDriver (50, 1);
driver.Force16Colors = force16Colors;
// Create a line with many attribute changes
string [] colors = { "Red", "Green", "Blue", "Yellow", "Magenta", "Cyan" };
foreach (string colorName in colors)
{
Color fg = colorName switch
{
"Red" => Color.Red,
"Green" => Color.Green,
"Blue" => Color.Blue,
"Yellow" => Color.Yellow,
"Magenta" => Color.Magenta,
"Cyan" => Color.Cyan,
_ => Color.White
};
driver.CurrentAttribute = new (fg, Color.Black);
driver.AddStr (colorName);
}
string ansi = driver.ToAnsi ();
Assert.True (driver.Force16Colors == force16Colors);
// Should contain multiple color codes
Assert.Contains (expectedRed, ansi); // Red
Assert.Contains (expectedGreen, ansi); // Green
Assert.Contains (expectedBlue, ansi); // Blue
Assert.Contains (expectedYellow, ansi); // Yellow
Assert.Contains (expectedMagenta, ansi); // Magenta
Assert.Contains (expectedCyan, ansi); // Cyan
}
[Fact]
public void ToAnsi_Special_Characters ()
{
IDriver driver = CreateFakeDriver (20, 1);
// Test backslash character
driver.AddStr ("Backslash:");
driver.AddRune ('\\');
string ansi = driver.ToAnsi ();
Assert.Contains ("Backslash:", ansi);
Assert.Contains ("\\", ansi);
}
[Fact]
public void ToAnsi_Buffer_Boundary_Conditions ()
{
// Test with minimum buffer size
IDriver driver = CreateFakeDriver (1, 1);
driver.AddStr ("X");
string ansi = driver.ToAnsi ();
Assert.Contains ("X", ansi);
Assert.Contains ("\n", ansi);
// Test with very wide buffer
driver = CreateFakeDriver (1000, 1);
driver.AddStr ("Wide");
ansi = driver.ToAnsi ();
Assert.Contains ("Wide", ansi);
Assert.True (ansi.Length > 1000); // Should have many spaces
}
[Fact]
public void ToAnsi_Empty_Lines ()
{
IDriver driver = CreateFakeDriver (10, 3);
// Only write to first and third lines
driver.AddStr ("First");
driver.Move (0, 2);
driver.AddStr ("Third");
string ansi = driver.ToAnsi ();
string [] lines = ansi.Split ('\n');
Assert.Equal (4, lines.Length); // 3 content lines + 1 empty line at end
Assert.Contains ("First", lines [0]);
Assert.Contains ("Third", lines [2]);
}
[Fact]
public void ToAnsi_Performance_Stress_Test ()
{
// Create a large buffer and fill it completely
const int width = 200;
const int height = 100;
IDriver driver = CreateFakeDriver (width, height);
// Fill every cell with different content and colors
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
driver.Move (col, row);
driver.CurrentAttribute = new Attribute ((ColorName16)((row + col) % 16), Color.Black);
driver.AddRune ((char)('A' + ((row + col) % 26)));
}
}
// This should complete in reasonable time and not throw
string ansi = driver.ToAnsi ();
Assert.NotNull (ansi);
Assert.True (ansi.Length > width * height); // Should contain all characters plus ANSI codes
}
}