Skip to content

Commit

Permalink
extend UI tests for public share creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jesmrec authored and davigonz committed Apr 9, 2019
1 parent 2a5071e commit 164b12d
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ package com.owncloud.android.shares.ui
import android.accounts.Account
import android.text.InputType.TYPE_CLASS_TEXT
import android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD
import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withInputType
import androidx.test.espresso.matcher.ViewMatchers.withText
Expand All @@ -43,7 +44,6 @@ import com.owncloud.android.shares.viewmodel.OCShareViewModel
import com.owncloud.android.utils.TestUtil
import com.owncloud.android.utils.ViewModelUtil
import com.owncloud.android.vo.Resource
import org.hamcrest.CoreMatchers.not
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -131,6 +131,11 @@ class PublicShareDialogFragmentTest {
onView(withId(R.id.shareViaLinkEditPermissionGroup)).check(matches(isDisplayed()))
}

@Test
fun showDefaultLinkName() {
onView(withId(R.id.shareViaLinkNameValue)).check(matches(withText("DOC_12112018.jpg link")))
}

@Test
fun enablePasswordSwitch() {
onView(withId(R.id.shareViaLinkPasswordSwitch)).perform(click())
Expand All @@ -153,8 +158,19 @@ class PublicShareDialogFragmentTest {

@Test
fun enableExpirationSwitch() {
// onView(withId(R.id.shareViaLinkExpirationSwitch)).perform(click())
// TODO Check date picker
onView(withId(R.id.shareViaLinkExpirationSwitch)).perform(click())
onView(withId(android.R.id.button1)).perform(click());
onView(withId(R.id.shareViaLinkExpirationValue))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
//TODO: check the date form the picker
}

@Test
fun cancelExpirationSwitch() {
onView(withId(R.id.shareViaLinkExpirationSwitch)).perform(click())
onView(withId(android.R.id.button2)).perform(click());
onView(withId(R.id.shareViaLinkExpirationValue))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE)))
}

@Test
Expand All @@ -172,16 +188,4 @@ class PublicShareDialogFragmentTest {
onView(withId(R.id.public_link_error_message)).check(matches(withText(R.string.share_link_file_no_exist)))
}

@Test
fun dismissDialog() {
onView(withId(R.id.saveButton)).perform(click())

sharesLiveData.postValue(
Resource.success(publicShares)
)

Log.d("HEEY", activityRule.activity.supportFragmentManager.findFragmentByTag("TEST FRAGMENT")?.toString())

onView(withText("Create link share")).check(matches(not(isDisplayed())))
}
}

0 comments on commit 164b12d

Please sign in to comment.