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

Fix #2132: Chapter List Page Issues (#2232) - Blur and lock thumbnails of inactive cards. #2422

Merged
merged 38 commits into from
Feb 3, 2021
Merged

Conversation

viktoriias
Copy link
Contributor

@viktoriias viktoriias commented Jan 7, 2021

Explanation

Fixes #2132. Here I blur and lock thumbnails of inactive cards.

LessonThumbnailImageView loads images in fun loadLessonThumbnail():

if (lessonThumbnail.thumbnailFilename.isNotEmpty()) {
  // This branch will be used in production. I'm not able to test blurring here.
  loadImage(lessonThumbnail.thumbnailFilename)
} else {
  // This branch is executed in develop. I can test blurring this.
  imageView.setImageResource(getLessonDrawableResource(lessonThumbnail))
}

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is made from a branch that is up-to-date with "develop".
  • The PR's branch is based on "develop" and not on any other branch.
  • The PR is assigned to an appropriate reviewer in both the Assignees and the Reviewers sections.

Test runs relevant to this PR:
Screen Shot 2021-01-24 at 9 00 11 PM
Screen Shot 2021-01-24 at 9 02 24 PM
Screen Shot 2021-01-24 at 9 02 58 PM
Screen Shot 2021-01-24 at 9 03 39 PM
Screen Shot 2021-01-24 at 9 05 12 PM
Screen Shot 2021-01-24 at 9 06 05 PM

@viktoriias
Copy link
Contributor Author

Result:
Screen Shot 2021-01-06 at 12 44 00 PM

@viktoriias
Copy link
Contributor Author

@anandwana001 @BenHenning Please review first draft.

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @viktoriias! Took a high-level pass & focused generally less on nits/readability.

@BenHenning BenHenning assigned viktoriias and unassigned BenHenning Jan 8, 2021
@viktoriias viktoriias assigned BenHenning and unassigned viktoriias Jan 9, 2021
@viktoriias
Copy link
Contributor Author

Thanks @viktoriias! Took a high-level pass & focused generally less on nits/readability.

@BenHenning PTAL

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @viktoriias! Other than the open questions around the blur transformation itself, I think this is looking good. Had some additional minor comments. Also, we should add tests for the new blurring behavior. To do this, I think you can provide a mock ImageLoader (e.g. using Mockito) by creating a test module rather than including GlideImageLoaderModule. By doing this, you can verify that the system being tested is properly blurring the image by verifying that it correctly passes the BLUR image transformation in the situations we're interested in.

I think just having tests for story_chapter_view is sufficient, but we should make sure to cover the portrait/landscape and handset/tablet scenarios (e.g. if any of the four XML files change, the tests should fail).

@BenHenning BenHenning assigned viktoriias and unassigned BenHenning Jan 9, 2021
@viktoriias
Copy link
Contributor Author

viktoriias commented Jan 10, 2021

We should add tests for the new blurring behavior. To do this, I think you can provide a mock ImageLoader (e.g. using Mockito) by creating a test module rather than including GlideImageLoaderModule. By doing this, you can verify that the system being tested is properly blurring the image by verifying that it correctly passes the BLUR image transformation in the situations we're interested in.

I think just having tests for story_chapter_view is sufficient, but we should make sure to cover the portrait/landscape and handset/tablet scenarios (e.g. if any of the four XML files change, the tests should fail).

@BenHenning @anandwana001 I have some questions regarding testing.

This PR is causing testRecentlyPlayedTestActivity_recyclerViewItem1_lessonThumbnailIsCorrect to fail. I don't think it's possible to test Glige loading image using withDrawable(R.drawable.lesson_thumbnail_name), but I can't find an official proof of that. Can I remove two lessonThumbnailIsCorrect tests from RecentlyPlayedFragmentTest?

Another question is about StoryFragmentTest, where I believe I would add tests for new blurring behavior. I didn't realize StoryFragmentTest wasn't included in CI Lint and Tests / Robolectric Tests. When I ran it in Android Studio, all tests in this class failed with the following error: android.renderscript.RSDriverException: Failed to create RS context.
The I found out that Renderscript does not work with Robolectric: robolectric/robolectric#1034
Will mock ImageLoader solve this problem? (I'm still working on figuring out the mocking part)

@anandwana001
Copy link
Contributor

anandwana001 commented Jan 11, 2021

@viktoriias For Glide in testing, please have a look at this

// Initialize Glide such that all of its executors use the same shared dispatcher pool as the

Also need to check if ourDrawableMatcher can handle this update or not
reference might help,not sure - https://gist.github.com/frankiesardo/7490059

@anandwana001
Copy link
Contributor

StoryFragmentTest wasn't included in CI Lint and Tests / Robolectric Tests

It's included

name: Robolectric Tests - App Module (Non-Flaky)

@viktoriias
Copy link
Contributor Author

StoryFragmentTest wasn't included in CI Lint and Tests / Robolectric Tests

It's included

name: Robolectric Tests - App Module (Non-Flaky)

Oh, you're right. Found it and it failed with the same error: android.renderscript.RSDriverException: Failed to create RS context.

@anandwana001
Copy link
Contributor

Can I remove two lessonThumbnailIsCorrect tests from RecentlyPlayedFragmentTest?

Both the tests are different. One is for port and one is for landscape.

fun testRecentlyPlayedTestActivity_changeConfiguration_recyclerViewItem1_lessonThumbnailIsCorrect()
fun testRecentlyPlayedTestActivity_recyclerViewItem1_lessonThumbnailIsCorrect()

@anandwana001 anandwana001 removed their assignment Jan 25, 2021
@viktoriias
Copy link
Contributor Author

Also, could you please add a screenshot in the PR Description showing test results for the modified test files in this PR? You can simply run the test files on both Espresso and Robolectric.

Done.

Also, could you please confirm by running any test file which does not ave TestImageLoaderModule is it passing on both Espresso and Robolectric or not, I am bit confused on using all the test modules in all the files or not.

Done, I included ProfilePictureActivityTest.

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @viktoriias! This seems pretty close to being wrapped up. Just had a few nits.

Also, please note the failing Robolectric tests in CI.

@BenHenning BenHenning removed their assignment Jan 28, 2021
Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @viktoriias! Just nits left, then I think this will LGTM.

@BenHenning BenHenning removed their assignment Jan 29, 2021
Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @viktoriias! This looks great!

@BenHenning BenHenning assigned rt4914 and unassigned BenHenning Jan 30, 2021
@BenHenning
Copy link
Sponsor Member

Adding @rt4914 for codeowners.

@viktoriias viktoriias removed their assignment Jan 31, 2021
Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks @viktoriias

@anandwana001 anandwana001 removed their assignment Feb 1, 2021
Copy link
Contributor

@rt4914 rt4914 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

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.

Chapter List Page Issues
4 participants