mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 05:43:55 +01:00
* *.kt: bulk correction of formatting using ktlint --format * *.kt: replace wildcard imports and second stage auto format ktlint --format * QuizQuestionTest.kt: modified property names to camel case to meet ktlint standard * LevelControllerTest.kt: modified property names to camel case to meet ktlint standard * QuizActivityUnitTest.kt: modified property names to camel case to meet ktlint standard * MediaDetailFragmentUnitTests.kt: modified property names to camel case to meet ktlint standard * UploadWorker.kt: modified property names to camel case to meet ktlint standard * UploadClient.kt: modified property names to camel case to meet ktlint standard * BasePagingPresenter.kt: modified property names to camel case to meet ktlint standard * DescriptionEditActivity.kt: modified property names to camel case to meet ktlint standard * OnSwipeTouchListener.kt: modified property names to camel case to meet ktlint standard * MediaDetailFragmentUnitTests.kt: corrected excessive line length to meet ktlint standard * DepictedItem.kt: corrected property name format and catch format to for ktlint standard * UploadCategoryAdapter.kt: corrected class definition format to meet ktlint standard * CustomSelectorActivity.kt: reformatted function names to first letter lowercase to meet ktlint standard * MediaDetailFragmentUnitTests.kt: fix string literal indentation to meet ktlint standard * NotForUploadDao.kt: file renamed to match class name, new file NotForUploadStatusDao.kt * UploadedDao.kt: file renamed to match class name, new file UploadedStatusDao.kt * Urls.kt: fixed excessive line length for ktLint standard * Snak_partial.kt & Statement_partial.kt: refactored to remove underscores in class names to meet ktLint standard * *.kt: fixed consecutive KDOC error for ktLint * PageableBaseDataSourceTest.kt & UploadPresenterTest.kt: fixed excessive line lengths to meet ktLint standard * CheckboxTriStatesTest.kt: renamed file to match class name to meet ktLint standard * .kt: resolved backing-property-naming error in ktLint, made matching properties public, matched names and refactored * TestConnectionFactory.kt: fixed property naming to adhere to ktLint standard
81 lines
2.3 KiB
Kotlin
81 lines
2.3 KiB
Kotlin
package fr.free.nrw.commons
|
|
|
|
import android.content.Intent
|
|
import android.widget.TextView
|
|
import fr.free.nrw.commons.quiz.QuizActivity
|
|
import org.junit.Assert.assertEquals
|
|
import org.junit.Assert.assertNotNull
|
|
import org.junit.Before
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
import org.robolectric.Robolectric
|
|
import org.robolectric.RobolectricTestRunner
|
|
import org.robolectric.Shadows.shadowOf
|
|
import org.robolectric.annotation.Config
|
|
import org.robolectric.shadows.ShadowActivity
|
|
import org.robolectric.shadows.ShadowIntent
|
|
|
|
/**
|
|
* Tests Welcome Activity Methods
|
|
*/
|
|
@RunWith(RobolectricTestRunner::class)
|
|
@Config(sdk = [21], application = TestCommonsApplication::class)
|
|
class WelcomeActivityUnitTest {
|
|
private lateinit var activity: WelcomeActivity
|
|
private lateinit var finishTutorialButton: TextView
|
|
|
|
/**
|
|
* Setup the Class and Views for Test
|
|
* Initialise the activity with isQuiz as true for Intent Extra
|
|
*/
|
|
@Before
|
|
fun setUp() {
|
|
val intent = Intent().putExtra("isQuiz", true)
|
|
activity =
|
|
Robolectric
|
|
.buildActivity(WelcomeActivity::class.java, intent)
|
|
.get()
|
|
activity.onCreate(null)
|
|
finishTutorialButton = activity.findViewById(R.id.finishTutorialButton)
|
|
}
|
|
|
|
/**
|
|
* Checks if the activity is not null
|
|
*/
|
|
@Test
|
|
@Throws(Exception::class)
|
|
fun checkActivityNotNull() {
|
|
assertNotNull(activity)
|
|
}
|
|
|
|
/**
|
|
* Checks if the activity onDestroy method launches correct intent when isQuiz is true
|
|
*/
|
|
@Test
|
|
@Throws(Exception::class)
|
|
fun testOnDestroy() {
|
|
activity.onDestroy()
|
|
val shadowActivity: ShadowActivity = shadowOf(activity)
|
|
val startedIntent = shadowActivity.nextStartedActivity
|
|
val shadowIntent: ShadowIntent = shadowOf(startedIntent)
|
|
assertEquals(shadowIntent.intentClass, QuizActivity::class.java)
|
|
}
|
|
|
|
/**
|
|
* Checks if the finish Tutorial Button executes the finishTutorial method without any errors
|
|
*/
|
|
@Test
|
|
@Throws(Exception::class)
|
|
fun testFinishTutorial() {
|
|
finishTutorialButton.performClick()
|
|
}
|
|
|
|
/**
|
|
* Checks if the onBackPressed method executes without any errors
|
|
*/
|
|
@Test
|
|
@Throws(Exception::class)
|
|
fun testOnBackPressed() {
|
|
activity.onBackPressed()
|
|
}
|
|
}
|