Skip to content

Commit 2439ec5

Browse files
committed
Add fixture to enable existing tests for screen reader mode
Tests that depend on supported features such as menu completions, list view, inline predictions, continuation prompt, and colors are skipped. The "helper" module for running tests from the command-line and in AppVeyor is minimally updated to not skip the new fixture. A `BlankRestOfBuffer()` function implements the semantics of the `0J` control sequence in the mock console.
1 parent 1ddc750 commit 2439ec5

11 files changed

+158
-6
lines changed

test/CompletionTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ public void MenuCompletions_FilterByTyping()
177177
[SkippableFact]
178178
public void MenuCompletions_Navigation1()
179179
{
180+
Skip.If(ScreenReaderModeEnabled, "Menu completions are not supported in screen reader mode.");
181+
180182
// Test 'RightArrow' and 'LeftArrow' with the following menu:
181183
// Get-Many0 Get-Many3 Get-Many6 Get-Many9 Get-Many12
182184
// Get-Many1 Get-Many4 Get-Many7 Get-Many10 Get-Many13
@@ -304,6 +306,8 @@ public void MenuCompletions_Navigation1()
304306
[SkippableFact]
305307
public void MenuCompletions_Navigation2()
306308
{
309+
Skip.If(ScreenReaderModeEnabled, "Menu completions are not supported in screen reader mode.");
310+
307311
// Test 'RightArrow' with the following menu:
308312
// Get-Less0 Get-Less3 Get-Less6 Get-Less9 Get-Less12
309313
// Get-Less1 Get-Less4 Get-Less7 Get-Less10
@@ -387,6 +391,8 @@ public void MenuCompletions_Navigation2()
387391
[SkippableFact]
388392
public void MenuCompletions_Navigation3()
389393
{
394+
Skip.If(ScreenReaderModeEnabled, "Menu completions are not supported in screen reader mode.");
395+
390396
// Test 'LeftArrow' with the following menu:
391397
// Get-Less0 Get-Less3 Get-Less6 Get-Less9 Get-Less12
392398
// Get-Less1 Get-Less4 Get-Less7 Get-Less10
@@ -462,6 +468,8 @@ public void MenuCompletions_Navigation3()
462468
[SkippableFact]
463469
public void MenuCompletions_Navigation4()
464470
{
471+
Skip.If(ScreenReaderModeEnabled, "Menu completions are not supported in screen reader mode.");
472+
465473
// Test 'UpArrow' and 'DownArrow' with the following menu:
466474
// Get-Less0 Get-Less3 Get-Less6 Get-Less9 Get-Less12
467475
// Get-Less1 Get-Less4 Get-Less7 Get-Less10
@@ -633,6 +641,8 @@ public void MenuCompletions_Navigation5()
633641
[SkippableFact]
634642
public void MenuCompletions_Navigation6()
635643
{
644+
Skip.If(ScreenReaderModeEnabled, "Menu completions are not supported in screen reader mode.");
645+
636646
// Test 'UpArrow', 'DownArrow', 'LeftArrow', and 'RightArrow' with the following menu:
637647
// Get-NewDynamicParameters Get-NewStyle
638648
// Get-NewIdea
@@ -736,6 +746,8 @@ public void MenuCompletions_Navigation6()
736746
[SkippableFact]
737747
public void MenuCompletions_Navigation7()
738748
{
749+
Skip.If(ScreenReaderModeEnabled, "Menu completions are not supported in screen reader mode.");
750+
739751
// Trigger the menu completion from the last line in the screen buffer, which will cause the screen
740752
// to scroll up. Then test 'DownArrow' and 'UpArrow' with the following menu to verify if scrolling
741753
// was handled correctly:
@@ -968,6 +980,8 @@ public void MenuCompletions_ClearProperly()
968980
[SkippableFact]
969981
public void MenuCompletions_WorkWithListView()
970982
{
983+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
984+
971985
TestSetup(KeyMode.Cmd, new KeyHandler("Ctrl+Spacebar", PSConsoleReadLine.MenuComplete));
972986

973987
int listWidth = CheckWindowSize();
@@ -1032,6 +1046,8 @@ public void MenuCompletions_WorkWithListView()
10321046
[SkippableFact]
10331047
public void MenuCompletions_HandleScrolling1()
10341048
{
1049+
Skip.If(ScreenReaderModeEnabled, "Menu completions are not supported in screen reader mode.");
1050+
10351051
// This test case covers the fix to https://github.com/PowerShell/PSReadLine/issues/2928.
10361052
var basicScrollingConsole = new BasicScrollingConsole(keyboardLayout: _, width: 133, height: 10);
10371053
TestSetup(basicScrollingConsole, KeyMode.Cmd, new KeyHandler("Ctrl+Spacebar", PSConsoleReadLine.MenuComplete));
@@ -1127,6 +1143,8 @@ public void MenuCompletions_HandleScrolling1()
11271143
[SkippableFact]
11281144
public void MenuCompletions_HandleScrolling2()
11291145
{
1146+
Skip.If(ScreenReaderModeEnabled, "Menu completions are not supported in screen reader mode.");
1147+
11301148
// This test case covers the fix to https://github.com/PowerShell/PSReadLine/issues/2948.
11311149
var basicScrollingConsole = new BasicScrollingConsole(keyboardLayout: _, width: 133, height: 10);
11321150
TestSetup(basicScrollingConsole, KeyMode.Cmd, new KeyHandler("Ctrl+Spacebar", PSConsoleReadLine.MenuComplete));

test/InlinePredictionTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public partial class ReadLine
1414
[SkippableFact]
1515
public void Inline_RenderSuggestion()
1616
{
17+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
18+
1719
TestSetup(KeyMode.Cmd,
1820
new KeyHandler("Ctrl+f", PSConsoleReadLine.ForwardWord));
1921
using var disp = SetPrediction(PredictionSource.History, PredictionViewStyle.InlineView);
@@ -92,6 +94,8 @@ public void Inline_RenderSuggestion()
9294
[SkippableFact]
9395
public void Inline_CustomKeyBindingsToAcceptSuggestion()
9496
{
97+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
98+
9599
TestSetup(KeyMode.Cmd,
96100
new KeyHandler("Alt+g", PSConsoleReadLine.AcceptSuggestion),
97101
new KeyHandler("Alt+f", PSConsoleReadLine.AcceptNextSuggestionWord));
@@ -156,6 +160,8 @@ public void Inline_CustomKeyBindingsToAcceptSuggestion()
156160
[SkippableFact]
157161
public void Inline_AcceptNextSuggestionWordCanAcceptMoreThanOneWords()
158162
{
163+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
164+
159165
TestSetup(KeyMode.Cmd,
160166
new KeyHandler("Ctrl+f", PSConsoleReadLine.ForwardWord),
161167
new KeyHandler("Alt+f", PSConsoleReadLine.AcceptNextSuggestionWord));
@@ -192,6 +198,8 @@ public void Inline_AcceptNextSuggestionWordCanAcceptMoreThanOneWords()
192198
[SkippableFact]
193199
public void Inline_AcceptSuggestionWithSelection()
194200
{
201+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
202+
195203
TestSetup(KeyMode.Cmd,
196204
new KeyHandler("Ctrl+f", PSConsoleReadLine.ForwardWord));
197205
using var disp = SetPrediction(PredictionSource.History, PredictionViewStyle.InlineView);
@@ -261,6 +269,8 @@ public void Inline_DisablePrediction()
261269
[SkippableFact]
262270
public void Inline_SetPredictionColor()
263271
{
272+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
273+
264274
TestSetup(KeyMode.Cmd);
265275
var predictionColor = MakeCombinedColor(ConsoleColor.DarkYellow, ConsoleColor.Yellow);
266276
var predictionColorToCheck = Tuple.Create(ConsoleColor.DarkYellow, ConsoleColor.Yellow);
@@ -288,6 +298,8 @@ public void Inline_SetPredictionColor()
288298
[SkippableFact]
289299
public void Inline_HistoryEditsCanUndoProperly()
290300
{
301+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
302+
291303
TestSetup(KeyMode.Cmd,
292304
new KeyHandler("Ctrl+f", PSConsoleReadLine.ForwardWord));
293305
SetHistory("git checkout -b branch origin/bbbb");
@@ -320,6 +332,8 @@ public void Inline_HistoryEditsCanUndoProperly()
320332
[SkippableFact]
321333
public void Inline_AcceptSuggestionInVIMode()
322334
{
335+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
336+
323337
TestSetup(KeyMode.Vi);
324338
using var disp = SetPrediction(PredictionSource.History, PredictionViewStyle.InlineView);
325339

@@ -367,6 +381,8 @@ public void Inline_AcceptSuggestionInVIMode()
367381
[SkippableFact]
368382
public void ViDefect2408()
369383
{
384+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
385+
370386
TestSetup(KeyMode.Vi);
371387
using var disp = SetPrediction(PredictionSource.History, PredictionViewStyle.InlineView);
372388

@@ -460,6 +476,8 @@ internal static List<PredictionResult> MockedPredictInput(Ast ast, Token[] token
460476
[SkippableFact]
461477
public void Inline_PluginSource_Acceptance()
462478
{
479+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
480+
463481
// Using the 'Plugin' source will make PSReadLine get prediction from the plugin only.
464482
TestSetup(KeyMode.Cmd,
465483
new KeyHandler("Ctrl+f", PSConsoleReadLine.ForwardWord));
@@ -534,6 +552,8 @@ public void Inline_PluginSource_Acceptance()
534552
[SkippableFact]
535553
public void Inline_HistoryAndPluginSource_Acceptance()
536554
{
555+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
556+
537557
// Using the 'HistoryAndPlugin' source will make PSReadLine get prediction from the plugin and history,
538558
// and plugin takes precedence.
539559
TestSetup(KeyMode.Cmd,
@@ -798,6 +818,8 @@ public void Inline_HistoryAndPluginSource_ExecutionStatus()
798818
[SkippableFact]
799819
public void Inline_TruncateVeryLongSuggestion()
800820
{
821+
Skip.If(ScreenReaderModeEnabled, "Inline predictions are not supported in screen reader mode.");
822+
801823
TestSetup(new TestConsole(keyboardLayout: _, width: 10, height: 2), KeyMode.Cmd);
802824
using var disp = SetPrediction(PredictionSource.History, PredictionViewStyle.InlineView);
803825

test/KillYankTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,8 @@ public void SelectCommandArgument_CLIArgs()
672672
[SkippableFact]
673673
public void SelectCommandArgument_HereStringArgs()
674674
{
675+
Skip.If(ScreenReaderModeEnabled, "We're still investigating exactly why this test fails in screen reader mode.");
676+
675677
TestSetup(KeyMode.Cmd);
676678

677679
var continuationPrompt = PSConsoleReadLine.GetOptions().ContinuationPrompt;

test/ListPredictionTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public void List_RenderSuggestion_NoMatching_HistorySearchBackwardForward()
9696
[SkippableFact]
9797
public void List_RenderSuggestion_ListUpdatesWhileTyping()
9898
{
99+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
100+
99101
TestSetup(KeyMode.Cmd);
100102
int listWidth = CheckWindowSize();
101103
// The font effect sequences of the dimmed color used in list view metadata line
@@ -184,6 +186,8 @@ public void List_RenderSuggestion_ListUpdatesWhileTyping()
184186
[SkippableFact]
185187
public void List_RenderSuggestion_NavigateInList_DefaultUpArrowDownArrow()
186188
{
189+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
190+
187191
TestSetup(KeyMode.Cmd);
188192
int listWidth = CheckWindowSize();
189193
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);
@@ -401,6 +405,8 @@ public void List_RenderSuggestion_NavigateInList_DefaultUpArrowDownArrow()
401405
[SkippableFact]
402406
public void List_RenderSuggestion_NavigateInList_HistorySearchBackwardForward()
403407
{
408+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
409+
404410
TestSetup(KeyMode.Cmd,
405411
new KeyHandler("Ctrl+p", PSConsoleReadLine.HistorySearchBackward),
406412
new KeyHandler("Ctrl+l", PSConsoleReadLine.HistorySearchForward));
@@ -620,6 +626,8 @@ public void List_RenderSuggestion_NavigateInList_HistorySearchBackwardForward()
620626
[SkippableFact]
621627
public void List_RenderSuggestion_Escape()
622628
{
629+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
630+
623631
TestSetup(KeyMode.Cmd);
624632
int listWidth = CheckWindowSize();
625633
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);
@@ -783,6 +791,8 @@ public void List_RenderSuggestion_Escape()
783791
[SkippableFact]
784792
public void List_RenderSuggestion_DigitArgument()
785793
{
794+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
795+
786796
TestSetup(KeyMode.Cmd);
787797
int listWidth = CheckWindowSize();
788798
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);
@@ -943,6 +953,8 @@ public void List_RenderSuggestion_DigitArgument()
943953
[SkippableFact]
944954
public void List_RenderSuggestion_CtrlZ()
945955
{
956+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
957+
946958
TestSetup(KeyMode.Cmd);
947959
int listWidth = CheckWindowSize();
948960
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);
@@ -1076,6 +1088,8 @@ public void List_RenderSuggestion_CtrlZ()
10761088
[SkippableFact]
10771089
public void List_RenderSuggestion_Selection()
10781090
{
1091+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
1092+
10791093
TestSetup(KeyMode.Cmd);
10801094
int listWidth = CheckWindowSize();
10811095
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);
@@ -1276,6 +1290,8 @@ public void List_RenderSuggestion_Selection()
12761290
[SkippableFact]
12771291
public void List_HistorySource_NoAcceptanceCallback()
12781292
{
1293+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
1294+
12791295
TestSetup(KeyMode.Cmd);
12801296
int listWidth = CheckWindowSize();
12811297
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);
@@ -1340,6 +1356,8 @@ public void List_HistorySource_NoAcceptanceCallback()
13401356
[SkippableFact]
13411357
public void List_PluginSource_Acceptance()
13421358
{
1359+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
1360+
13431361
TestSetup(KeyMode.Cmd);
13441362
int listWidth = CheckWindowSize();
13451363
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);
@@ -1661,6 +1679,8 @@ public void List_PluginSource_Acceptance()
16611679
[SkippableFact]
16621680
public void List_HistoryAndPluginSource_Acceptance()
16631681
{
1682+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
1683+
16641684
TestSetup(KeyMode.Cmd);
16651685
int listWidth = CheckWindowSize();
16661686
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);
@@ -1994,6 +2014,8 @@ public void List_HistoryAndPluginSource_Acceptance()
19942014
[SkippableFact]
19952015
public void List_HistoryAndPluginSource_Deduplication()
19962016
{
2017+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
2018+
19972019
TestSetup(KeyMode.Cmd);
19982020
int listWidth = CheckWindowSize();
19992021
var dimmedColors = Tuple.Create(ConsoleColor.White, _console.BackgroundColor);

test/ListScrollableViewTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public partial class ReadLine
99
[SkippableFact]
1010
public void List_MetaLine_And_Paging_Navigation()
1111
{
12+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
13+
1214
int listWidth = 100;
1315
TestSetup(new TestConsole(keyboardLayout: _, width: listWidth, height: 15), KeyMode.Cmd);
1416

@@ -514,6 +516,8 @@ public void List_MetaLine_And_Paging_Navigation()
514516
[SkippableFact]
515517
public void ListView_AdapteTo_ConsoleSize()
516518
{
519+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
520+
517521
// Console size is very small (h: 6, w: 50), and thus the list view will adjust to use 3-line height,
518522
// and the metadata line will be reduced to only show the (index/total) info.
519523
int listWidth = 50;
@@ -850,6 +854,8 @@ public void ListView_AdapteTo_ConsoleSize()
850854
[SkippableFact]
851855
public void ListView_TermSize_Warning()
852856
{
857+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
858+
853859
// Console size is very small (h: 6, w: 50), and thus the list view will adjust to use 3-line height,
854860
// and the metadata line will be reduced to only show the (index/total) info.
855861
int listWidth = 40;

test/ListViewTooltipTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public partial class ReadLine
99
[SkippableFact]
1010
public void List_Item_Tooltip_4_Lines()
1111
{
12+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
13+
1214
// Set the terminal height to 22 and width to 60, so the metadata line will be fully rendered
1315
// and maximum 4 lines can be used for tooltip for a selected list item.
1416
int listWidth = 60;
@@ -206,6 +208,8 @@ public void List_Item_Tooltip_4_Lines()
206208
[SkippableFact]
207209
public void List_Item_Tooltip_2_Lines()
208210
{
211+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
212+
209213
// Set the terminal height to 15 and width to 60, so the metadata line will be fully rendered
210214
// and maximum 2 lines can be used for tooltip for a selected list item.
211215
int listWidth = 60;
@@ -363,6 +367,8 @@ public void List_Item_Tooltip_2_Lines()
363367
[SkippableFact]
364368
public void List_Item_Tooltip_1_Line()
365369
{
370+
Skip.If(ScreenReaderModeEnabled, "List view is not supported in screen reader mode.");
371+
366372
// Set the terminal height to 6 and width to 60, so the metadata line will be fully rendered
367373
// and maximum 2 lines can be used for tooltip for a selected list item.
368374
int listWidth = 60;

test/MockConsole.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,17 @@ public virtual void BlankRestOfLine()
300300
buffer[writePos + i].ForegroundColor = ForegroundColor;
301301
}
302302
}
303+
304+
public virtual void BlankRestOfBuffer()
305+
{
306+
var writePos = CursorTop * BufferWidth + CursorLeft;
307+
for (; writePos < buffer.Length; writePos++)
308+
{
309+
buffer[writePos].UnicodeChar = ' ';
310+
buffer[writePos].BackgroundColor = BackgroundColor;
311+
buffer[writePos].ForegroundColor = ForegroundColor;
312+
}
313+
}
303314

304315
public virtual void Clear()
305316
{
@@ -334,6 +345,7 @@ private static void ToggleNegative(TestConsole c, bool b)
334345
c.BackgroundColor = (ConsoleColor)((int)c.BackgroundColor ^ 7);
335346
c._negative = b;
336347
}
348+
337349
protected static readonly Dictionary<string, Action<TestConsole>> EscapeSequenceActions = new()
338350
{
339351
{"7", c => ToggleNegative(c, true) },
@@ -376,7 +388,8 @@ private static void ToggleNegative(TestConsole c, bool b)
376388
c.ForegroundColor = DefaultForeground;
377389
c.BackgroundColor = DefaultBackground;
378390
}},
379-
{"2J", c => c.SetCursorPosition(0, 0) }
391+
{ "0J", c => c.BlankRestOfBuffer() },
392+
{ "2J", c => c.SetCursorPosition(0, 0) },
380393
};
381394
}
382395

@@ -520,6 +533,17 @@ public override void BlankRestOfLine()
520533
}
521534
}
522535

536+
public override void BlankRestOfBuffer()
537+
{
538+
var writePos = (_offset + CursorTop) * BufferWidth + CursorLeft;
539+
for (; writePos < buffer.Length; writePos++)
540+
{
541+
buffer[writePos].UnicodeChar = ' ';
542+
buffer[writePos].BackgroundColor = BackgroundColor;
543+
buffer[writePos].ForegroundColor = ForegroundColor;
544+
}
545+
}
546+
523547
public override void Clear()
524548
{
525549
_offset = 0;

0 commit comments

Comments
 (0)