mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Added Review Activity Tests (#4167)
* Added Review Activity Tests * Remove Unused Code
This commit is contained in:
parent
9296ef6fbd
commit
381f54c5ef
2 changed files with 105 additions and 0 deletions
|
|
@ -92,6 +92,7 @@ dependencies {
|
||||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.1"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.1"
|
||||||
|
testImplementation 'com.facebook.soloader:soloader:0.9.0'
|
||||||
|
|
||||||
// Mockito and PowerMock
|
// Mockito and PowerMock
|
||||||
androidTestCompile ('org.powermock:powermock-mockito-release-full:1.6.0') {
|
androidTestCompile ('org.powermock:powermock-mockito-release-full:1.6.0') {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
package fr.free.nrw.commons.review
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import com.facebook.drawee.backends.pipeline.Fresco
|
||||||
|
import com.facebook.soloader.SoLoader
|
||||||
|
import fr.free.nrw.commons.TestAppAdapter
|
||||||
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.mockito.MockitoAnnotations
|
||||||
|
import org.robolectric.Robolectric
|
||||||
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
import org.robolectric.RuntimeEnvironment
|
||||||
|
import org.robolectric.annotation.Config
|
||||||
|
import org.robolectric.fakes.RoboMenu
|
||||||
|
import org.robolectric.fakes.RoboMenuItem
|
||||||
|
import org.wikipedia.AppAdapter
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||||
|
class ReviewActivityTest {
|
||||||
|
|
||||||
|
private lateinit var activity: ReviewActivity
|
||||||
|
|
||||||
|
private lateinit var menuItem: MenuItem
|
||||||
|
|
||||||
|
private lateinit var menu: Menu
|
||||||
|
|
||||||
|
private lateinit var context: Context
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this)
|
||||||
|
|
||||||
|
context = RuntimeEnvironment.application.applicationContext
|
||||||
|
|
||||||
|
AppAdapter.set(TestAppAdapter())
|
||||||
|
|
||||||
|
SoLoader.setInTestMode()
|
||||||
|
|
||||||
|
Fresco.initialize(context)
|
||||||
|
|
||||||
|
activity = Robolectric.buildActivity(ReviewActivity::class.java).create().get()
|
||||||
|
|
||||||
|
menuItem = RoboMenuItem(null)
|
||||||
|
|
||||||
|
menu = RoboMenu(context)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun checkActivityNotNull() {
|
||||||
|
Assert.assertNotNull(activity)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testOnSupportNavigateUp() {
|
||||||
|
activity.onSupportNavigateUp()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testSwipeToNext() {
|
||||||
|
activity.swipeToNext()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testOnDestroy() {
|
||||||
|
activity.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testShowSkipImageInfo() {
|
||||||
|
activity.showSkipImageInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testShowReviewImageInfo() {
|
||||||
|
activity.showReviewImageInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testOnCreateOptionsMenu() {
|
||||||
|
activity.onCreateOptionsMenu(menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun testOnOptionsItemSelected() {
|
||||||
|
activity.onOptionsItemSelected(menuItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue