Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input completion test suite #4644

Merged
merged 21 commits into from
May 21, 2023

Conversation

dnsge
Copy link
Contributor

@dnsge dnsge commented May 20, 2023

Description

Adds tests for InputCompletionPopup and CompletionModel behavior as a precursor to merging #4639. While developing these tests I identified two discrepancies in behavior from #4639 which I will fix (eventually).

This PR needed to make some changes to BttvEmotes (among others) to allow directly setting loaded emotes for mocking. It looks a bit weird but it seems necessary.

Benchmarking

I've all but finished writing benchmarks for the existing input completion code. However, I can't figure out a smart way to access tests/src/mocks from both tests and benchmarks. The code should obviously be shared. I tried moving it to src but that would require linking gtest into chatterino-lib (I think), which I don't understand the full implications of (nor would be I able to modify the cmake config to do so).

If anyone (read: pajlada) can think of a way to share the mocks between tests and benchmarks and how to configure CMakeLists.txt (as I also can't figure that out when simply copying tests/src/mocks to benchmarks/src/mocks), I'd be very grateful :)

@dnsge
Copy link
Contributor Author

dnsge commented May 20, 2023

I'll note that this PR does not include completion tests for username nor commands. Testing these would require a fully mockable TwitchChannel instance because the completion code relies on a dynamic cast.

This is one of the advantages of the new system in the pending PR as strategies are testable outside of sources.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

benchmarks/src/Highlights.cpp Outdated Show resolved Hide resolved
src/widgets/splits/InputCompletionPopup.cpp Show resolved Hide resolved
src/widgets/splits/InputCompletionPopup.hpp Show resolved Hide resolved
Copy link
Contributor

@Nerixyz Nerixyz left a comment

Choose a reason for hiding this comment

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

Small things I noticed while looking at this.

src/providers/seventv/SeventvEmotes.hpp Outdated Show resolved Hide resolved
tests/src/InputCompletion.cpp Show resolved Hide resolved
benchmarks/src/Emojis.cpp Outdated Show resolved Hide resolved
@pajlada
Copy link
Member

pajlada commented May 20, 2023

I made the mock change to make them accessible for both tests & benchmarks here #4645

Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

Small nitpicks, haven't done a thorough review yet

src/common/CompletionModel.hpp Outdated Show resolved Hide resolved
src/common/CompletionModel.cpp Outdated Show resolved Hide resolved
src/widgets/splits/InputCompletionPopup.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/widgets/splits/InputCompletionPopup.cpp Show resolved Hide resolved
src/widgets/splits/InputCompletionPopup.cpp Show resolved Hide resolved
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

👍 Thank you!

@pajlada pajlada enabled auto-merge (squash) May 21, 2023 09:29
@pajlada pajlada merged commit 51f2c4d into Chatterino:master May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants