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 #2263: Fixes App crashes in Lessons Tab and Espresso tests in TopicLessonFragmentTest #2264

Merged
merged 5 commits into from
Dec 23, 2020

Conversation

FareesHussain
Copy link
Contributor

Explanation

Fixes #2263

  • Fixes app crash in lessons Tab (landscape)
  • Fixes Espresso lagging test case in TopicLessonFragmentTest (testLessonsPlayFragment_loadRatiosTopic_configurationChange_storyName_isCorrect)
  • Fixes app crash in lesson Tab (Tablet portrait and Tablet landscape)
  • Fixes 12 failed test in TopicLessonFragmentTest when run in TopicLessonFragmentTest (run in tablet)

NOTE: above mentioned tests passes in robolectric

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.

##ScreenShots
testLessonsPlayFragment_loadRatiosTopic_configurationChange_storyName_isCorrect before changes
image
Espresso test failing in tablet
image

@FareesHussain
Copy link
Contributor Author

Workflow needs to be re-run as it works when I run it in my forked workflow

@anandwana001
Copy link
Contributor

@FareesHussain can we investigate why this crash is occurring? As I know earlier it is not crashing.

@FareesHussain
Copy link
Contributor Author

may be bindable adapter was implemented in story summary recently
the person who implemented it might have forgot to make changes in other layouts

@anandwana001
Copy link
Contributor

may be bindable adapter was implemented in story summary recently
the person who implemented it might have forgot to make changes in other layouts

Could you link the PR which cause the crash? We can fix but need to check why things working correctly before.

@FareesHussain
Copy link
Contributor Author

FareesHussain commented Dec 15, 2020

may be bindable adapter was implemented in story summary recently
the person who implemented it might have forgot to make changes in other layouts

Could you link the PR which cause the crash? We can fix but need to check why things working correctly before.

@anandwana001 It was working correctly because robolectric tests are passing and it was tested in mobile portrait
and this is the pr #2104

@anandwana001
Copy link
Contributor

anandwana001 commented Dec 15, 2020

#2104

Looking into this, Thanks for mentioning.

Ah, I really messed up the configuration here by passing the faulty data.
Wondering why the test was passing on Robolectric!!

Could you run the Bazel tests, steps are listed here - #2104 (comment)

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 @FareesHussain

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.

Thanks a lot @FareesHussain

@rt4914
Copy link
Contributor

rt4914 commented Dec 15, 2020

This will need @BenHenning approval as he is the code owner.

@rt4914 rt4914 assigned BenHenning and unassigned anandwana001 Dec 15, 2020
@FareesHussain
Copy link
Contributor Author

@anandwana001 I tried to run the Bazel test you mentioned

for the first command
bazel build //oppia --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx

I get the output

DEBUG: Rule 'io_bazel_stardoc' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "4378e9b6bb2831de7143580594782f538f461180", shallow_since = "157082916
6 -0400" and dropping ["tag"]
DEBUG: Repository io_bazel_stardoc instantiated at:
  E:/android/oppia-android-two/WORKSPACE:45:35: in <toplevel>
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/io_bazel_rules_kotlin/kotlin/internal/repositories/download.bzl:115:10: in kt_download_local_dev_dependencies
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/bazel_tools/tools/build_defs/repo/utils.bzl:201:18: in maybe
Repository rule git_repository defined at:
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
DEBUG: Rule 'robolectric' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "a7eac9418cc0b6d2527699986d5937efcebae927c3917c8bd3cb7663ee65ab63"
DEBUG: Repository robolectric instantiated at:
  E:/android/oppia-android-two/WORKSPACE:91:13: in <toplevel>
Repository rule http_archive defined at:
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
DEBUG: Rule 'tools_android' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1594238320 -0400"
DEBUG: Repository tools_android instantiated at:
  E:/android/oppia-android-two/WORKSPACE:102:15: in <toplevel>
Repository rule git_repository defined at:
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
ERROR: Skipping '//oppia': no such package 'oppia': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - E:/android/oppia-android-two/oppia
WARNING: Target pattern parsing failed.
ERROR: no such package 'oppia': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - E:/android/oppia-android-two/oppia
INFO: Elapsed time: 212.216s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

Could you please check

@FareesHussain
Copy link
Contributor Author

For the second command

bazel test //app:TopicLessonsFragmentTest --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx

The output is

