Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/student/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ dependencies {
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation Libs.PHOTO_VIEW

/* Sliding Panel */
implementation 'com.sothree.slidinguppanel:library:3.4.0'

/* Apache Commons */
implementation 'org.apache.commons:commons-text:1.6'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.instructure.student.espresso
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.instructure.student.SingleFragmentTestActivity
import com.instructure.student.ui.pages.renderPages.AssignmentDetailsRenderPage
import com.instructure.student.ui.pages.renderPages.SubmissionDetailsRenderPage
import com.instructure.student.ui.utils.StudentActivityTestRule
import com.instructure.student.ui.utils.StudentTest
import org.junit.runner.RunWith
Expand All @@ -34,5 +35,6 @@ abstract class StudentRenderTest : StudentTest() {
}

val assignmentDetailsRenderPage = AssignmentDetailsRenderPage()
val submissionDetailsRenderPage = SubmissionDetailsRenderPage()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2019 - present Instructure, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.instructure.student.ui.pages

import com.instructure.espresso.page.BasePage
import com.instructure.student.R

open class SubmissionDetailsPage : BasePage(R.id.submissionDetails) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright (C) 2019 - present Instructure, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.instructure.student.ui.pages.renderPages

import android.view.View
import androidx.test.espresso.Espresso.onData
import androidx.test.espresso.action.*
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withSpinnerText
import com.instructure.espresso.*
import com.instructure.espresso.page.*
import com.instructure.student.R
import com.instructure.student.ui.pages.SubmissionDetailsPage
import org.hamcrest.CoreMatchers.*

class SubmissionDetailsRenderPage : SubmissionDetailsPage() {

val toolbar by OnViewWithId(R.id.toolbar)
val loadingView by OnViewWithId(R.id.loadingView)
val errorView by OnViewWithId(R.id.errorContainer)
val mainContent by OnViewWithId(R.id.contentWrapper)
val drawerContent by OnViewWithId(R.id.drawerViewPager)
val slidingPanel by OnViewWithId(R.id.slidingUpPanelLayout)
val versionSpinner by OnViewWithId(R.id.submissionVersionsSpinner)

/* Grabs the current coordinates of the center of drawerTabLayout */
private val tabLayoutCoordinates = object : CoordinatesProvider {
override fun calculateCoordinates(view: View): FloatArray {
val tabs = view.findViewById<View>(R.id.drawerTabLayout)
val xy = IntArray(2).apply { tabs.getLocationOnScreen(this) }
val x = xy[0] + (tabs.width / 2f)
val y = xy[1] + (tabs.height / 2f)
return floatArrayOf(x, y)
}
}

fun assertDisplaysToolbarTitle(text: String) {
onViewWithText(text).assertDisplayed()
}

fun assertDisplaysLoadingView() {
loadingView.assertDisplayed()
errorView.assertGone()
mainContent.assertGone()
}

fun assertDisplaysError() {
loadingView.assertGone()
mainContent.assertGone()
errorView.assertVisible()
onViewWithText(R.string.submissionDetailsErrorTitle).assertDisplayed()
onViewWithText(R.string.error_loading_submission).assertDisplayed()
onViewWithId(R.id.retryButton).assertDisplayed()
}

fun assertDisplaysContent() {
mainContent.assertDisplayed()
loadingView.assertGone()
errorView.assertGone()
}

fun assertDisplaysDrawerContent() {
drawerContent.assertDisplayed()
}

fun clickTab(name: String) {
onView(allOf(withAncestor(R.id.drawerTabLayout), withText(name))).click()
}

fun swipeDrawerTo(location: GeneralLocation) {
slidingPanel.perform(GeneralSwipeAction(Swipe.FAST, tabLayoutCoordinates, location, Press.FINGER))
}

fun assertSpinnerMatchesText(text: String) {
versionSpinner.check(matches(withSpinnerText(containsString(text))))
}

fun assertSpinnerDropdownItemHasText(position: Int, text: String) {
onData(anything()).atPosition(position).check(matches(ViewMatchers.withText(text)))
}
}
Loading