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 #2667: Wrong Tab selected on configuration change in TopicFragment #2670

Merged
merged 18 commits into from
Feb 28, 2021
Merged

Fix #2667: Wrong Tab selected on configuration change in TopicFragment #2670

merged 18 commits into from
Feb 28, 2021

Conversation

MaskedCarrot
Copy link
Contributor

@MaskedCarrot MaskedCarrot commented Feb 9, 2021

Explanation

Fixes #2667

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.

gif

21-02-09-18-46-29.mp4

Espresso Tests

without fix with fix
Screenshot from 2021-02-15 11-24-48 Screenshot from 2021-02-15 11-26-49

Tests after the changes made in this PR.

Espresso Robolectric
Screenshot from 2021-02-24 14-35-05 Screenshot from 2021-02-24 14-37-17

@anandwana001
Copy link
Contributor

Few points:

  1. Can we check why do we have this issue at first place? What's causing this issue?
  2. If we are solving this, can we have test case related to it?

Currently, we do have a test to test this issue testTopicFragment_clickOnPracticeTab_configurationChange_showsSameTabAndItsContent and it's passing for me.

Could you please confirm!!.

@FareesHussain
Copy link
Contributor

@anandwana001 the bug only occurs when navigated through Promoted stories. I guess we need to test it using HomeActivityTest

@MaskedCarrot Your implementation does fix this. But you need to track down what might be causing this issue before fixing this, to avoid further bugs related to this. This is also weird that it is only reproduced when navigated through Promoted stories.

@FareesHussain FareesHussain assigned MaskedCarrot and rt4914 and unassigned rt4914 Feb 10, 2021
@MaskedCarrot
Copy link
Contributor Author

This issue is caused because in the handleOnCreate of TopicFragmentPresenter we are setting the viewpager to lessons/info fragment every time the activity is recreated.

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.

@MaskedCarrot Please add a test case for this specific case. The test should be added in TopicFragmentTest.

@rt4914 rt4914 removed their assignment Feb 10, 2021
@anandwana001
Copy link
Contributor

@rt4914 before going for the test case, could you confirm if the approach looks good to you? Also, what is the root cause of this issue before fixing it? As we are landing on the same topic page but from two different places, what's the difference here?

@rt4914 rt4914 self-assigned this Feb 11, 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.

@rt4914
Copy link
Contributor

rt4914 commented Feb 11, 2021

@rt4914 before going for the test case, could you confirm if the approach looks good to you? Also, what is the root cause of this issue before fixing it? As we are landing on the same topic page but from two different places, what's the difference here?

@anandwana001 Yeah the approach is correct. Only the naming is just opposite.

Cause: The code is incorrect. It should be like this: if we are on same screen and do orientation change than nothing should change.

From promoted story we show Topic-Lessons in expanded form and from All topics section we should Topic Info.

@rt4914 rt4914 removed their assignment Feb 11, 2021
@MaskedCarrot MaskedCarrot assigned rt4914 and unassigned MaskedCarrot Feb 14, 2021
@MaskedCarrot MaskedCarrot requested a review from rt4914 February 14, 2021 14:06
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.

Nit changes on the Test file.

@MaskedCarrot MaskedCarrot removed their assignment Feb 15, 2021
Copy link
Contributor

@FareesHussain FareesHussain left a comment

Choose a reason for hiding this comment

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

LGTM. Added a commet please check

@@ -375,6 +375,7 @@ class TopicFragmentTest {
targetViewId = R.id.master_skills_text_view,
stringToMatch = "Master These Skills"
)
testCoroutineDispatchers.runCurrent()
onView(isRoot()).perform(orientationLandscape())
testCoroutineDispatchers.runCurrent()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can remove this because after clicking on the tab we have a runCurrent() which will provide the delay to switch the tab.

Copy link
Contributor

Choose a reason for hiding this comment

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

Check if Robolectric passing or not with/without this stabilizing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The robolectric test are passing with or without testCoroutineDispatchers.runCurrent()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed unnecessary testCoroutineDispatchers.runCurrent() and checked that the tests are still correctly passing on espresso (real device and emulator) and robolectric.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added screenshots for the same in description.

@BenHenning BenHenning added the PR don't merge - NEEDS UPDATE Corresponds to PRs that need to be updated with the latest develop changes before they can be merged label Feb 24, 2021
@BenHenning BenHenning removed the PR don't merge - NEEDS UPDATE Corresponds to PRs that need to be updated with the latest develop changes before they can be merged label Feb 24, 2021
Copy link
Contributor

@FareesHussain FareesHussain left a comment

Choose a reason for hiding this comment

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

LGTM,
Can you confirm that you are able to see the screen rotation while running the espresso tests.

@FareesHussain FareesHussain removed their assignment Feb 24, 2021
@MaskedCarrot
Copy link
Contributor Author

yes I can see the orientation change

@anandwana001
Copy link
Contributor

I will take a look at this tomorrow.

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

Copy link
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 @MaskedCarrot! I had a couple thoughts, but feel free to resolve those conversations. The PR LGTM. Please re-assign me if you have any follow-up questions that you'd like my thoughts on.

@MaskedCarrot MaskedCarrot removed their assignment Feb 26, 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.

@rt4914 rt4914 merged commit 1467141 into oppia:develop Feb 28, 2021
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.

Wrong Tab selected on configuration change in TopicFragment
5 participants