DEBUG: Rule 'io_bazel_stardoc' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "4378e9b6bb2831de7143580594782f538f461180", shallow_since = "1570829166 -0400" and dropping ["tag"]
DEBUG: Repository io_bazel_stardoc instantiated at:
  E:/android/oppia-android-two/WORKSPACE:45:35: in <toplevel>
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/io_bazel_rules_kotlin/kotlin/internal/repositories/download.bzl:115:10: in kt_download_local_dev_dependencies
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/bazel_tools/tools/build_defs/repo/utils.bzl:201:18: in maybe
Repository rule git_repository defined at:
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
DEBUG: Rule 'robolectric' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "a7eac9418cc0b6d2527699986d5937efcebae927c3917c8bd3cb7663ee65ab63"
DEBUG: Repository robolectric instantiated at:
  E:/android/oppia-android-two/WORKSPACE:91:13: in <toplevel>
Repository rule http_archive defined at:
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
DEBUG: Rule 'tools_android' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1594238320 -0400"
DEBUG: Repository tools_android instantiated at:
  E:/android/oppia-android-two/WORKSPACE:102:15: in <toplevel>
Repository rule git_repository defined at:
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
INFO: Repository maven instantiated at:
  E:/android/oppia-android-two/WORKSPACE:125:14: in <toplevel>
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/rules_jvm_external/defs.bzl:89:19: in maven_install
Repository rule coursier_fetch defined at:
  C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/rules_jvm_external/coursier.bzl:620:33: in <toplevel>
INFO: Repository 'maven' used the following cache hits instead of downloading the corresponding file.
 * Hash '8f35f92fb8e021f96b3aa8145c66c3b2e29295baabb28ff50569e613438afcbd' for https://github.com/coursier/coursier/releases/download/v2.0.0-RC3-4/coursier.jar
If the definition of 'maven' was updated, verify that the hashes were also updated.
ERROR: An error occurred during the fetch of repository 'maven':
   Traceback (most recent call last):
        File "C:/users/syed farees hussain/_bazel_syed farees hussain/zcnrcatv/external/rules_jvm_external/coursier.bzl", line 364, column 13, in _coursier_fetch_impl
                fail("Error while fetching artifact with coursier: " + exec_result.stderr)
Error in fail: Error while fetching artifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_annotation_annotation in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact w
ith coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_databinding_databinding_adapters in repository @maven which failed to fetch. no such package '@maven//': Error while fetching
 artifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_databinding_databinding_common in repository @maven which failed to fetch. no such package '@maven//': Error while fetching a
rtifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_databinding_databinding_compiler in repository @maven which failed to fetch. no such package '@maven//': Error while fetching
 artifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_databinding_databinding_runtime in repository @maven which failed to fetch. no such package '@maven//': Error while fetching
artifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_navigation_navigation_fragment in repository @maven which failed to fetch. no such package '@maven//': Error while fetching a
rtifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_navigation_navigation_ui in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifac
t with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_test_espresso_espresso_contrib in repository @maven which failed to fetch. no such package '@maven//': Error while fetching a
rtifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_test_espresso_espresso_core in repository @maven which failed to fetch. no such package '@maven//': Error while fetching arti
fact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_test_espresso_espresso_intents in repository @maven which failed to fetch. no such package '@maven//': Error while fetching a
rtifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_test_ext_junit in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact with cou
rsier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:androidx_test_runner in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact with coursi
er: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:com_github_bumptech_glide_mocks in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact
with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:com_google_truth_truth in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact with cour
sier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:org_jetbrains_kotlin_kotlin_test_junit in repository @maven which failed to fetch. no such package '@maven//': Error while fetching ar
tifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:org_jetbrains_kotlin_kotlin_reflect in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artif
act with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:org_jetbrains_kotlinx_kotlinx_coroutines_test in repository @maven which failed to fetch. no such package '@maven//': Error while fetc
hing artifact with coursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:org_mockito_mockito_core in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact with co
ursier: Timed out
ERROR: E:/android/oppia-android-two/app/BUILD.bazel:1092:9: //app:TopicLessonsFragmentTest depends on @maven//:org_robolectric_annotations in repository @maven which failed to fetch. no such package '@maven//': Error while fetching artifact with
 coursier: Timed out
ERROR: Analysis of target '//app:TopicLessonsFragmentTest' failed; build aborted: Analysis failed
INFO: Elapsed time: 602.467s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

@anandwana001
Copy link
Contributor

@FareesHussain It involves cloning of oppia's bazel version. I will do it for now.
Please add the screenshot of espresso and robolectric result for future reference.

@FareesHussain
Copy link
Contributor Author

Espresso
image
Robolectric
image

@BenHenning
Copy link
Member

I'm fine with approving this, but can we please update #2263 with the root cause (e.g. which PR introduced the original crash)? In general, cases like this should lead to a reversion, not a fix (see https://github.com/oppia/oppia-android/wiki/Revert-&-regression-policy).

@BenHenning
Copy link
Member

Also, before approving: @FareesHussain please add tests in the fragment holding these views that hit each of these scenarios (e.g. landscape, tablet portrait, tablet landscape). Please add a screenshot showing these tests fail without your fix in place (to ensure they prevent this from happening again).

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.

