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 part of #134: Home fragment low fi with TopicList #289

Merged
merged 29 commits into from
Nov 5, 2019

Conversation

rt4914
Copy link
Contributor

@rt4914 rt4914 commented Oct 31, 2019

Explanation

This PR includes implementation of HomeFragment and next PR on this will include ContinuePlayingActivity

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 assigned to an appropriate reviewer.

@rt4914 rt4914 changed the title Fix #134: Home fragment low fi with TopicList Fix part of #134: Home fragment low fi with TopicList Oct 31, 2019
@veena14cs veena14cs assigned rt4914 and unassigned veena14cs Nov 4, 2019
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 @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/res/values/strings.xml Outdated Show resolved Hide resolved
app/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
@BenHenning BenHenning removed their assignment Nov 4, 2019
Copy link
Contributor

@nikitamarysolomanpvt nikitamarysolomanpvt left a 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
  1. Turn on the auto-rotate in the device
  2. Keep your device in LANDSCAPE mode.
  3. Now start playing test cases.
  • Issue
    Seven test cases failed
  • Expected result
    All test cases should be successful

small

  • 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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Sponsor Member

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 = ... }

Copy link
Contributor Author

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())
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Sponsor Member

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?

Copy link
Contributor

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

@rt4914
Copy link
Contributor Author

rt4914 commented Nov 4, 2019

PTAL

  • step to follow while testing
  1. Turn on the auto-rotate in the device
  2. Keep your device in LANDSCAPE mode.
  3. Now start playing test cases.
  • Issue
    Seven test cases failed
  • Expected result
    All test cases should be successful
small
  • It seems the configuration changes in test cases are not working.
  • PTAL on other Nit changes.

All tests were written assuming that device will be in portrait mode. Thanks for pointing this out.

Added onView(withId(R.id.home_recycler_view)).perform(scrollToPosition<RecyclerView.ViewHolder>(3)) this and similar index based scrolling to resolve this issue.

@rt4914 rt4914 assigned BenHenning and unassigned rt4914 Nov 4, 2019
class OrientationChangeAction(private val orientation: Int) : ViewAction {

companion object {
fun orientationLandscape(): ViewAction = OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
Copy link
Sponsor Member

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.

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 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())

val c = view.childCount
var i = 0
while (i < c && activity == null) {
activity = getActivity(view.getChildAt(i).context)
Copy link
Sponsor Member

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.

Copy link
Contributor Author

@rt4914 rt4914 Nov 5, 2019

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.

@BenHenning
Copy link
Sponsor Member

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

@BenHenning BenHenning assigned rt4914 and unassigned BenHenning Nov 5, 2019
Copy link
Contributor

@nikitamarysolomanpvt nikitamarysolomanpvt left a 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

@nikitamarysolomanpvt nikitamarysolomanpvt removed their assignment Nov 5, 2019
@rt4914
Copy link
Contributor Author

rt4914 commented Nov 5, 2019

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.

@rt4914 rt4914 merged commit 8bfbbec into develop Nov 5, 2019
@rt4914 rt4914 deleted the home-fragment-low-fi branch November 5, 2019 07:52
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.

None yet

6 participants