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

Fixes #1198 & 1200: Options - Tablet (Landscape) (Portrait) (Lowfi) #1677

Merged
merged 23 commits into from
Aug 29, 2020

Conversation

MohamedMedhat1998
Copy link
Contributor

Important Note

The newly added test cases in StoryTextSizeFragmentTest,DefaultAudioFragmentTest, and AppLanguageFragmentTest don't pass on robolectric, but when they are copied to espresso, they pass.

Explanation

Screenshots

screenshot-٢٠٢٠-٠٨-١٩_١٥ ٠١ ١٢ ٤٢١
screenshot-٢٠٢٠-٠٨-١٩_١٥ ٠١ ٠٧ ٤٥١
screenshot-٢٠٢٠-٠٨-١٩_١٥ ٠١ ٠٣ ١٥٢
screenshot-٢٠٢٠-٠٨-١٩_١٥ ٠٠ ٤٧ ٩٩٦
screenshot-٢٠٢٠-٠٨-١٩_١٥ ٠٠ ٤٣ ٢٧٨
screenshot-٢٠٢٠-٠٨-١٩_١٥ ٠٠ ٣٨ ٤٩١

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.

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.

Really nice implementation.
I am unable to run test cases but on glance they look correct. Still I will run them in second attempt but meanwhile make sure that your tests pass on Github Actions first.

@rt4914 rt4914 assigned MohamedMedhat1998 and unassigned rt4914 Aug 19, 2020
@MohamedMedhat1998
Copy link
Contributor Author

Really nice implementation.
I am unable to run test cases but on glance they look correct. Still I will run them in second attempt but meanwhile make sure that your tests pass on Github Actions first.

@rt4914 The test cases fail on Robolectric but pass on Espresso (when they are copied there).
So, the PR itself contains newly added test cases that fail, is it what causing the tests to fail on github actions?

@rt4914
Copy link
Contributor

rt4914 commented Aug 21, 2020

Really nice implementation.
I am unable to run test cases but on glance they look correct. Still I will run them in second attempt but meanwhile make sure that your tests pass on Github Actions first.

@rt4914 The test cases fail on Robolectric but pass on Espresso (when they are copied there).
So, the PR itself contains newly added test cases that fail, is it what causing the tests to fail on github actions?

@MohamedMedhat1998 I was facing similar issue on #1682 and when I merged with latest develop and the test cases are not passing on CI. So can you please update it with latest develop and after that can easily investigate if we still face any issue.

@rt4914 rt4914 assigned MohamedMedhat1998 and unassigned rt4914 Aug 21, 2020
@MohamedMedhat1998
Copy link
Contributor Author

Really nice implementation.
I am unable to run test cases but on glance they look correct. Still I will run them in second attempt but meanwhile make sure that your tests pass on Github Actions first.

@rt4914 The test cases fail on Robolectric but pass on Espresso (when they are copied there).
So, the PR itself contains newly added test cases that fail, is it what causing the tests to fail on github actions?

@MohamedMedhat1998 I was facing similar issue on #1682 and when I merged with latest develop and the test cases are not passing on CI. So can you please update it with latest develop and after that can easily investigate if we still face any issue.

@rt4914 I have updated with the latest develop.
Please check the tests in StoryTextSizeFragmentTest,DefaultAudioFragmentTest, and AppLanguageFragmentTest because some of them are failing on robolectric, but when they are moved to espresso, they work.

@rt4914
Copy link
Contributor

rt4914 commented Aug 28, 2020

  • OptionsFragmentPresenter
      getOptionControlsItemViewModel().getAppLanguage(AppLanguage.ENGLISH_APP_LANGUAGE) -> {
        profileManagementController.updateAppLanguage(
          profileId,
          AppLanguage.ENGLISH_APP_LANGUAGE
        ).observe(fragment, Observer { appLanguageResult ->
          if (appLanguageResult.isSuccess()) {
            appLanguage = AppLanguage.ENGLISH_APP_LANGUAGE
          }
        })
      }

@rt4914
Copy link
Contributor

rt4914 commented Aug 28, 2020

getOptionControlsItemViewModel().getAppLanguage(AppLanguage.ENGLISH_APP_LANGUAGE) -> {
profileManagementController.updateAppLanguage(
profileId,
AppLanguage.ENGLISH_APP_LANGUAGE
).observe(fragment, Observer { appLanguageResult ->
if (appLanguageResult.isSuccess()) {
appLanguage = AppLanguage.ENGLISH_APP_LANGUAGE
}
})
}

@MohamedMedhat1998 Next steps / commits:

  1. Update test cases to use initialiseProfiles
  2. Resolve merge conflicts.
  3. Update implementation to observe results.
  4. You might need to Recheck test cases after step 3.

@rt4914 rt4914 removed their assignment Aug 28, 2020
@MohamedMedhat1998
Copy link
Contributor Author

Out of curiosity, how have these tests been tested on Espresso? Given that they're in the test/ folder, they're not actually configured to run with instrumentation (and when I try, I get 'No tests were found' as expected for a non-shared test suite).

I just copied the tests from Robolectric files to Espresso files :D

Edit: also, how did you use testCoroutineDispatchers if DefaultAudioFragmentTest isn't an injected test?

I didn't use testCoroutineDispatchers while I was trying on Espresso

@MohamedMedhat1998
Copy link
Contributor Author

* The click to change the language is changing the audioLanguage in `OptionsFragmentPresenter` (by the way, why do we need this variable?) and is initiating an update for the profile

Because when we are on a tablet device, the AudioLanguageActivity isn't started, so we update the language using the OptionsFragmentPresenter instead of AudioLanguageActivityPresenter

* Note that the notify data set changed is wrong here since the adapter list hasn't actually changed yet--that's contingent on the view model's livedata observer getting called back

I will fix that using Rajat snippet in his comment.

* It seems like the test isn't actually setting up or logging into any profiles--this is putting the profile system in an invalid state (**action item**: you should add observers to _all_ live datas returned by the profile controller's update methods since these will tell you if they pass/fail--they're clearly failing here. I suggest adding log statements for the cases when they fail.)

I think this will be solved also using the code Rajat added in his comment.

I suspect that the Espresso runs of these tests only pass because you already had profiles setup on the local device. Robolectric is more correct here: it's always running the tests in a clean state, uncovering the test setup issue. Restructuring your test like so fixes it for me:

https://gist.github.com/BenHenning/0582c3bc1f8cb03917b030dc8238f075/revisions

Thanks a lot, Ben. This really helped.

# Conflicts (resolved):
#	app/src/main/java/org/oppia/app/options/OptionControlsViewModel.kt
#	app/src/main/java/org/oppia/app/options/OptionsActivity.kt
#	app/src/main/java/org/oppia/app/options/OptionsFragment.kt
#	app/src/main/java/org/oppia/app/options/OptionsFragmentPresenter.kt
#	app/src/main/java/org/oppia/app/options/OptionsReadingTextSizeViewModel.kt
#	app/src/main/java/org/oppia/app/options/ReadingTextSizeFragmentPresenter.kt
#	app/src/sharedTest/java/org/oppia/app/options/OptionsFragmentTest.kt
#	app/src/test/java/org/oppia/app/testing/options/OptionsFragmentTest.kt
#	app/src/test/java/org/oppia/app/testing/options/ReadingTextSizeFragmentTest.kt
} else {
consoleLogger.e(
READING_TEXT_SIZE_TAG,
READING_TEXT_SIZE_ERROR,
Copy link
Contributor

Choose a reason for hiding this comment

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

You cannot have the same logger everywhere, the error should be different for each logger otherwise if anyone faces this error how would they know which error is related to which function?

          consoleLogger.e(
            READING_TEXT_SIZE_TAG,
            READING_TEXT_SIZE_ERROR + ": small text size",
            it.getErrorOrNull()
          )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

Nit change suggested in logger.

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, nit change suggested.

@rt4914 rt4914 assigned MohamedMedhat1998 and unassigned rt4914 Aug 29, 2020
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.

Approval for codeowners for the Bazel changes (didn't look at the rest of the PR in depth).

@MohamedMedhat1998 MohamedMedhat1998 merged commit b11cf58 into develop Aug 29, 2020
@MohamedMedhat1998 MohamedMedhat1998 deleted the options-tablet-lowfi branch August 29, 2020 21:41
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.

Options - Tablet (Portrait) (Lowfi) Options - Tablet (Landscape) (Lowfi)
3 participants