73 lines
2.3 KiB
Kotlin
73 lines
2.3 KiB
Kotlin
package pl.edu.amu.wmi.socialaggregator
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.test.espresso.Espresso.*
|
|
import androidx.test.espresso.action.ViewActions.click
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
|
import androidx.test.espresso.contrib.RecyclerViewActions
|
|
import androidx.test.espresso.intent.rule.IntentsTestRule
|
|
import androidx.test.espresso.matcher.ViewMatchers.*
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
import org.junit.Assert.assertTrue
|
|
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
import pl.edu.amu.wmi.socialaggregator.TestUtils.atPosition
|
|
import pl.edu.amu.wmi.socialaggregator.TestUtils.cleanLocalStorage
|
|
import pl.edu.amu.wmi.socialaggregator.TestUtils.getCurrentActivity
|
|
import pl.edu.amu.wmi.socialaggregator.activity.MainActivity
|
|
|
|
@RunWith(AndroidJUnit4::class)
|
|
class NewPostActivityTest {
|
|
|
|
@Rule
|
|
@JvmField
|
|
val activity = IntentsTestRule(MainActivity::class.java)
|
|
|
|
@Test
|
|
fun clickPublishPost_shouldEndActivity() {
|
|
onView(withId(R.id.createPostButton)).perform(click())
|
|
|
|
closeSoftKeyboard()
|
|
|
|
onView(withId(R.id.publishPost)).perform(click())
|
|
|
|
assertTrue(getCurrentActivity()!!::class.java.simpleName == "MainActivity")
|
|
}
|
|
|
|
@Test
|
|
fun clickPublishPost_shouldIncreasePostCount() {
|
|
cleanLocalStorage(activity)
|
|
|
|
onView(withId(R.id.connectedSocialsButton)).perform(click())
|
|
|
|
onView(withId(R.id.addSocialRecyclerView))
|
|
.perform(
|
|
RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
|
|
0,
|
|
TestUtils.actionOnChild(click(), R.id.socialPlatformImage)
|
|
)
|
|
)
|
|
|
|
pressBack()
|
|
|
|
onView(withId(R.id.createPostButton)).perform(click())
|
|
|
|
closeSoftKeyboard()
|
|
|
|
onView(withId(R.id.availableSocials))
|
|
.perform(
|
|
RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
|
|
0,
|
|
TestUtils.actionOnChild(click(), R.id.chip)
|
|
)
|
|
)
|
|
|
|
onView(withId(R.id.publishPost)).perform(click())
|
|
|
|
onView(withId(R.id.previousPostsRecyclerView)).check(
|
|
matches(atPosition(0, hasDescendant(withText("Facebook"))))
|
|
)
|
|
}
|
|
|
|
} |