-
Notifications
You must be signed in to change notification settings - Fork 503
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 part of #134: Home fragment low fi with TopicList #289
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rt4914! This generally LGTM (& really nice tests for the topic list). Feel free to re-assign to me if you want me to do one more pass, but once all my comments are resolved I'm completely fine with this being merged.
app/src/main/java/org/oppia/app/home/RouteToTopicPlayStoryListener.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/app/home/topiclist/PromotedStoryViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/oppia/app/home/topiclist/PromotedStoryViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/app/home/ContinuePlayingActivityTest.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
- step to follow while testing
- Turn on the auto-rotate in the device
- Keep your device in LANDSCAPE mode.
- Now start playing test cases.
- Issue
Seven test cases failed - Expected result
All test cases should be successful
-
It seems the configuration changes in test cases are not working.
-
PTAL on other Nit changes.
|
||
@Test | ||
fun testHomeActivity_recyclerViewIndex0_configurationChange_displaysWelcomeMessageCorrectly() { | ||
launch(HomeActivity::class.java).use { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code seems not working. Even while debugging not changing (not showing the change in configuration)the configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduced new file OrientationChangeAction
which helps to work with orientationchange along with visibility.
onView(isRoot()).perform(orientationLandscape())
@BenHenning Please check this new implementation for orientation change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just for convenience? I'm trying to understand why it's needed versus scenario.onActivity { activity -> activity.requestedOrientation = ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenHenning When we use
scenario.onActivity { activity -> activity.requestedOrientation = ... }
the test cases pass but the orientation change is not visible on screen.
The OrientationChangeAction
file makes sure that the orientation change is actually visible on device when we run these test cases.
fun setBackgroundDrawable(view: View, @ColorInt colorRgb: Int) { | ||
view.setBackgroundResource(R.drawable.rounded_rect_background) | ||
// The input color needs to have alpha channel prepended to it. | ||
(view.background as GradientDrawable).setColor((0xff000000 or colorRgb.toLong()).toInt()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is't supposed to be added in resource file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenHenning Can you address this given the case that I have used this from your code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What specifically should be added to a resource file? There's nothing here that's really shareable. The 0xff000000
isn't a color, it's an alpha filter so it wouldn't belong in a resource file. Is there another aspect of this that you think should be in a resource file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned about 0xff000000 only.
We may add color with alpha filter in resource files is't?.(Just to clarify)
Just for example like the below code.
https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/colors.xml
class OrientationChangeAction(private val orientation: Int) : ViewAction { | ||
|
||
companion object { | ||
fun orientationLandscape(): ViewAction = OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make these file-level functions instead of companion functions. Then we can make this action private to the file to make things a bit cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actually in favour of keeping this implementation because this makes the usage of these functions quite easy in test cases.
sample:
onView(isRoot()).perform(orientationLandscape())
app/src/sharedTest/java/org/oppia/app/utility/OrientationChangeAction.kt
Show resolved
Hide resolved
val c = view.childCount | ||
var i = 0 | ||
while (i < c && activity == null) { | ||
activity = getActivity(view.getChildAt(i).context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we just use the ViewGroup's context? This extra iteration is a bit confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try to use the viewgroup's context but that was leading to NullPointerException
error and therefore keeping it as it is for now.
@rt4914 I did not do another pass on this. Let me know if you'd like me to, or want to discuss the specific aspects that you mentioned me in above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM .Please fix the comment mentioned
Merging this PR for now, there are some open comments which will be discussed once low-fi is finished but those comments are non-blocking. |
Explanation
This PR includes implementation of HomeFragment and next PR on this will include ContinuePlayingActivity
Checklist