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

[Android] add LocalClock to control time for screenshot test #1224

Merged
merged 14 commits into from
Sep 30, 2023

Conversation

tkhs0604
Copy link
Contributor

@tkhs0604 tkhs0604 commented Sep 15, 2023

Issue

Overview (Required)

  • SSIA
  • Adding a composition local for clock makes it slightly more adjustable to set datetime information for screenshot test

Links

Screenshot (Optional if screenshot test is present or unrelated to UI)

Before After

Movie (Optional)

Before After

@tkhs0604 tkhs0604 self-assigned this Sep 15, 2023
@tkhs0604 tkhs0604 requested a review from a team as a code owner September 15, 2023 15:14
@github-actions
Copy link

github-actions bot commented Sep 15, 2023

Test Results

216 tests   216 ✔️  8m 25s ⏱️
  11 suites      0 💤
  11 files        0

Results for commit d41ed3f.

♻️ This comment has been updated with latest results.

@tkhs0604 tkhs0604 closed this Sep 15, 2023
@tkhs0604 tkhs0604 reopened this Sep 16, 2023
@tkhs0604 tkhs0604 force-pushed the kenken/pass_clock_to_controll_time_in_preview branch from c39834b to 9cbdc1d Compare September 16, 2023 02:37
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 16, 2023 03:16 Inactive
@tkhs0604 tkhs0604 force-pushed the kenken/pass_clock_to_controll_time_in_preview branch from bf4a1bc to c8821ac Compare September 16, 2023 05:15
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 16, 2023 05:48 Inactive
Copy link
Contributor

@kubode kubode left a comment

Choose a reason for hiding this comment

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

I tried to work on #1219 but was told that the PR is already there.
I commented where I was concerned.

import kotlinx.datetime.Clock

@Suppress("CompositionLocalAllowList")
val LocalClockProvider = compositionLocalOf<Clock> {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, using staticCompositionLocalOf would be better performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the advice! Let me check the function and replace with it!

@tkhs0604
Copy link
Contributor Author

Hmm... The format error cannot be resolved even if I suppressed it 🫠...

@tkhs0604
Copy link
Contributor Author

x: @Suppress("CompositionLocalAllowList")
o: @Suppress("CompositionLocalAllowlist")
😢

@tkhs0604 tkhs0604 force-pushed the kenken/pass_clock_to_controll_time_in_preview branch from 34d9afb to ca1ca65 Compare September 16, 2023 08:24
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 16, 2023 08:52 Inactive
@tkhs0604 tkhs0604 changed the title [Android] add clock parameter to control time in preview [Android] add LocalClockProvider to control time in preview and test Sep 16, 2023
@tkhs0604 tkhs0604 changed the title [Android] add LocalClockProvider to control time in preview and test [Android] add LocalClock to control time in preview and test Sep 16, 2023
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 16, 2023 12:20 Inactive
@github-actions
Copy link

Hi @tkhs0604! Codes seem to be unformatted. To resolve this issue, please run ./gradlew detekt --auto-correct and fix the results of ./gradlew lintDebug.. Thank you for your contribution.

@tkhs0604 tkhs0604 force-pushed the kenken/pass_clock_to_controll_time_in_preview branch from 021e82f to 54e8242 Compare September 17, 2023 04:12
onTimetableItemClick = { },
onBookmarkIconClick = { },
)
CompositionLocalProvider(LocalClock provides FakeClock) {
Copy link
Contributor Author

@tkhs0604 tkhs0604 Sep 17, 2023

Choose a reason for hiding this comment

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

@takahirom
It does not seem like it works well...
Do you know how I can overwrite the CompositionLocal in test environment? 🤔

Maybe, since there is no setContent in KaigiAppTest, so the only way is to add like ClockTestRule or something like that?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure too.
By the way, you might have to fix the commit history 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I'll investigate the cause again 🙏
And regarding your BTW comment, which commits? All?

Copy link
Member

@takahirom takahirom Sep 17, 2023

Choose a reason for hiding this comment

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

Sorry, I might see old commits 🙇

Copy link
Contributor Author

@tkhs0604 tkhs0604 Sep 17, 2023

Choose a reason for hiding this comment

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

The FakeClock worked well for only TimetableScreenTest on my local, but the screenshot results haven't been updated even if I pushed some commits 👀
Is there any way to update them on this PR's comment?

In case of 2023-09-14T10:00:00.000Z
TimetableScreenTest checkGridScrollShot_compare

In case of 2023-09-15T10:00:00.000Z (To check the diff)
TimetableScreenTest checkGridScrollShot_compare

Copy link
Member

@takahirom takahirom Sep 30, 2023

Choose a reason for hiding this comment

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

I've removed the comment and rerun the test. Let's see what screenshots the tests take.

Copy link
Member

Choose a reason for hiding this comment

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

image It seems that there is no change 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! 🙌

@github-actions github-actions bot temporarily deployed to deploygate-distribution September 17, 2023 04:40 Inactive
@tkhs0604 tkhs0604 force-pushed the kenken/pass_clock_to_controll_time_in_preview branch from 54e8242 to fb54dac Compare September 17, 2023 05:48
@tkhs0604 tkhs0604 force-pushed the kenken/pass_clock_to_controll_time_in_preview branch from fb54dac to 046fba6 Compare September 17, 2023 05:49
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 17, 2023 06:17 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 17, 2023 12:54 Inactive
@tkhs0604 tkhs0604 changed the title [Android] add LocalClock to control time in preview and test [Android] add LocalClock to control time for screenshot test Sep 19, 2023
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 19, 2023 14:46 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 24, 2023 06:38 Inactive
@DroidKaigi DroidKaigi deleted a comment from github-actions bot Sep 30, 2023
@DroidKaigi DroidKaigi deleted a comment from github-actions bot Sep 30, 2023
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 30, 2023 08:37 Inactive
Copy link
Member

@takahirom takahirom left a comment

Choose a reason for hiding this comment

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

Thanks!

@takahirom takahirom merged commit 9559d15 into main Sep 30, 2023
8 checks passed
@takahirom takahirom deleted the kenken/pass_clock_to_controll_time_in_preview branch September 30, 2023 10:16
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.

Adjusting Time Settings to "Day 1" for Screenshot Tests
3 participants