apps-android-commons/app/src/test/kotlin/fr/free/nrw/commons/AboutActivityUnitTests.kt
tristan 2d82a430c4
Issue-5662-kotlinstyle (#5833)
* *.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
2024-09-19 13:56:45 +09:00

117 lines
3.1 KiB
Kotlin

package fr.free.nrw.commons
import android.content.Context
import android.net.Uri
import android.view.Menu
import android.view.MenuItem
import androidx.test.core.app.ApplicationProvider
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.Shadows
import org.robolectric.annotation.Config
import org.robolectric.fakes.RoboMenu
import org.robolectric.fakes.RoboMenuItem
import org.robolectric.shadows.ShadowActivity
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [21], application = TestCommonsApplication::class)
class AboutActivityUnitTests {
private lateinit var activity: AboutActivity
private lateinit var context: Context
@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
activity = Robolectric.buildActivity(AboutActivity::class.java).create().get()
context = ApplicationProvider.getApplicationContext()
}
@Test
@Throws(Exception::class)
fun checkActivityNotNull() {
Assert.assertNotNull(activity)
}
@Test
@Throws(Exception::class)
fun testLaunchFacebook() {
activity.launchFacebook(null)
val shadowActivity: ShadowActivity = Shadows.shadowOf(activity)
val startedIntent = shadowActivity.nextStartedActivity
Assert.assertEquals(startedIntent.action, "android.intent.action.VIEW")
Assert.assertEquals(startedIntent.`package`, "com.facebook.katana")
Assert.assertEquals(startedIntent.`data`, Uri.parse("fb://page/1921335171459985"))
}
@Test
@Throws(Exception::class)
fun testLaunchGithub() {
activity.launchGithub(null)
}
@Test
@Throws(Exception::class)
fun testLaunchWebsite() {
activity.launchWebsite(null)
}
@Test
@Throws(Exception::class)
fun testLaunchRatings() {
activity.launchRatings(null)
}
@Test
@Throws(Exception::class)
fun testLaunchCredits() {
activity.launchCredits(null)
}
@Test
@Throws(Exception::class)
fun testLaunchPrivacyPolicy() {
activity.launchPrivacyPolicy(null)
}
@Test
@Throws(Exception::class)
fun testLaunchUserGuide() {
activity.launchUserGuide(null)
}
@Test
@Throws(Exception::class)
fun testLaunchFrequentlyAskedQuestions() {
activity.launchFrequentlyAskedQuesions(null)
}
@Test
@Throws(Exception::class)
fun testOnCreateOptionsMenu() {
val menu: Menu = RoboMenu(context)
activity.onCreateOptionsMenu(menu)
}
@Test
@Throws(Exception::class)
fun testOnOptionsItemSelected() {
val menuItem: MenuItem = RoboMenuItem(R.menu.menu_about)
activity.onOptionsItemSelected(menuItem)
val shadowActivity = Shadows.shadowOf(activity)
shadowActivity.clickMenuItem(R.id.share_app_icon)
}
@Test
@Throws(Exception::class)
fun testOnSupportNavigateUp() {
activity.onSupportNavigateUp()
}
}