Requesting changes until there's a test to guard against this regressing in the future.

@FareesHussain
Copy link
Contributor Author

Please add a screenshot showing these tests fail without your fix in place (to ensure they prevent this from happening again).

I've already added screenshots in this pr description please check

@FareesHussain
Copy link
Contributor Author

@BenHenning please check

Before changes

For mobile landscape the following tests does'nt run to the completions in espresso (however they pass in robolectric)

testLessonsPlayFragment_loadRatiosTopic_clickExpandListIconIndex1_configurationChange_chapterListIsVisible
image

testLessonsPlayFragment_loadRatiosTopic_configurationChange_storyName_isCorrect
image

Running all tests of TopicLessonsFragmentTest 12 out of 13 Tests fail
image

After Changes

Mobile espresso
image

Tablet Espresso (NEXUS 7 API 27)
image

@BenHenning
Copy link
Member

Thanks @FareesHussain. Sorry to be a bit clearer, what we actually need here is a test that results in the same crash that you're fixing. Are those Espresso tests actually resulting in the same bindable adapter issue that #2263 is describing? It's also odd that Robolectric isn't failing--it should be. @FareesHussain can you make sure that we have a test that specifically fails on Robolectric without the suggest fix in place? @anandwana001 might this be because Robolectric doesn't do rotation correctly? If so, @FareesHussain you may be able to write an explicit test for this that starts the device in landscape mode (e.g. using @Config per http://robolectric.org/javadoc/3.3/org/robolectric/annotation/Config.html#qualifiers--).

@BenHenning BenHenning removed their assignment Dec 18, 2020
@FareesHussain
Copy link
Contributor Author

Thanks @FareesHussain. Sorry to be a bit clearer, what we actually need here is a test that results in the same crash that you're fixing. Are those Espresso tests actually resulting in the same bindable adapter issue that #2263 is describing? It's also odd that Robolectric isn't failing--it should be. @FareesHussain can you make sure that we have a test that specifically fails on Robolectric without the suggest fix in place? @anandwana001 might this be because Robolectric doesn't do rotation correctly? If so, @FareesHussain you may be able to write an explicit test for this that starts the device in landscape mode (e.g. using @Config per http://robolectric.org/javadoc/3.3/org/robolectric/annotation/Config.html#qualifiers--).

@BenHenning There is no crash when I run this on Espresso(it crashes when the Item in the recyclerview is expanded) The test stop as below. I will try adding tests corresponding test that fail in robolectric.

Screenshot_1608264360

@anandwana001
Copy link
Contributor

Thanks @FareesHussain. Sorry to be a bit clearer, what we actually need here is a test that results in the same crash that you're fixing. Are those Espresso tests actually resulting in the same bindable adapter issue that #2263 is describing? It's also odd that Robolectric isn't failing--it should be. @FareesHussain can you make sure that we have a test that specifically fails on Robolectric without the suggest fix in place? @anandwana001 might this be because Robolectric doesn't do rotation correctly? If so, @FareesHussain you may be able to write an explicit test for this that starts the device in landscape mode (e.g. using @Config per http://robolectric.org/javadoc/3.3/org/robolectric/annotation/Config.html#qualifiers--).

Sounds like that. Robolectric is not performing rotation correctly.

@anandwana001 anandwana001 removed their assignment Dec 19, 2020
@FareesHussain
Copy link
Contributor Author

@BenHenning please check

Before changes robolectric
image

After changes robolectric
image

@@ -308,6 +311,7 @@ class TopicLessonsFragmentTest {
fun testLessonsPlayFragment_loadRatiosTopic_clickExpandListIconIndex1_configurationChange_chapterListIsVisible() { // ktlint-disable max-line-length
launch<TopicActivity>(createTopicActivityIntent(internalProfileId, RATIOS_TOPIC_ID)).use {
clickLessonTab()
onView(isRoot()).perform(orientationLandscape())
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 added these again cause orientation does'nt change in Espresso
even if using @config

@BenHenning
Copy link
Member

Thanks @FareesHussain. Can you actually change the test such that:

  • We have a test for doing X (in portrait by default)
  • We have another test for doing X after a configuration change
  • We have another test for doing X (in landscape by default)

The third test is technically a new, duplicate test of the first one (but starting in landscape). This is preferred over changing existing tests to only be landsdcape + configuration change, and should improve our behavioral coverage a bit.

It looks like two tests were changed before--in that case I'd expect those two to be reverted, and duplicated to be the third class of test above (starting in landscape but performing a configuration change).

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 @FareesHussain! LGTM.

@BenHenning BenHenning merged commit f29299a into oppia:develop Dec 23, 2020
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.

Lessons tab crashes in landscape mode(mobile) and tablets
4 participants