Skip to content

Add some tests for TextBuffer::Reflow - #8715

Merged
6 commits merged into
mainfrom
dev/duhowett/reflow
Jan 18, 2021
Merged

6 commits merged into
mainfrom
dev/duhowett/reflow

Conversation

@DHowett

Copy link
Copy Markdown
Member

This is by no means comprehensive. It will be unmarked as draft when it
is more comprehensive.

This pull request adds some tests for resizing a TextBuffer and
reflowing its contents. Each test takes the form of an initial state and
a number of buffers of different sizes. The initial state is used to
seed the first TextBuffer, and the subsequent buffers are only used to
compare.

I manually reimplemented some of the DBCS logic to ensure that the
buffers contain exactly what they're supposed to. I know this is
non-ideal. After some of the CharRow changes in #8446 land, this will
need to be updated.

There's a cool bit of TAEF gore in here: the IDataSource. An IDataSource
allows us to programmatically return test cases. It's a code-only
version of its support for parameterized tests of the form Data:x = {0, 1, 2} .

The only downsides are...

  1. It looks like COM (it is not using COM under the hood, just the COM
    ABI)
  2. Property values must be returned as strings.

To best support rich test types, I used IDataSource to produce a lit of
array indices
and nothing more. The test is run once for array member,
and it is the test's responsibility to look up the object to which that
index refers.

Works great though! Each reflow test is its own unit, and a failure in
an earlier reflow test will not tank a later one.

@DHowett
Dustin L. Howett (DHowett) marked this pull request as draft January 6, 2021 20:04
@DHowett

Copy link
Copy Markdown
Member Author

Looks like this:

StartGroup: ReflowTests::TestReflowCases#export0
TAEF: Data[index]: 0
[0.0] Test case "SBCS, cursor remains in buffer, no circling, no original wrap"
[0.1] Resizing to 5x5
[0.2] Resizing to 6x5
[0.3] Resizing to 7x5
EndGroup: ReflowTests::TestReflowCases#export0 [Passed]

StartGroup: ReflowTests::TestReflowCases#export1
TAEF: Data[index]: 1
[1.0] Test case "SBCS, cursor remains in buffer, no circling, with original wrap"
[1.1] Resizing to 5x5
[1.2] Resizing to 6x5
[1.3] Resizing to 7x5
EndGroup: ReflowTests::TestReflowCases#export1 [Passed]

StartGroup: ReflowTests::TestReflowCases#export2
TAEF: Data[index]: 2
[2.0] Test case "DBCS, cursor remains in buffer, no circling, with original wrap"
[2.1] Resizing to 5x5
[2.2] Resizing to 6x5
[2.3] Resizing to 7x5
[2.4] Resizing to 8x5
EndGroup: ReflowTests::TestReflowCases#export2 [Passed]

we can customize that name (export0) if we want.

@DHowett

Copy link
Copy Markdown
Member Author

There are 30 conditional branches in Reflow.

I hit 22 of them.
3 are error cases (never hit).
5 are in viewport position retention (the std::optional arguments).

22 + 3 + 5 = 30

@DHowett
Dustin L. Howett (DHowett) marked this pull request as ready for review January 11, 2021 22:26
@DHowett Dustin L. Howett (DHowett) mentioned this pull request Jan 12, 2021
13 of 15 tasks
@DHowett

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

{ 5, 5 }, // reduce width by 1
{
{ L"ABCDE", true },
{ L"F$ ", false }, // [BUG] EXACT WRAP. $ should be alone on next line.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these [BUG] tags be filed and linked appropriately?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably not gonna file 20 new bugs for "reflow is broken", which is a well-known statement.

I should have used a less controversial word, like "[KNOWN BADNESS]"

};

#pragma region TAEF hookup for the test case array above
struct ArrayIndexTaefAdapterRow : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom | Microsoft::WRL::InhibitFtmBase>, IDataRow>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be cool if this got pulled out so that other tests could take advantage of this. Alas, that's already on your radar and probably out of scope for this PR.

@DHowett Dustin L. Howett (DHowett) added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 18, 2021
@ghost

Copy link
Copy Markdown

Hello Dustin L. Howett (@DHowett)!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
ghost merged commit fa0cd8c into main Jan 18, 2021
@ghost
ghost deleted the dev/duhowett/reflow branch January 18, 2021 21:51
MPela (mpela81) pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
This is by no means comprehensive. It will be unmarked as draft when it
is more comprehensive.

This pull request adds some tests for resizing a TextBuffer and
reflowing its contents. Each test takes the form of an initial state and
a number of buffers of different sizes. The initial state is used to
seed the first TextBuffer, and the subsequent buffers are only used to
compare.

I manually reimplemented some of the DBCS logic to ensure that the
buffers contain _exactly_ what they're supposed to. I know this is
non-ideal. After some of the CharRow changes in microsoft#8446 land, this will
need to be updated.

There's a cool bit of TAEF gore in here: the IDataSource. An IDataSource
allows us to programmatically return test cases. It's a code-only
version of its support for parameterized tests of the form `Data:x = {0,
1, 2}` . 

The only downsides are...

1. It looks like COM (it is not using COM under the hood, just the COM
   ABI)
2. Property values must be returned as strings.

To best support rich test types, I used IDataSource to produce _a lit of
array indices_ and nothing more. The test is run once for array member,
and it is the test's responsibility to look up the object to which that
index refers.

Works great though! Each reflow test is its own unit, and a failure in
an earlier reflow test will not tank a later one.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AutoMerge Marked for automatic merge by the bot when requirements are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants