mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-24 21:58:34 +03:00
Fix tests after Kotlin merge (probably)
This commit is contained in:
parent
db97250db8
commit
7a467d43df
7 changed files with 61 additions and 26 deletions
|
@ -29,7 +29,7 @@ public class DataModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public DatabaseHelper provideDatabaseHelper(Application app) {
|
||||
DatabaseHelper provideDatabaseHelper(Application app) {
|
||||
return new DatabaseHelper(app);
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,13 @@ public class DataModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public NetworkHelper provideNetworkHelper(Application app) {
|
||||
NetworkHelper provideNetworkHelper(Application app) {
|
||||
return new NetworkHelper(app);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SourceManager provideSourceManager(Application app) {
|
||||
SourceManager provideSourceManager(Application app) {
|
||||
return new SourceManager(app);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package eu.kanade.tachiyomi;
|
||||
|
||||
public class CustomBuildConfig {
|
||||
public static final boolean DEBUG = Boolean.parseBoolean("true");
|
||||
public static final String APPLICATION_ID = "eu.kanade.tachiyomi";
|
||||
public static final String BUILD_TYPE = "debug";
|
||||
public static final String FLAVOR = "";
|
||||
public static final int VERSION_CODE = 4;
|
||||
public static final String VERSION_NAME = "0.1.3";
|
||||
// Fields from default config.
|
||||
public static final String BUILD_TIME = "2016-02-19T14:49Z";
|
||||
public static final String COMMIT_COUNT = "482";
|
||||
public static final String COMMIT_SHA = "e52c498";
|
||||
public static final boolean INCLUDE_UPDATER = true;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package eu.kanade.tachiyomi;
|
||||
|
||||
import org.junit.runners.model.InitializationError;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.manifest.AndroidManifest;
|
||||
|
||||
public class CustomRobolectricGradleTestRunner
|
||||
extends RobolectricGradleTestRunner {
|
||||
|
||||
public CustomRobolectricGradleTestRunner(Class<?> klass) throws InitializationError {
|
||||
super(klass);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AndroidManifest getAppManifest(Config config) {
|
||||
AndroidManifest androidManifest = super.getAppManifest(config);
|
||||
androidManifest.setPackageName("eu.kanade.tachiyomi");
|
||||
return androidManifest;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi;
|
|||
|
||||
import eu.kanade.tachiyomi.injection.component.DaggerAppComponent;
|
||||
import eu.kanade.tachiyomi.injection.module.AppModule;
|
||||
import eu.kanade.tachiyomi.injection.module.TestDataModule;
|
||||
|
||||
public class TestApp extends App {
|
||||
|
||||
|
|
|
@ -10,21 +10,21 @@ import org.assertj.core.data.Offset;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowAlarmManager;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.shadows.ShadowPendingIntent;
|
||||
|
||||
import eu.kanade.tachiyomi.CustomBuildConfig;
|
||||
import eu.kanade.tachiyomi.BuildConfig;
|
||||
import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner;
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
@Config(constants = CustomBuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
|
||||
@RunWith(CustomRobolectricGradleTestRunner.class)
|
||||
public class LibraryUpdateAlarmTest {
|
||||
|
||||
ShadowApplication app;
|
||||
|
|
|
@ -9,14 +9,14 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import eu.kanade.tachiyomi.CustomBuildConfig;
|
||||
import eu.kanade.tachiyomi.BuildConfig;
|
||||
import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner;
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga;
|
||||
import eu.kanade.tachiyomi.data.source.base.Source;
|
||||
|
@ -31,8 +31,8 @@ import static org.mockito.Mockito.times;
|
|||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@Config(constants = CustomBuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
|
||||
@RunWith(CustomRobolectricGradleTestRunner.class)
|
||||
public class LibraryUpdateServiceTest {
|
||||
|
||||
ShadowApplication app;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package eu.kanade.tachiyomi.injection.module;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper;
|
||||
import eu.kanade.tachiyomi.data.network.NetworkHelper;
|
||||
import eu.kanade.tachiyomi.data.source.SourceManager;
|
||||
|
||||
public class TestDataModule extends DataModule {
|
||||
|
||||
@Override
|
||||
DatabaseHelper provideDatabaseHelper(Application app) {
|
||||
return Mockito.mock(DatabaseHelper.class, Mockito.RETURNS_DEEP_STUBS);
|
||||
}
|
||||
|
||||
@Override
|
||||
NetworkHelper provideNetworkHelper(Application app) {
|
||||
return Mockito.mock(NetworkHelper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
SourceManager provideSourceManager(Application app) {
|
||||
return Mockito.mock(SourceManager.class, Mockito.RETURNS_DEEP_STUBS);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue