forked from ankidroid/Anki-Android-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert remaining Java files to Kotlin
- Loading branch information
Showing
49 changed files
with
2,463 additions
and
2,825 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
rsdroid-instrumented/src/androidTest/java/net/ankiweb/rsdroid/BackendDisposalTests.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
rsdroid-instrumented/src/androidTest/java/net/ankiweb/rsdroid/BackendDisposalTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2020 David Allison <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 3 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ankiweb.rsdroid | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import net.ankiweb.rsdroid.ankiutil.DatabaseUtil.queryScalar | ||
import net.ankiweb.rsdroid.ankiutil.InstrumentedTest | ||
import net.ankiweb.rsdroid.database.AnkiSupportSQLiteDatabase.Companion.withRustBackend | ||
import org.junit.Ignore | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import timber.log.Timber | ||
import java.io.IOException | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class BackendDisposalTests : InstrumentedTest() { | ||
/** This test should be run under the profiler */ | ||
@Test | ||
@Ignore("Run under profiler") | ||
@Throws(IOException::class) | ||
fun testDisposalDoesNotLeak() { | ||
for (i in 0..9999) { | ||
Timber.d("Iteration %d", i) | ||
super.getBackend("initial_version_2_12_1.anki2").use { backend -> | ||
val db = withRustBackend(backend) | ||
queryScalar(db, "select count(*) from revlog") | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
@Ignore | ||
fun getAssetFilePathFileLeak() { | ||
// testDisposalDoesNotLeak had a failure: open failed: EMFILE (Too many open files) | ||
// This determines if it is our file handling, or rust implementation which has the issue. | ||
for (i in 0..9999) { | ||
getAssetFilePath("initial_version_2_12_1.anki2") | ||
} | ||
} | ||
|
||
} |
74 changes: 0 additions & 74 deletions
74
rsdroid-instrumented/src/androidTest/java/net/ankiweb/rsdroid/BackendForTesting.java
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
rsdroid-instrumented/src/androidTest/java/net/ankiweb/rsdroid/BackendForTesting.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2021 David Allison <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 3 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ankiweb.rsdroid | ||
|
||
import androidx.annotation.VisibleForTesting | ||
|
||
class BackendForTesting(langs: Iterable<String>) : Backend(langs) { | ||
// Debug methods | ||
/** | ||
* Throws a given error, generated from the Rust | ||
* @param error The error to throw | ||
*/ | ||
@VisibleForTesting | ||
fun debugProduceError(error: ErrorType) { | ||
super.debugProduceError(error.toString()) | ||
throw IllegalStateException("An exception should have been thrown") | ||
} | ||
|
||
enum class ErrorType { | ||
InvalidInput, TemplateError, DbErrorFileTooNew, DbErrorFileTooOld, DbErrorMissingEntity, DbErrorCorrupt, DbErrorLocked, DbErrorOther, NetworkError, SyncErrorAuthFailed, SyncErrorOther, JSONError, ProtoError, Interrupted, CollectionNotOpen, CollectionAlreadyOpen, NotFound, Existing, FilteredDeckError, SearchError, FatalError | ||
} | ||
|
||
companion object { | ||
fun create(): BackendForTesting { | ||
System.loadLibrary("rsdroid") | ||
return BackendForTesting(mutableListOf("en")) | ||
} | ||
} | ||
} |
86 changes: 0 additions & 86 deletions
86
rsdroid-instrumented/src/androidTest/java/net/ankiweb/rsdroid/BackendIntegrationTests.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.