Skip to content

Commit

Permalink
Fix #666: Lowfi Landscape: ContinuePlaying Screen (#673)
Browse files Browse the repository at this point in the history
* Added landscape layout to ContinuePlaying Screen

* Added tests for landscape layout
  • Loading branch information
abhinavraj23 authored Feb 20, 2020
1 parent d705580 commit a01be8c
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 11 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
android:theme="@style/OppiaTheme">
<activity
android:name=".home.continueplaying.ContinuePlayingActivity"
android:screenOrientation="portrait"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity android:name=".testing.AudioFragmentTestActivity" />
<activity
Expand Down
67 changes: 67 additions & 0 deletions app/src/main/res/layout-land/continue_playing_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="viewModel"
type="org.oppia.app.home.continueplaying.ContinuePlayViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/story_list_app_bar_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/continue_playing_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:fontFamily="sans-serif"
android:minHeight="?attr/actionBarSize"
android:textSize="20sp"
app:navigationContentDescription="@string/go_to_previous_page"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/continue_playing_activity"
app:titleTextColor="@color/white" />
</com.google.android.material.appbar.AppBarLayout>

<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/story_list_app_bar_layout">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/ongoing_story_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingTop="8dp"
android:paddingBottom="172dp"
android:scrollbars="none"
app:data="@{viewModel.ongoingStoryLiveData}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

<View
android:id="@+id/continue_playing__shadow_view"
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="@drawable/toolbar_drop_shadow" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -260,43 +260,58 @@ class ContinuePlayingFragmentTest {
}
}

/** Landscape Tests */

@Test
@Ignore("Landscape not properly supported") // TODO(#56): Reenable once landscape is supported.
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem0_showsLastWeekSectionTitle() {
fun testContinuePlayingTestActivity_changeConfiguration_toolbarTitle_isDisplayedSuccessfully() {
ActivityScenario.launch(ContinuePlayingFragmentTestActivity::class.java).use {
onView(isRoot()).perform(orientationLandscape())
onView(
allOf(
instanceOf(TextView::class.java),
withParent(withId(R.id.continue_playing_toolbar))
)
).check(matches(withText(R.string.continue_playing_activity)))
}
}

@Test
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem0_doesNotShowSectionDivider() {
ActivityScenario.launch(ContinuePlayingFragmentTestActivity::class.java).use {
onView(isRoot()).perform(orientationLandscape())
onView(
atPositionOnView(
R.id.ongoing_story_recycler_view,
0,
R.id.section_title_text_view
R.id.divider_view
)
).check(
matches(
withText(R.string.ongoing_story_last_week)
not(isDisplayed())
)
)
}
}

@Test
@Ignore("Landscape not properly supported") // TODO(#56): Reenable once landscape is supported.
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem3_showsLastMonthSectionTitle() {
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem0_showsLastWeekSectionTitle() {
ActivityScenario.launch(ContinuePlayingFragmentTestActivity::class.java).use {
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.ongoing_story_recycler_view)).perform(scrollToPosition<RecyclerView.ViewHolder>(3))
onView(
atPositionOnView(
R.id.ongoing_story_recycler_view,
3,
0,
R.id.section_title_text_view
)
).check(matches(withText(R.string.ongoing_story_last_month)))
).check(
matches(
withText(R.string.ongoing_story_last_week)
)
)
}
}

@Test
@Ignore("Landscape not properly supported") // TODO(#56): Reenable once landscape is supported.
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem4_chapterNameIsCorrect() {
ActivityScenario.launch(ContinuePlayingFragmentTestActivity::class.java).use {
onView(isRoot()).perform(orientationLandscape())
Expand All @@ -319,6 +334,90 @@ class ContinuePlayingFragmentTest {
}
}

@Test
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem1_storyNameIsCorrect() {
ActivityScenario.launch(ContinuePlayingFragmentTestActivity::class.java).use {
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.ongoing_story_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(
atPositionOnView(
R.id.ongoing_story_recycler_view,
1,
R.id.story_name_text_view
)
).check(
matches(
withText(containsString("Matthew Goes to the Bakery"))
)
)
}
}

@Test
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem1_topicNameIsCorrect() {
ActivityScenario.launch(ContinuePlayingFragmentTestActivity::class.java).use {
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.ongoing_story_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(
atPositionOnView(
R.id.ongoing_story_recycler_view,
1,
R.id.topic_name_text_view
)
).check(
matches(
withText(containsString("FRACTIONS"))
)
)
}
}

@Test
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem1_lessonThumbnailIsCorrect() {
ActivityScenario.launch(ContinuePlayingFragmentTestActivity::class.java).use {
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.ongoing_story_recycler_view)).perform(
scrollToPosition<RecyclerView.ViewHolder>(
1
)
)
onView(
atPositionOnView(
R.id.ongoing_story_recycler_view,
1,
R.id.lesson_thumbnail
)
).check(
matches(
withDrawable(R.drawable.lesson_thumbnail_graphic_duck_and_chicken)
)
)
}
}

@Test
fun testContinuePlayingTestActivity_changeConfiguration_recyclerViewItem3_showsLastMonthSectionTitle() {
ActivityScenario.launch(ContinuePlayingFragmentTestActivity::class.java).use {
onView(isRoot()).perform(orientationLandscape())
onView(withId(R.id.ongoing_story_recycler_view)).perform(scrollToPosition<RecyclerView.ViewHolder>(3))
onView(
atPositionOnView(
R.id.ongoing_story_recycler_view,
3,
R.id.section_title_text_view
)
).check(matches(withText(R.string.ongoing_story_last_month)))
}
}

@After
fun tearDown() {
Intents.release()
Expand Down

0 comments on commit a01be8c

Please sign in to comment.