-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
271 additions
and
269 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
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
13 changes: 13 additions & 0 deletions
13
.../androidMain/kotlin/app/cash/sqldelight/driver/androidx/sqlite/TransactionsThreadLocal.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,13 @@ | ||
package app.cash.sqldelight.driver.androidx.sqlite | ||
|
||
import app.cash.sqldelight.Transacter | ||
|
||
internal actual class TransactionsThreadLocal actual constructor() { | ||
private val transactions = ThreadLocal<Transacter.Transaction>() | ||
|
||
internal actual fun get(): Transacter.Transaction? = transactions.get() | ||
|
||
internal actual fun set(transaction: Transacter.Transaction?) { | ||
transactions.set(transaction) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...st/kotlin/app/cash/sqldelight/driver/androidx/sqlite/AndroidxSqliteCommonTests.android.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,49 @@ | ||
package app.cash.sqldelight.driver.androidx.sqlite | ||
|
||
import androidx.sqlite.SQLiteDriver | ||
import androidx.sqlite.driver.AndroidSQLiteDriver | ||
import app.cash.sqldelight.Transacter | ||
import com.squareup.sqldelight.driver.test.DriverTest | ||
import com.squareup.sqldelight.driver.test.QueryTest | ||
import com.squareup.sqldelight.driver.test.TransacterTest | ||
import java.util.concurrent.Semaphore | ||
import org.junit.Assert | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
actual abstract class CommonDriverTest : DriverTest() | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
actual abstract class CommonQueryTest : QueryTest() | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
actual abstract class CommonTransacterTest : TransacterTest() | ||
|
||
actual fun androidxSqliteTestDriver(): SQLiteDriver = AndroidSQLiteDriver() | ||
|
||
actual inline fun <T> assertChecksThreadConfinement( | ||
transacter: Transacter, | ||
crossinline scope: Transacter.(T.() -> Unit) -> Unit, | ||
crossinline block: T.() -> Unit, | ||
) { | ||
lateinit var thread: Thread | ||
var result: Result<Unit>? = null | ||
val semaphore = Semaphore(0) | ||
|
||
transacter.scope { | ||
thread = kotlin.concurrent.thread { | ||
result = runCatching { | ||
this@scope.block() | ||
} | ||
|
||
semaphore.release() | ||
} | ||
} | ||
|
||
semaphore.acquire() | ||
thread.interrupt() | ||
Assert.assertThrows(IllegalStateException::class.java) { | ||
result!!.getOrThrow() | ||
} | ||
} |
80 changes: 0 additions & 80 deletions
80
...oidUnitTest/kotlin/app/cash/sqldelight/driver/androidx/sqlite/AndroidxSqliteDriverTest.kt
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...roidUnitTest/kotlin/app/cash/sqldelight/driver/androidx/sqlite/AndroidxSqliteQueryTest.kt
This file was deleted.
Oops, something went wrong.
90 changes: 0 additions & 90 deletions
90
...nitTest/kotlin/app/cash/sqldelight/driver/androidx/sqlite/AndroidxSqliteTransacterTest.kt
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.