mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Merge branch 'v4.2.0-release'
This commit is contained in:
commit
1490710a51
137 changed files with 456 additions and 449 deletions
4
.github/workflows/android.yml
vendored
4
.github/workflows/android.yml
vendored
|
|
@ -17,8 +17,8 @@ jobs:
|
|||
- name: Set up JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 11
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
- name: Cache packages
|
||||
id: cache-packages
|
||||
|
|
|
|||
15
.idea/codeStyles/Project.xml
generated
15
.idea/codeStyles/Project.xml
generated
|
|
@ -39,21 +39,18 @@
|
|||
<option name="ALIGN_INIT_LIST_IN_COLUMNS" value="false" />
|
||||
<option name="SPACE_BEFORE_SUPERCLASS_COLON" value="false" />
|
||||
</Objective-C>
|
||||
<Objective-C-extensions>
|
||||
<extensions>
|
||||
<pair source="cc" header="h" fileNamingConvention="NONE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
</extensions>
|
||||
</Objective-C-extensions>
|
||||
<Python>
|
||||
<option name="USE_CONTINUATION_INDENT_FOR_ARGUMENTS" value="true" />
|
||||
</Python>
|
||||
<TypeScriptCodeStyleSettings>
|
||||
<option name="INDENT_CHAINED_CALLS" value="false" />
|
||||
</TypeScriptCodeStyleSettings>
|
||||
<XML>
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
</XML>
|
||||
<files>
|
||||
<extensions>
|
||||
<pair source="cc" header="h" fileNamingConvention="NONE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
</extensions>
|
||||
</files>
|
||||
<codeStyleSettings language="CSS">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
|
|
|
|||
|
|
@ -20,8 +20,10 @@ dependencies {
|
|||
// Utils
|
||||
implementation 'in.yuvi:http.fluent:1.3'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation ("com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"){
|
||||
force = true //API 19 support
|
||||
implementation ("com.squareup.okhttp3:okhttp:$OKHTTP_VERSION!!"){
|
||||
// Forcing dependency versions using force = true on a first-level dependency has been deprecated.
|
||||
// Ref: https://docs.gradle.org/7.5/userguide/upgrading_version_5.html#forced_dependencies
|
||||
//force = true //API 19 support
|
||||
}
|
||||
implementation 'com.squareup.okio:okio:2.2.2'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||
|
|
@ -78,22 +80,22 @@ dependencies {
|
|||
|
||||
//Mocking
|
||||
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
|
||||
testImplementation 'org.mockito:mockito-inline:2.13.0'
|
||||
testImplementation 'org.mockito:mockito-core:2.25.1'
|
||||
testImplementation "org.powermock:powermock-module-junit4:2.0.2"
|
||||
testImplementation "org.powermock:powermock-api-mockito2:2.0.2"
|
||||
testImplementation 'org.mockito:mockito-inline:5.2.0'
|
||||
testImplementation 'org.mockito:mockito-core:5.5.0'
|
||||
testImplementation "org.powermock:powermock-module-junit4:2.0.9"
|
||||
testImplementation "org.powermock:powermock-api-mockito2:2.0.9"
|
||||
|
||||
// Unit testing
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.robolectric:robolectric:4.6.1'
|
||||
testImplementation 'androidx.test:core:1.4.0'
|
||||
testImplementation 'org.robolectric:robolectric:4.10.3'
|
||||
testImplementation 'androidx.test:core:1.5.0'
|
||||
testImplementation "com.squareup.okhttp3:mockwebserver:$OKHTTP_VERSION"
|
||||
testImplementation "com.jraska.livedata:testing-ktx:1.1.2"
|
||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.0"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.0"
|
||||
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.0"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.0"
|
||||
testImplementation 'com.facebook.soloader:soloader:0.10.1'
|
||||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.0"
|
||||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3"
|
||||
|
||||
// Android testing
|
||||
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
|
||||
|
|
@ -119,8 +121,7 @@ dependencies {
|
|||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation "androidx.exifinterface:exifinterface:1.3.2"
|
||||
implementation "androidx.core:core-ktx:$CORE_KTX_VERSION"
|
||||
implementation "androidx.multidex:multidex:2.0.1"
|
||||
compile 'com.simplecityapps:recyclerview-fastscroll:2.0.1'
|
||||
implementation 'com.simplecityapps:recyclerview-fastscroll:2.0.1'
|
||||
|
||||
//swipe_layout
|
||||
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
|
||||
|
|
@ -151,6 +152,8 @@ dependencies {
|
|||
//Glide
|
||||
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
||||
kaptTest "androidx.databinding:databinding-compiler:8.0.2"
|
||||
kaptAndroidTest "androidx.databinding:databinding-compiler:8.0.2"
|
||||
|
||||
implementation("io.github.coordinates2country:coordinates2country-android:1.3") { exclude group: 'com.google.android', module: 'android' }
|
||||
}
|
||||
|
|
@ -188,12 +191,16 @@ android {
|
|||
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/androidx.*'
|
||||
exclude 'META-INF/proguard/androidx-annotations.pro'
|
||||
jniLibs {
|
||||
excludes += ['META-INF/androidx.*']
|
||||
}
|
||||
resources {
|
||||
excludes += ['META-INF/androidx.*', 'META-INF/proguard/androidx-annotations.pro']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
testOptions {
|
||||
animationsDisabled true
|
||||
|
||||
|
|
@ -326,11 +333,6 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
disable 'MissingTranslation'
|
||||
disable 'ExtraTranslation'
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
|
|
@ -342,7 +344,11 @@ android {
|
|||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
namespace 'fr.free.nrw.commons'
|
||||
lint {
|
||||
abortOnError false
|
||||
disable 'MissingTranslation', 'ExtraTranslation'
|
||||
}
|
||||
}
|
||||
|
||||
String getTestUserName() {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
-keepattributes Signature
|
||||
# Retain declared checked exceptions for use by a Proxy instance.
|
||||
-keepattributes Exceptions
|
||||
# Classes used by retrofit to fetch API repsonse
|
||||
-keepclasseswithmembers class org.wikipedia.** { *; }
|
||||
# --- /Retrofit ---
|
||||
|
||||
# --- OkHttp + Okio ---
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="fr.free.nrw.commons">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ import fr.free.nrw.commons.R;
|
|||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.auth.SessionManager;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import fr.free.nrw.commons.utils.DialogUtil;
|
||||
import fr.free.nrw.commons.media.MediaClient;
|
||||
import fr.free.nrw.commons.profile.ProfileActivity;
|
||||
import fr.free.nrw.commons.utils.DialogUtil;
|
||||
import fr.free.nrw.commons.utils.SystemThemeUtils;
|
||||
import fr.free.nrw.commons.utils.ViewUtil;
|
||||
import java.util.Locale;
|
||||
|
|
@ -52,7 +53,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.wikipedia.dataclient.WikiSite;
|
||||
import fr.free.nrw.commons.profile.ProfileActivity;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +112,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
|
||||
private ContributionsListAdapter adapter;
|
||||
|
||||
@Nullable private Callback callback;
|
||||
@Nullable
|
||||
private Callback callback;
|
||||
|
||||
private final int SPAN_COUNT_LANDSCAPE = 3;
|
||||
private final int SPAN_COUNT_PORTRAIT = 1;
|
||||
|
|
@ -142,7 +143,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable @org.jetbrains.annotations.Nullable final Bundle savedInstanceState) {
|
||||
public void onCreate(
|
||||
@Nullable @org.jetbrains.annotations.Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//Now that we are allowing this fragment to be started for
|
||||
// any userName- we expect it to be passed as an argument
|
||||
|
|
@ -336,7 +338,7 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
* Launch Custom Selector.
|
||||
*/
|
||||
@OnClick(R.id.fab_custom_gallery)
|
||||
void launchCustomSelector(){
|
||||
void launchCustomSelector() {
|
||||
controller.initiateCustomGalleryPickWithPermission(getActivity());
|
||||
animateFAB(isFabOpen);
|
||||
}
|
||||
|
|
@ -348,24 +350,24 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
private void animateFAB(final boolean isFabOpen) {
|
||||
this.isFabOpen = !isFabOpen;
|
||||
if (fabPlus.isShown()) {
|
||||
if (isFabOpen) {
|
||||
fabPlus.startAnimation(rotate_backward);
|
||||
fabCamera.startAnimation(fab_close);
|
||||
fabGallery.startAnimation(fab_close);
|
||||
fabCustomGallery.startAnimation(fab_close);
|
||||
fabCamera.hide();
|
||||
fabGallery.hide();
|
||||
fabCustomGallery.hide();
|
||||
} else {
|
||||
fabPlus.startAnimation(rotate_forward);
|
||||
fabCamera.startAnimation(fab_open);
|
||||
fabGallery.startAnimation(fab_open);
|
||||
fabCustomGallery.startAnimation(fab_open);
|
||||
fabCamera.show();
|
||||
fabGallery.show();
|
||||
fabCustomGallery.show();
|
||||
}
|
||||
this.isFabOpen = !isFabOpen;
|
||||
if (isFabOpen) {
|
||||
fabPlus.startAnimation(rotate_backward);
|
||||
fabCamera.startAnimation(fab_close);
|
||||
fabGallery.startAnimation(fab_close);
|
||||
fabCustomGallery.startAnimation(fab_close);
|
||||
fabCamera.hide();
|
||||
fabGallery.hide();
|
||||
fabCustomGallery.hide();
|
||||
} else {
|
||||
fabPlus.startAnimation(rotate_forward);
|
||||
fabCamera.startAnimation(fab_open);
|
||||
fabGallery.startAnimation(fab_open);
|
||||
fabCustomGallery.startAnimation(fab_open);
|
||||
fabCamera.show();
|
||||
fabGallery.show();
|
||||
fabCustomGallery.show();
|
||||
}
|
||||
this.isFabOpen = !isFabOpen;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package fr.free.nrw.commons.filepicker;
|
||||
|
||||
import static fr.free.nrw.commons.filepicker.PickedFiles.singleFileList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
|
|
@ -8,13 +10,11 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import fr.free.nrw.commons.customselector.model.Image;
|
||||
import fr.free.nrw.commons.customselector.ui.selector.CustomSelectorActivity;
|
||||
import java.io.File;
|
||||
|
|
@ -23,8 +23,6 @@ import java.net.URISyntaxException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static fr.free.nrw.commons.filepicker.PickedFiles.singleFileList;
|
||||
|
||||
public class FilePicker implements Constants {
|
||||
|
||||
private static final String KEY_PHOTO_URI = "photo_uri";
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.app.PendingIntent;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import android.os.Build;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -49,21 +50,29 @@ public class NotificationHelper {
|
|||
* @param intent the intent to be fired when the notification is clicked
|
||||
*/
|
||||
public void showNotification(Context context,
|
||||
String notificationTitle,
|
||||
String notificationMessage,
|
||||
int notificationId,
|
||||
Intent intent) {
|
||||
String notificationTitle,
|
||||
String notificationMessage,
|
||||
int notificationId,
|
||||
Intent intent) {
|
||||
|
||||
notificationBuilder.setDefaults(DEFAULT_ALL)
|
||||
.setContentTitle(notificationTitle)
|
||||
.setStyle(new NotificationCompat.BigTextStyle()
|
||||
.bigText(notificationMessage))
|
||||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
.setProgress(0, 0, false)
|
||||
.setOngoing(false)
|
||||
.setPriority(PRIORITY_HIGH);
|
||||
.setContentTitle(notificationTitle)
|
||||
.setStyle(new NotificationCompat.BigTextStyle()
|
||||
.bigText(notificationMessage))
|
||||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
.setProgress(0, 0, false)
|
||||
.setOngoing(false)
|
||||
.setPriority(PRIORITY_HIGH);
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
|
||||
// Check if the API level is 31 or higher to modify the flag
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
// For API level 31 or above, PendingIntent requires either FLAG_IMMUTABLE or FLAG_MUTABLE to be set
|
||||
flags |= PendingIntent.FLAG_IMMUTABLE;
|
||||
}
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, flags);
|
||||
notificationBuilder.setContentIntent(pendingIntent);
|
||||
notificationManager.notify(notificationId, notificationBuilder.build());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,7 +225,6 @@ class DepictsPresenter @Inject constructor(
|
|||
)
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
} else {
|
||||
repository.cleanup()
|
||||
|
|
|
|||
|
|
@ -7,16 +7,13 @@ import android.content.pm.PackageManager;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.karumi.dexter.Dexter;
|
||||
import com.karumi.dexter.MultiplePermissionsReport;
|
||||
import com.karumi.dexter.PermissionToken;
|
||||
import com.karumi.dexter.listener.PermissionRequest;
|
||||
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.R;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class AboutActivityUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
activity = Robolectric.buildActivity(AboutActivity::class.java).create().get()
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class CommonsAppAdapterUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
adapter = CommonsAppAdapter(sessionManager, preferences)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class FakeContextWrapper(base: Context?) : ContextWrapper(base) {
|
|||
}
|
||||
|
||||
init {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
Mockito.`when`(mMockAccountManager.accounts).thenReturn(ACCOUNTS)
|
||||
Mockito.`when`(mMockAccountManager.getAccountsByType(BuildConfig.ACCOUNT_TYPE))
|
||||
.thenReturn(ACCOUNTS)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class FakeContextWrapperWithException(base: Context?) : ContextWrapper(base) {
|
|||
}
|
||||
|
||||
init {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
Mockito.`when`(mMockAccountManager.getAccountsByType(BuildConfig.ACCOUNT_TYPE))
|
||||
.thenThrow(SecurityException("Permission Denied"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class MediaDataExtractorTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class OkHttpJsonApiClientTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
okHttpJsonApiClient = OkHttpJsonApiClient(
|
||||
okhttpClient,
|
||||
depictsClient,
|
||||
|
|
|
|||
24
app/src/test/kotlin/fr/free/nrw/commons/TestUtility.kt
Normal file
24
app/src/test/kotlin/fr/free/nrw/commons/TestUtility.kt
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package fr.free.nrw.commons
|
||||
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
object TestUtility {
|
||||
@Throws(java.lang.Exception::class)
|
||||
fun setFinalStatic(field: Field, newValue: Any?) {
|
||||
try {
|
||||
field.isAccessible = true
|
||||
// remove final modifier from field
|
||||
val modifiersField: Field = Field::class.java.getDeclaredField("modifiers")
|
||||
modifiersField.isAccessible = true
|
||||
modifiersField.setInt(field, field.modifiers and Modifier.FINAL.inv())
|
||||
field.set(null, newValue)
|
||||
} catch (e: SecurityException) {
|
||||
e.stackTrace
|
||||
} catch (e: NoSuchFieldException) {
|
||||
e.stackTrace
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.stackTrace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ class PageEditClientTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
pageEditClient = PageEditClient(csrfTokenClient, pageEditInterface)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,15 +8,18 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockedStatic
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.wikipedia.csrf.CsrfTokenClient
|
||||
import org.wikipedia.dataclient.Service
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@PrepareForTest(CommonsApplication::class)
|
||||
class ThanksClientTest {
|
||||
@Mock
|
||||
|
|
@ -28,6 +31,7 @@ class ThanksClientTest {
|
|||
private lateinit var commonsApplication: CommonsApplication
|
||||
|
||||
private lateinit var thanksClient: ThanksClient
|
||||
private lateinit var mockedApplication: MockedStatic<CommonsApplication>
|
||||
|
||||
/**
|
||||
* initial setup, test environment
|
||||
|
|
@ -35,9 +39,9 @@ class ThanksClientTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
PowerMockito.mockStatic(CommonsApplication::class.java)
|
||||
PowerMockito.`when`(CommonsApplication.getInstance()).thenReturn(commonsApplication)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
mockedApplication = Mockito.mockStatic(CommonsApplication::class.java)
|
||||
`when`(CommonsApplication.getInstance()).thenReturn(commonsApplication)
|
||||
thanksClient = ThanksClient(csrfTokenClient, service)
|
||||
}
|
||||
|
||||
|
|
@ -46,8 +50,8 @@ class ThanksClientTest {
|
|||
*/
|
||||
@Test
|
||||
fun testThanks() {
|
||||
Mockito.`when`(csrfTokenClient.tokenBlocking).thenReturn("test")
|
||||
Mockito.`when`(commonsApplication.userAgent).thenReturn("test")
|
||||
`when`(csrfTokenClient.tokenBlocking).thenReturn("test")
|
||||
`when`(commonsApplication.userAgent).thenReturn("test")
|
||||
thanksClient.thank(1L)
|
||||
verify(service).thank(ArgumentMatchers.anyString(), ArgumentMatchers.any(), eq("test"), eq("test"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class LoginActivityUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
activity = Robolectric.buildActivity(LoginActivity::class.java).create().get()
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import javax.inject.Named
|
|||
class LogoutClientTest {
|
||||
|
||||
@Mock @field:[Inject Named("commons-service")]
|
||||
internal var service: Service? = null
|
||||
lateinit var service: Service
|
||||
|
||||
@InjectMocks
|
||||
var logoutClient: LogoutClient? = null
|
||||
|
|
@ -27,7 +27,7 @@ class LogoutClientTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
val mwQueryResponse = mock(MwQueryResponse::class.java)
|
||||
val mwQueryResult = mock(MwQueryResult::class.java)
|
||||
`when`(mwQueryResult!!.csrfToken()).thenReturn("test_token")
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class SessionManagerUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
accountManager = AccountManager.get(ApplicationProvider.getApplicationContext())
|
||||
shadowOf(accountManager).addAccount(account)
|
||||
sessionManager =
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class SignupActivityTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
activity = Robolectric.buildActivity(SignupActivity::class.java).create().get()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class WikiAccountAuthenticatorServiceUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
service = WikiAccountAuthenticatorService()
|
||||
service.onBind(null)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class WikiAccountAuthenticatorUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
authenticator = WikiAccountAuthenticator(context)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class BookmarkListRootFragmentUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
activity = Robolectric.buildActivity(MainActivity::class.java).create().get()
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class BookmarksPagerAdapterTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
bookmarksPagerAdapter = BookmarksPagerAdapter(fragmentManager, context, false)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class LoggedOutBookmarksPagerAdapterTests {
|
|||
*/
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
bookmarksPagerAdapter = BookmarksPagerAdapter(fragmentManager, context, true)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class BookmarkItemsControllerTest {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
whenever(bookmarkDao!!.allBookmarksItems)
|
||||
.thenReturn(mockBookmarkList)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.junit.Assert
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
|
|
@ -230,112 +231,112 @@ class BookmarkItemsDaoTest {
|
|||
fun migrateTableVersionFrom_v1_to_v2() {
|
||||
onUpdate(database, 1, 2)
|
||||
// Table didn't exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v2_to_v3() {
|
||||
onUpdate(database, 2, 3)
|
||||
// Table didn't exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v3_to_v4() {
|
||||
onUpdate(database, 3, 4)
|
||||
// Table didn't exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v4_to_v5() {
|
||||
onUpdate(database, 4, 5)
|
||||
// Table didn't change in version 5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v5_to_v6() {
|
||||
onUpdate(database, 5, 6)
|
||||
// Table didn't change in version 6
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v6_to_v7() {
|
||||
onUpdate(database, 6, 7)
|
||||
// Table didn't change in version 7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v7_to_v8() {
|
||||
onUpdate(database, 7, 8)
|
||||
// Table didn't change in version 8
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v8_to_v9() {
|
||||
onUpdate(database, 8, 9)
|
||||
// Table didn't change in version 9
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v9_to_v10() {
|
||||
onUpdate(database, 9, 10)
|
||||
// Table didn't change in version 10
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v10_to_v11() {
|
||||
onUpdate(database, 10, 11)
|
||||
// Table didn't change in version 11
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v11_to_v12() {
|
||||
onUpdate(database, 11, 12)
|
||||
// Table didn't change in version 12
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v12_to_v13() {
|
||||
onUpdate(database, 12, 13)
|
||||
// Table didn't change in version 13
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v13_to_v14() {
|
||||
onUpdate(database, 13, 14)
|
||||
// Table didn't change in version 14
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v14_to_v15() {
|
||||
onUpdate(database, 14, 15)
|
||||
// Table didn't change in version 15
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v15_to_v16() {
|
||||
onUpdate(database, 15, 16)
|
||||
// Table didn't change in version 16
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v16_to_v17() {
|
||||
onUpdate(database, 16, 17)
|
||||
// Table didn't change in version 17
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -347,7 +348,7 @@ class BookmarkItemsDaoTest {
|
|||
@Test
|
||||
fun migrateTableVersionFrom_v19_to_v19() {
|
||||
onUpdate(database, 19, 19)
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
private fun createCursor(rowCount: Int) = MatrixCursor(columns, rowCount).apply {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class BookmarkItemsFragmentUnitTest {
|
|||
*/
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
val activity = Robolectric.buildActivity(ProfileActivity::class.java).create().get()
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import org.junit.Assert.*
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
|
|
@ -215,42 +216,42 @@ class BookMarkLocationDaoTest {
|
|||
fun migrateTableVersionFrom_v1_to_v2() {
|
||||
onUpdate(database, 1, 2)
|
||||
// Table didnt exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v2_to_v3() {
|
||||
onUpdate(database, 2, 3)
|
||||
// Table didnt exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v3_to_v4() {
|
||||
onUpdate(database, 3, 4)
|
||||
// Table didnt exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v4_to_v5() {
|
||||
onUpdate(database, 4, 5)
|
||||
// Table didnt change in version 5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v5_to_v6() {
|
||||
onUpdate(database, 5, 6)
|
||||
// Table didnt change in version 6
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v6_to_v7() {
|
||||
onUpdate(database, 6, 7)
|
||||
// Table didnt change in version 7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao.Table.*
|
|||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
|
|
@ -165,42 +166,42 @@ class BookmarkPictureDaoTest {
|
|||
fun migrateTableVersionFrom_v1_to_v2() {
|
||||
onUpdate(database, 1, 2)
|
||||
// Table didn't exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v2_to_v3() {
|
||||
onUpdate(database, 2, 3)
|
||||
// Table didn't exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v3_to_v4() {
|
||||
onUpdate(database, 3, 4)
|
||||
// Table didn't exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v4_to_v5() {
|
||||
onUpdate(database, 4, 5)
|
||||
// Table didn't change in version 5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v5_to_v6() {
|
||||
onUpdate(database, 5, 6)
|
||||
// Table didn't change in version 6
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v6_to_v7() {
|
||||
onUpdate(database, 6, 7)
|
||||
// Table didn't change in version 7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class CategoriesModelTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
categoriesModel = CategoriesModel(categoryClient, categoryDao, gpsCategoryModel)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class CategoryClientTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.junit.Assert.*
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.util.*
|
||||
|
|
@ -57,21 +58,21 @@ class CategoryDaoTest {
|
|||
fun migrateTableVersionFrom_v1_to_v2() {
|
||||
onUpdate(database, 1, 2)
|
||||
// Table didnt exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v2_to_v3() {
|
||||
onUpdate(database, 2, 3)
|
||||
// Table didnt exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v3_to_v4() {
|
||||
onUpdate(database, 3, 4)
|
||||
// Table didnt exist before v5
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -84,21 +85,21 @@ class CategoryDaoTest {
|
|||
fun migrateTableVersionFrom_v5_to_v6() {
|
||||
onUpdate(database, 5, 6)
|
||||
// Table didnt change in version 6
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v6_to_v7() {
|
||||
onUpdate(database, 6, 7)
|
||||
// Table didnt change in version 7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun migrateTableVersionFrom_v7_to_v8() {
|
||||
onUpdate(database, 7, 8)
|
||||
// Table didnt change in version 8
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class CategoryDetailsActivityUnitTests {
|
|||
@Before
|
||||
fun setUp() {
|
||||
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class CategoryEditHelperUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
helper = CategoryEditHelper(notificationHelper, pageEditClient, viewUtilWrapper,
|
||||
"")
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class GridViewAdapterUnitTest {
|
|||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package fr.free.nrw.commons.contributions
|
|||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.nhaarman.mockitokotlin2.verify
|
||||
import com.nhaarman.mockitokotlin2.verifyZeroInteractions
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.media.MediaClient
|
||||
|
|
@ -17,6 +16,7 @@ import org.mockito.ArgumentMatchers.anyList
|
|||
import org.mockito.ArgumentMatchers.anyString
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
import org.mockito.MockitoAnnotations
|
||||
import java.lang.reflect.Method
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ class ContributionBoundaryCallbackTest {
|
|||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(contributionBoundaryCallback)
|
||||
verifyZeroInteractions(repository);
|
||||
verifyNoInteractions(repository)
|
||||
verify(mediaClient).getMediaListForUser(anyString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.facebook.soloader.SoLoader
|
|||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
||||
import fr.free.nrw.commons.media.MediaClient
|
||||
import fr.free.nrw.commons.profile.ProfileActivity
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
|
@ -25,17 +26,21 @@ import org.junit.runner.RunWith
|
|||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.reflect.Whitebox
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.Shadows
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.LooperMode
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
@LooperMode(LooperMode.Mode.PAUSED)
|
||||
@PrepareForTest(ContributionViewHolder::class)
|
||||
class ContributionViewHolderUnitTests {
|
||||
|
||||
private lateinit var contributionViewHolder: ContributionViewHolder
|
||||
|
|
@ -116,14 +121,9 @@ class ContributionViewHolderUnitTests {
|
|||
|
||||
progressView = parent.findViewById(R.id.contributionProgress)
|
||||
Whitebox.setInternalState(contributionViewHolder, "progressView", progressView)
|
||||
|
||||
|
||||
Whitebox.setInternalState(
|
||||
contributionViewHolder,
|
||||
"compositeDisposable",
|
||||
compositeDisposable
|
||||
)
|
||||
|
||||
setFinalStatic(
|
||||
ContributionViewHolder::class.java.getDeclaredField("compositeDisposable"),
|
||||
compositeDisposable)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -3,14 +3,9 @@ package fr.free.nrw.commons.contributions
|
|||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.nhaarman.mockitokotlin2.times
|
||||
import com.nhaarman.mockitokotlin2.verify
|
||||
import com.nhaarman.mockitokotlin2.verifyZeroInteractions
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.media.MediaClient
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.Scheduler
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
|
|
@ -18,7 +13,6 @@ import org.junit.Test
|
|||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.ArgumentMatchers.any
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
|
|
|
|||
|
|
@ -8,18 +8,23 @@ import androidx.test.core.app.ApplicationProvider
|
|||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import fr.free.nrw.commons.TestAppAdapter
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.reflect.Whitebox
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import org.wikipedia.AppAdapter
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
@PrepareForTest(OnSwipeTouchListener::class)
|
||||
internal class OnSwipeTouchListenerTest {
|
||||
|
||||
private lateinit var context: Context
|
||||
|
|
@ -42,13 +47,14 @@ internal class OnSwipeTouchListenerTest {
|
|||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
// motionEvent1 = MotionEvent.obtain(200, 300, MotionEvent.ACTION_MOVE, 15.0f, 10.0f, 0);
|
||||
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
onSwipeTouchListener = OnSwipeTouchListener(context)
|
||||
gesListener = OnSwipeTouchListener(context).GestureListener()
|
||||
|
||||
Whitebox.setInternalState(onSwipeTouchListener, "gestureDetector", gestureDetector)
|
||||
|
||||
setFinalStatic(
|
||||
OnSwipeTouchListener::class.java.getDeclaredField("gestureDetector"),
|
||||
gestureDetector)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -56,9 +62,10 @@ internal class OnSwipeTouchListenerTest {
|
|||
*/
|
||||
@Test
|
||||
fun onTouch() {
|
||||
val motionEvent = MotionEvent.obtain(200, 300, MotionEvent.ACTION_MOVE, 15.0f, 10.0f, 0);
|
||||
val func = onSwipeTouchListener.javaClass.getDeclaredMethod("onTouch", View::class.java, MotionEvent::class.java)
|
||||
func.isAccessible = true
|
||||
func.invoke(onSwipeTouchListener, view, motionEvent1)
|
||||
func.invoke(onSwipeTouchListener, view, motionEvent)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import android.widget.GridLayout
|
|||
import com.nhaarman.mockitokotlin2.any
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
||||
import fr.free.nrw.commons.customselector.listeners.FolderClickListener
|
||||
import fr.free.nrw.commons.customselector.model.Folder
|
||||
import fr.free.nrw.commons.customselector.model.Image
|
||||
|
|
@ -25,6 +26,8 @@ import org.powermock.reflect.Whitebox
|
|||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
/**
|
||||
* Custom Selector Folder Adapter Test.
|
||||
|
|
@ -49,7 +52,7 @@ class FolderAdapterTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
activity = Robolectric.buildActivity(CustomSelectorActivity::class.java).get()
|
||||
image = Image(1, "image", uri, "abc/abc", 1, "bucket1")
|
||||
|
|
@ -76,7 +79,6 @@ class FolderAdapterTest {
|
|||
|
||||
whenever(context.contentResolver).thenReturn(mockContentResolver)
|
||||
whenever(mockContentResolver.getType(any())).thenReturn("jpg")
|
||||
Whitebox.setInternalState(folderAdapter, "context", context)
|
||||
folderAdapter.init(folderList)
|
||||
folderAdapter.onBindViewHolder(FolderAdapter.FolderViewHolder(listItemView), 0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import android.widget.GridLayout
|
|||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
||||
import fr.free.nrw.commons.customselector.listeners.ImageSelectListener
|
||||
import fr.free.nrw.commons.customselector.model.Image
|
||||
import fr.free.nrw.commons.customselector.ui.selector.CustomSelectorActivity
|
||||
|
|
@ -33,6 +34,7 @@ import org.robolectric.Robolectric
|
|||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
|
@ -107,8 +109,6 @@ class ImageAdapterTest {
|
|||
|
||||
whenever(context.contentResolver).thenReturn(mockContentResolver)
|
||||
whenever(mockContentResolver.getType(uri)).thenReturn("jpg")
|
||||
Whitebox.setInternalState(imageAdapter, "context", context)
|
||||
|
||||
// Parameters.
|
||||
images.add(image)
|
||||
imageAdapter.init(images, images, TreeMap())
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class CustomSelectorActivityTest {
|
|||
*/
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
||||
activity = Robolectric.buildActivity(CustomSelectorActivity::class.java)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.nhaarman.mockitokotlin2.doReturn
|
|||
import com.nhaarman.mockitokotlin2.mock
|
||||
import com.nhaarman.mockitokotlin2.same
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
||||
import fr.free.nrw.commons.customselector.listeners.ImageLoaderListener
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -23,6 +24,8 @@ import org.robolectric.annotation.Config
|
|||
import org.robolectric.annotation.LooperMode
|
||||
import org.robolectric.fakes.RoboCursor
|
||||
import java.io.File
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
/**
|
||||
|
|
@ -67,8 +70,9 @@ class ImageFileLoaderTest {
|
|||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
|
||||
MediaStore.Images.Media.DATE_ADDED
|
||||
)
|
||||
|
||||
Whitebox.setInternalState(imageFileLoader, "coroutineContext", coroutineContext)
|
||||
setFinalStatic(
|
||||
ImageFileLoader::class.java.getDeclaredField("coroutineContext"),
|
||||
coroutineContext)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.content.SharedPreferences
|
|||
import android.net.Uri
|
||||
import com.nhaarman.mockitokotlin2.*
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
||||
import fr.free.nrw.commons.customselector.database.NotForUploadStatusDao
|
||||
import fr.free.nrw.commons.customselector.database.UploadedStatus
|
||||
import fr.free.nrw.commons.customselector.database.UploadedStatusDao
|
||||
|
|
@ -24,22 +25,28 @@ import kotlinx.coroutines.test.*
|
|||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.*
|
||||
import org.mockito.Mockito.mockStatic
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
import org.powermock.reflect.Whitebox
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
/**
|
||||
* Image Loader Test.
|
||||
*/
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@PrepareForTest(PickedFiles::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
@ExperimentalCoroutinesApi
|
||||
|
|
@ -89,13 +96,15 @@ class ImageLoaderTest {
|
|||
private var mapHolderImage : HashMap<ImageAdapter.ImageViewHolder, Image> = HashMap()
|
||||
private var mapResult: HashMap<String, ImageLoader.Result> = HashMap()
|
||||
private var mapModifiedImageSHA1: HashMap<Image, String> = HashMap()
|
||||
private lateinit var image: Image;
|
||||
private lateinit var uploadedStatus: UploadedStatus;
|
||||
private lateinit var image: Image
|
||||
private lateinit var uploadedStatus: UploadedStatus
|
||||
private lateinit var mockedPickedFiles: MockedStatic<PickedFiles>
|
||||
|
||||
/**
|
||||
* Setup before test.
|
||||
*/
|
||||
@Before
|
||||
@BeforeAll
|
||||
@ExperimentalCoroutinesApi
|
||||
fun setup() {
|
||||
Dispatchers.setMain(testDispacher)
|
||||
|
|
@ -117,11 +126,13 @@ class ImageLoaderTest {
|
|||
Whitebox.setInternalState(imageLoader, "mapHolderImage", mapHolderImage);
|
||||
Whitebox.setInternalState(imageLoader, "mapModifiedImageSHA1", mapModifiedImageSHA1);
|
||||
Whitebox.setInternalState(imageLoader, "mapResult", mapResult);
|
||||
Whitebox.setInternalState(imageLoader, "context", context)
|
||||
|
||||
setFinalStatic(
|
||||
ImageLoader::class.java.getDeclaredField("context"),
|
||||
context)
|
||||
whenever(contentResolver.openInputStream(uri)).thenReturn(inputStream)
|
||||
whenever(context.contentResolver).thenReturn(contentResolver)
|
||||
whenever(fileUtilsWrapper.getSHA1(inputStream)).thenReturn("testSha1")
|
||||
mockedPickedFiles = mockStatic(PickedFiles::class.java)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -132,6 +143,7 @@ class ImageLoaderTest {
|
|||
fun tearDown() {
|
||||
Dispatchers.resetMain()
|
||||
testDispacher.cleanupTestCoroutines()
|
||||
mockedPickedFiles.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -173,7 +185,7 @@ class ImageLoaderTest {
|
|||
whenever(notForUploadStatusDao.find(any())).thenReturn(0)
|
||||
whenever(uploadedStatusDao.findByImageSHA1(any(), any())).thenReturn(0)
|
||||
whenever(uploadedStatusDao.findByModifiedImageSHA1(any(), any())).thenReturn(0)
|
||||
PowerMockito.mockStatic(PickedFiles::class.java)
|
||||
// mockStatic(PickedFiles::class.java)
|
||||
BDDMockito.given(PickedFiles.pickedExistingPicture(context, image.uri))
|
||||
.willReturn(UploadableFile(uri, File("ABC")))
|
||||
whenever(fileUtilsWrapper.getFileInputStream("ABC")).thenReturn(inputStream)
|
||||
|
|
@ -200,7 +212,6 @@ class ImageLoaderTest {
|
|||
@ExperimentalCoroutinesApi
|
||||
fun testGetSha1() = testDispacher.runBlockingTest {
|
||||
|
||||
PowerMockito.mockStatic(PickedFiles::class.java)
|
||||
BDDMockito.given(PickedFiles.pickedExistingPicture(context, image.uri))
|
||||
.willReturn(UploadableFile(uri, File("ABC")))
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class DeleteHelperTest {
|
|||
*/
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
deleteHelper = DeleteHelper(mock(), pageEditClient, mock(), "")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class ReasonBuilderTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
val resources = mock(Resources::class.java)
|
||||
`when`(resources!!.getString(anyInt())).thenReturn("test")
|
||||
`when`(context!!.resources).thenReturn(resources)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class BasePagingPresenterTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
whenever(pageableBaseDataSource.pagingResults).thenReturn(searchResults)
|
||||
whenever(pageableBaseDataSource.loadingStates).thenReturn(loadingStates)
|
||||
whenever(pageableBaseDataSource.noItemsLoadedQueries)
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ExploreFragmentUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class ExploreListRootFragmentUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class PageableBaseDataSourceTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
pageableBaseDataSource = object: PageableBaseDataSource<String>(liveDataConverter){
|
||||
override val loadFunction: LoadFunction<String>
|
||||
get() = mock()
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class PagingDataSourceFactoryTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
factory = object : PagingDataSourceFactory<String>(loadingStates) {
|
||||
override val loadFunction get() = function
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import org.junit.After
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
class PagingDataSourceTest {
|
||||
|
|
@ -25,7 +26,7 @@ class PagingDataSourceTest {
|
|||
@Before
|
||||
fun setUp() {
|
||||
RxJavaPlugins.setIoSchedulerHandler { Schedulers.trampoline() }
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
loadingStates = PublishProcessor.create()
|
||||
searchDepictionsDataSource =
|
||||
TestPagingDataSource(
|
||||
|
|
@ -88,7 +89,7 @@ class PagingDataSourceTest {
|
|||
@Test
|
||||
fun `retryFailedRequest does nothing when null`() {
|
||||
searchDepictionsDataSource.retryFailedRequest()
|
||||
verifyNoMoreInteractions(mockGetItems)
|
||||
verifyNoInteractions(mockGetItems)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class PageableCategoriesMediaDataSourceTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class PageableParentCategoriesDataSourceTest{
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class PageableSubCategoriesDataSourceTest{
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class DepictsClientTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
depictsClient = DepictsClient(depictsInterface)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class WikidataItemDetailsActivityUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
val intent = Intent(
|
||||
ApplicationProvider.getApplicationContext(),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class PageableChildDepictionsDataSourceTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class PageableParentDepictionsDataSourceTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class MediaConverterTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
mediaConverter = MediaConverter()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class PageableMediaDataSourceTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.junit.Assert.*
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.util.*
|
||||
|
|
@ -65,7 +66,7 @@ class RecentSearchesDaoTest {
|
|||
fun migrateTableVersionFrom_v1_to_v2() {
|
||||
onUpdate(database, 1, 2)
|
||||
// Table didnt exist before v7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -75,7 +76,7 @@ class RecentSearchesDaoTest {
|
|||
fun migrateTableVersionFrom_v2_to_v3() {
|
||||
onUpdate(database, 2, 3)
|
||||
// Table didnt exist before v7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -85,7 +86,7 @@ class RecentSearchesDaoTest {
|
|||
fun migrateTableVersionFrom_v3_to_v4() {
|
||||
onUpdate(database, 3, 4)
|
||||
// Table didnt exist before v7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,7 +96,7 @@ class RecentSearchesDaoTest {
|
|||
fun migrateTableVersionFrom_v4_to_v5() {
|
||||
onUpdate(database, 4, 5)
|
||||
// Table didnt exist before v7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,7 +106,7 @@ class RecentSearchesDaoTest {
|
|||
fun migrateTableVersionFrom_v5_to_v6() {
|
||||
onUpdate(database, 5, 6)
|
||||
// Table didnt exist before v7
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -124,7 +125,7 @@ class RecentSearchesDaoTest {
|
|||
fun migrateTableVersionFrom_v7_to_v8() {
|
||||
onUpdate(database, 7, 8)
|
||||
// Table didnt change in version 8
|
||||
verifyZeroInteractions(database)
|
||||
verifyNoInteractions(database)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class RecentSearchesFragmentUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import org.junit.jupiter.api.Assertions.assertEquals
|
|||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.times
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.api.mockito.PowerMockito.mock
|
||||
|
|
@ -82,12 +81,9 @@ class SearchActivityUnitTests {
|
|||
@Mock
|
||||
private lateinit var searchCategoryFragment: SearchCategoryFragment
|
||||
|
||||
@Mock
|
||||
private lateinit var mFragments: FragmentController
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
activity = Robolectric.buildActivity(SearchActivity::class.java).create().get()
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
}
|
||||
|
|
@ -120,12 +116,7 @@ class SearchActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnBackPressed() {
|
||||
Whitebox.setInternalState(activity, "mFragments", mFragments)
|
||||
Whitebox.setInternalState(activity, "mediaDetails", mediaDetails)
|
||||
`when`(mFragments.supportFragmentManager).thenReturn(supportFragmentManager)
|
||||
`when`(supportFragmentManager.backStackEntryCount).thenReturn(0)
|
||||
activity.onBackPressed()
|
||||
verify(supportFragmentManager, times(2)).backStackEntryCount
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -196,42 +187,6 @@ class SearchActivityUnitTests {
|
|||
assertEquals(activity.totalMediaCount, num)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testRefreshNominatedMediaCase1() {
|
||||
Whitebox.setInternalState(activity, "mFragments", mFragments)
|
||||
Whitebox.setInternalState(activity, "mediaDetails", mediaDetails)
|
||||
`when`(mFragments.supportFragmentManager).thenReturn(supportFragmentManager)
|
||||
`when`(supportFragmentManager.backStackEntryCount).thenReturn(1)
|
||||
`when`(mediaDetails.isVisible).thenReturn(true)
|
||||
activity.refreshNominatedMedia(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testRefreshNominatedMediaCase2() {
|
||||
Whitebox.setInternalState(activity, "mFragments", mFragments)
|
||||
Whitebox.setInternalState(activity, "mediaDetails", mediaDetails)
|
||||
`when`(mFragments.supportFragmentManager).thenReturn(supportFragmentManager)
|
||||
`when`(supportFragmentManager.backStackEntryCount).thenReturn(1)
|
||||
`when`(mediaDetails.isVisible).thenReturn(true)
|
||||
activity.refreshNominatedMedia(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnResume() {
|
||||
Whitebox.setInternalState(activity, "mFragments", mFragments)
|
||||
Whitebox.setInternalState(activity, "supportFragmentManager", supportFragmentManager)
|
||||
Whitebox.setInternalState(activity, "mediaDetails", mediaDetails)
|
||||
`when`(mFragments.supportFragmentManager).thenReturn(supportFragmentManager)
|
||||
`when`(supportFragmentManager.backStackEntryCount).thenReturn(1)
|
||||
`when`(mediaDetails.isVisible).thenReturn(true)
|
||||
val method: Method = SearchActivity::class.java.getDeclaredMethod("onResume")
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testHandleSearchCaseEmpty() {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class FeedbackContentCreatorUnitTests {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
context = FakeContextWrapper(ApplicationProvider.getApplicationContext())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ import androidx.test.core.app.ApplicationProvider
|
|||
import com.nhaarman.mockitokotlin2.doReturn
|
||||
import fr.free.nrw.commons.TestAppAdapter
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
||||
import fr.free.nrw.commons.contributions.MainActivity
|
||||
import fr.free.nrw.commons.databinding.DialogFeedbackBinding
|
||||
import fr.free.nrw.commons.ui.PasteSensitiveTextInputEditText
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
|
|
@ -40,7 +42,7 @@ class FeedbackDialogTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
|
@ -64,9 +66,11 @@ class FeedbackDialogTests {
|
|||
fun testSubmitFeedbackError() {
|
||||
val editable = mock(Editable::class.java)
|
||||
val ed = mock(PasteSensitiveTextInputEditText::class.java)
|
||||
Whitebox.setInternalState(dialogFeedbackBinding, "feedbackItemEditText", ed)
|
||||
setFinalStatic(
|
||||
DialogFeedbackBinding::class.java.getDeclaredField("feedbackItemEditText"),
|
||||
ed)
|
||||
`when`(ed?.text).thenReturn(editable)
|
||||
doReturn(editable).`when`(dialogFeedbackBinding.feedbackItemEditText)?.text
|
||||
doReturn(editable).`when`(ed)?.text
|
||||
doReturn("").`when`(editable).toString()
|
||||
dialog.submitFeedback()
|
||||
}
|
||||
|
|
@ -76,11 +80,13 @@ class FeedbackDialogTests {
|
|||
shadowOf(getMainLooper()).idle()
|
||||
val editable: Editable = mock(Editable::class.java)
|
||||
val ed = mock(PasteSensitiveTextInputEditText::class.java)
|
||||
Whitebox.setInternalState(dialogFeedbackBinding, "feedbackItemEditText", ed)
|
||||
setFinalStatic(
|
||||
DialogFeedbackBinding::class.java.getDeclaredField("feedbackItemEditText"),
|
||||
ed)
|
||||
`when`(ed?.text).thenReturn(editable)
|
||||
`when`(editable.toString()).thenReturn("1234")
|
||||
|
||||
Assert.assertEquals(dialogFeedbackBinding.feedbackItemEditText?.text.toString(), "1234")
|
||||
Assert.assertEquals(ed.text.toString(), "1234")
|
||||
dialog.submitFeedback()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class FilePickerTest {
|
|||
`when`(sharedPref.edit().putInt("type", 0)).thenReturn(sharedPreferencesEditor)
|
||||
FilePicker.openGallery(activity, 0, nextBoolean())
|
||||
verify(activity).startActivityForResult(
|
||||
ArgumentMatchers.anyObject(),
|
||||
ArgumentMatchers.any(),
|
||||
requestCodeCaptor?.capture()?.toInt()!!
|
||||
)
|
||||
assertEquals(requestCodeCaptor?.value, RequestCodes.PICK_PICTURE_FROM_GALLERY)
|
||||
|
|
@ -78,7 +78,7 @@ class FilePickerTest {
|
|||
`when`(activity.applicationContext).thenReturn(mockApplication)
|
||||
FilePicker.openCameraForImage(activity, 0)
|
||||
verify(activity).startActivityForResult(
|
||||
ArgumentMatchers.anyObject(),
|
||||
ArgumentMatchers.any(),
|
||||
requestCodeCaptor?.capture()?.toInt()!!
|
||||
)
|
||||
assertEquals(requestCodeCaptor?.value, RequestCodes.TAKE_PICTURE)
|
||||
|
|
@ -227,7 +227,7 @@ class FilePickerTest {
|
|||
`when`(sharedPref.edit()).thenReturn(sharedPreferencesEditor)
|
||||
`when`(sharedPref.edit().putInt("type", 0)).thenReturn(sharedPreferencesEditor)
|
||||
FilePicker.openCustomSelector(activity, 0)
|
||||
verify(activity).startActivityForResult(ArgumentMatchers.anyObject(), requestCodeCaptor?.capture()?.toInt()!!)
|
||||
verify(activity).startActivityForResult(ArgumentMatchers.any(), requestCodeCaptor?.capture()?.toInt()!!)
|
||||
assertEquals(requestCodeCaptor?.value, RequestCodes.PICK_PICTURE_FROM_CUSTOM_SELECTOR)
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ class LoginActivityUnitTests {
|
|||
@Before
|
||||
fun setUp() {
|
||||
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class CustomOkHttpNetworkFetcherUnitTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
okHttpClient = OkHttpClient()
|
||||
fetcher = CustomOkHttpNetworkFetcher(okHttpClient, defaultKvStore)
|
||||
whenever(context.imageRequest).thenReturn(imageRequest)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class MediaClientTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
mediaClient =
|
||||
MediaClient(mediaInterface, pageMediaInterface, mediaDetailInterface, mediaConverter)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,16 +60,12 @@ class MediaDetailFragmentUnitTests {
|
|||
|
||||
private val REQUEST_CODE = 1001
|
||||
private val LAST_LOCATION = "last_location_while_uploading"
|
||||
private val REQUEST_CODE_EDIT_DESCRIPTION = 1002
|
||||
private lateinit var fragment: MediaDetailFragment
|
||||
private lateinit var fragmentManager: FragmentManager
|
||||
private lateinit var layoutInflater: LayoutInflater
|
||||
private lateinit var view: View
|
||||
private lateinit var context: Context
|
||||
|
||||
private val NOMINATING_FOR_DELETION_MEDIA = "Nominating for deletion %s"
|
||||
|
||||
|
||||
@Mock
|
||||
private lateinit var deleteHelper: DeleteHelper
|
||||
|
||||
|
|
@ -147,7 +143,7 @@ class MediaDetailFragmentUnitTests {
|
|||
@Before
|
||||
fun setUp() {
|
||||
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class MediaDetailPagerFragmentUnitTests {
|
|||
@Before
|
||||
fun setUp() {
|
||||
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class ZoomableActivityUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
SoLoader.setInTestMode()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class MultiPointerGestureDetectorUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
detector = MultiPointerGestureDetector()
|
||||
detector = MultiPointerGestureDetector.newInstance()
|
||||
detector.setListener(listener)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class TransformGestureDetectorUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
detector = TransformGestureDetector(MultiPointerGestureDetector())
|
||||
detector = TransformGestureDetector.newInstance()
|
||||
detector.setListener(listener)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class UserClientTest{
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class MoreBottomSheetFragmentUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class AdvanceQueryFragmentUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
activity = Robolectric.buildActivity(MainActivity::class.java).create().get()
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package fr.free.nrw.commons.nearby
|
|||
import android.widget.CompoundButton
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.nhaarman.mockitokotlin2.verify
|
||||
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.location.LatLng
|
||||
import fr.free.nrw.commons.nearby.CheckBoxTriStates.CHECKED
|
||||
|
|
@ -12,6 +11,7 @@ import org.junit.Before
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
|
@ -31,7 +31,7 @@ class CheckBoxTriStatesTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
checkBoxTriStates = CheckBoxTriStates(ApplicationProvider.getApplicationContext())
|
||||
checkBoxTriStates.setCallback(callback)
|
||||
checkBoxTriStates.setOnCheckedChangeListener(onCheckChangeListener)
|
||||
|
|
@ -44,7 +44,7 @@ class CheckBoxTriStatesTest {
|
|||
fun testSetStateWhenSameState() {
|
||||
checkBoxTriStates.state = CHECKED
|
||||
checkBoxTriStates.setState(CHECKED)
|
||||
verifyNoMoreInteractions(callback)
|
||||
verifyNoInteractions(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -66,6 +66,6 @@ class CheckBoxTriStatesTest {
|
|||
NearbyController.currentLocation = null
|
||||
checkBoxTriStates.state = CHECKED
|
||||
checkBoxTriStates.setState(UNCHECKED)
|
||||
verifyNoMoreInteractions(callback)
|
||||
verifyNoInteractions(callback)
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ class CommonPlaceClickActionsUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
val activity = Robolectric.buildActivity(ProfileActivity::class.java).create().get()
|
||||
commonPlaceClickActions = CommonPlaceClickActions(store, activity, contributionController)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class NearbyBaseMarkerUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
marker = NearbyBaseMarker()
|
||||
Whitebox.setInternalState(marker, "icon", icon)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class NearbyControllerTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
nearbyController = NearbyController(nearbyPlaces)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class NearbyFilterSearchRecyclerViewAdapterUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
adapter = NearbyFilterSearchRecyclerViewAdapter(context, ArrayList<Label>(Label.valuesAsList()), recyclerView)
|
||||
viewHolder.placeTypeIcon = imageView
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.junit.Test
|
|||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.verifyNoInteractions
|
||||
import org.mockito.MockitoAnnotations
|
||||
import java.util.*
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ class NearbyParentFragmentPresenterTest {
|
|||
@Before
|
||||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
nearbyPresenter = NearbyParentFragmentPresenter(bookmarkLocationsDao)
|
||||
nearbyPresenter.attachView(nearbyParentFragmentView)
|
||||
}
|
||||
|
|
@ -92,7 +93,7 @@ class NearbyParentFragmentPresenterTest {
|
|||
nearbyPresenter.lockUnlockNearby(true)
|
||||
nearbyPresenter.updateMapAndList(null)
|
||||
verify(nearbyParentFragmentView).disableFABRecenter()
|
||||
verifyZeroInteractions(nearbyParentFragmentView)
|
||||
verifyNoMoreInteractions(nearbyParentFragmentView)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -238,7 +239,7 @@ class NearbyParentFragmentPresenterTest {
|
|||
fun testFilterByMarkerTypeMultiSelectUNKNOWN() {
|
||||
val state = CheckBoxTriStates.UNKNOWN
|
||||
nearbyPresenter.filterByMarkerType(selectedLabels,state,false,true)
|
||||
verifyZeroInteractions(nearbyParentFragmentView)
|
||||
verifyNoInteractions(nearbyParentFragmentView)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -499,7 +500,7 @@ class NearbyParentFragmentPresenterTest {
|
|||
nearbyPresenter.onCameraMove(Mockito.mock(com.mapbox.mapboxsdk.geometry.LatLng::class.java))
|
||||
verify(nearbyParentFragmentView).setProjectorLatLngBounds()
|
||||
verify(nearbyParentFragmentView).isNetworkConnectionEstablished()
|
||||
verifyZeroInteractions(nearbyParentFragmentView)
|
||||
verifyNoMoreInteractions(nearbyParentFragmentView)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -509,7 +510,7 @@ class NearbyParentFragmentPresenterTest {
|
|||
nearbyPresenter.onCameraMove(Mockito.mock(com.mapbox.mapboxsdk.geometry.LatLng::class.java))
|
||||
verify(nearbyParentFragmentView).setProjectorLatLngBounds()
|
||||
verify(nearbyParentFragmentView).isNetworkConnectionEstablished()
|
||||
verifyZeroInteractions(nearbyParentFragmentView)
|
||||
verifyNoMoreInteractions(nearbyParentFragmentView)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class NearbyParentFragmentUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class NearbyPlacesTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
nearbyPlaces = NearbyPlaces(okHttpJsonApiClient)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class ProfileActivityTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
activity = Robolectric.buildActivity(ProfileActivity::class.java).create().get()
|
||||
mockContext = ApplicationProvider.getApplicationContext()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class AchievementsFragmentUnitTests {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
context = ApplicationProvider.getApplicationContext()
|
||||
menuItem = RoboMenuItem(context)
|
||||
AppAdapter.set(TestAppAdapter())
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class LevelControllerTest {
|
|||
*/
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
levelController = LevelController()
|
||||
levelInfo = LevelController.LevelInfo.from(
|
||||
IMAGES_UPLOADED_SAMPLE_VALUE,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class QuizActivityUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
SoLoader.setInTestMode()
|
||||
Fresco.initialize(ApplicationProvider.getApplicationContext())
|
||||
activity = Robolectric.buildActivity(QuizActivity::class.java).create().get()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class QuizCheckerUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
SoLoader.setInTestMode()
|
||||
Fresco.initialize(ApplicationProvider.getApplicationContext())
|
||||
activity = Robolectric.buildActivity(QuizActivity::class.java).create().get()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class QuizControllerTest {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
`when`(context.getString(any(Int::class.java)))
|
||||
.thenReturn("")
|
||||
quizController = QuizController()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class QuizQuestionTest {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
quizQuestion = QuizQuestion(
|
||||
QUESTION_NUM_SAMPLE_VALUE,
|
||||
QUESTION_SAMPLE_VALUE,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class QuizResultActivityUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
val intent = Intent().putExtra("QuizResult", 0)
|
||||
activity = Robolectric.buildActivity(QuizResultActivity::class.java, intent).get()
|
||||
quizResultActivity = PowerMockito.mock(QuizResultActivity::class.java)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class RadioGroupHelperUnitTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MockitoAnnotations.openMocks(this)
|
||||
radioGroupHelper = RadioGroupHelper()
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue