tests: fix failure
Fix some accidental regressions and unported mocks.
This commit is contained in:
parent
b72f33a989
commit
4e5a3f7fe1
3 changed files with 28 additions and 55 deletions
|
@ -26,6 +26,8 @@ import org.oxycblt.auxio.list.Item
|
||||||
* @param number The disc number.
|
* @param number The disc number.
|
||||||
* @param name The name of the disc group, if any. Null if not present.
|
* @param name The name of the disc group, if any. Null if not present.
|
||||||
*/
|
*/
|
||||||
data class Disc(val number: Int, val name: String?) : Item, Comparable<Disc> {
|
class Disc(val number: Int, val name: String?) : Item, Comparable<Disc> {
|
||||||
|
override fun equals(other: Any?) = other is Disc && number == other.number
|
||||||
|
override fun hashCode() = number.hashCode()
|
||||||
override fun compareTo(other: Disc) = number.compareTo(other.number)
|
override fun compareTo(other: Disc) = number.compareTo(other.number)
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,10 +111,11 @@ sealed interface Name : Comparable<Name> {
|
||||||
companion object {
|
companion object {
|
||||||
/**
|
/**
|
||||||
* Create a new instance of [Name.Known]
|
* Create a new instance of [Name.Known]
|
||||||
|
*
|
||||||
* @param raw The raw name obtained from the music item
|
* @param raw The raw name obtained from the music item
|
||||||
* @param sort The raw sort name obtained from the music item
|
* @param sort The raw sort name obtained from the music item
|
||||||
* @param musicSettings [MusicSettings] required to obtain user-preferred sorting
|
* @param musicSettings [MusicSettings] required to obtain user-preferred sorting
|
||||||
* configurations
|
* configurations
|
||||||
*/
|
*/
|
||||||
fun from(raw: String, sort: String?, musicSettings: MusicSettings): Known =
|
fun from(raw: String, sort: String?, musicSettings: MusicSettings): Known =
|
||||||
if (musicSettings.intelligentSorting) {
|
if (musicSettings.intelligentSorting) {
|
||||||
|
@ -148,6 +149,7 @@ private val PUNCT_REGEX = Regex("[\\p{Punct}+]")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plain [Name.Known] implementation that is internationalization-safe.
|
* Plain [Name.Known] implementation that is internationalization-safe.
|
||||||
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
private data class SimpleKnownName(override val raw: String, override val sort: String?) :
|
private data class SimpleKnownName(override val raw: String, override val sort: String?) :
|
||||||
|
@ -165,6 +167,7 @@ private data class SimpleKnownName(override val raw: String, override val sort:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [Name.Known] implementation that adds advanced sorting behavior at the cost of localization.
|
* [Name.Known] implementation that adds advanced sorting behavior at the cost of localization.
|
||||||
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
private data class IntelligentKnownName(override val raw: String, override val sort: String?) :
|
private data class IntelligentKnownName(override val raw: String, override val sort: String?) :
|
||||||
|
@ -192,23 +195,23 @@ private data class IntelligentKnownName(override val raw: String, override val s
|
||||||
// individual lexicographic and numeric tokens and then individually compare them
|
// individual lexicographic and numeric tokens and then individually compare them
|
||||||
// with special logic.
|
// with special logic.
|
||||||
return TOKEN_REGEX.findAll(stripped).mapTo(mutableListOf()) { match ->
|
return TOKEN_REGEX.findAll(stripped).mapTo(mutableListOf()) { match ->
|
||||||
// Remove excess whitespace where possible
|
// Remove excess whitespace where possible
|
||||||
val token = match.value.trim().ifEmpty { match.value }
|
val token = match.value.trim().ifEmpty { match.value }
|
||||||
val collationKey: CollationKey
|
val collationKey: CollationKey
|
||||||
val type: SortToken.Type
|
val type: SortToken.Type
|
||||||
// Separate each token into their numeric and lexicographic counterparts.
|
// Separate each token into their numeric and lexicographic counterparts.
|
||||||
if (token.first().isDigit()) {
|
if (token.first().isDigit()) {
|
||||||
// The digit string comparison breaks with preceding zero digits, remove those
|
// The digit string comparison breaks with preceding zero digits, remove those
|
||||||
val digits = token.trimStart('0').ifEmpty { token }
|
val digits = token.trimStart('0').ifEmpty { token }
|
||||||
// Other languages have other types of digit strings, still use collation keys
|
// Other languages have other types of digit strings, still use collation keys
|
||||||
collationKey = COLLATOR.getCollationKey(digits)
|
collationKey = COLLATOR.getCollationKey(digits)
|
||||||
type = SortToken.Type.NUMERIC
|
type = SortToken.Type.NUMERIC
|
||||||
} else {
|
} else {
|
||||||
collationKey = COLLATOR.getCollationKey(token)
|
collationKey = COLLATOR.getCollationKey(token)
|
||||||
type = SortToken.Type.LEXICOGRAPHIC
|
type = SortToken.Type.LEXICOGRAPHIC
|
||||||
}
|
|
||||||
SortToken(collationKey, type)
|
|
||||||
}
|
}
|
||||||
|
SortToken(collationKey, type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -18,20 +18,16 @@
|
||||||
|
|
||||||
package org.oxycblt.auxio.music
|
package org.oxycblt.auxio.music
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import org.oxycblt.auxio.music.fs.MimeType
|
import org.oxycblt.auxio.music.fs.MimeType
|
||||||
import org.oxycblt.auxio.music.fs.Path
|
import org.oxycblt.auxio.music.fs.Path
|
||||||
import org.oxycblt.auxio.music.info.Date
|
import org.oxycblt.auxio.music.info.Date
|
||||||
import org.oxycblt.auxio.music.info.Disc
|
import org.oxycblt.auxio.music.info.Disc
|
||||||
|
import org.oxycblt.auxio.music.info.Name
|
||||||
import org.oxycblt.auxio.music.info.ReleaseType
|
import org.oxycblt.auxio.music.info.ReleaseType
|
||||||
|
|
||||||
open class FakeSong : Song {
|
open class FakeSong : Song {
|
||||||
override val rawName: String?
|
override val name: Name
|
||||||
get() = throw NotImplementedError()
|
|
||||||
override val rawSortName: String?
|
|
||||||
get() = throw NotImplementedError()
|
|
||||||
override val sortName: SortName?
|
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
override val date: Date?
|
override val date: Date?
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
|
@ -59,18 +55,10 @@ open class FakeSong : Song {
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
override val uid: Music.UID
|
override val uid: Music.UID
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
|
|
||||||
override fun resolveName(context: Context): String {
|
|
||||||
throw NotImplementedError()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open class FakeAlbum : Album {
|
open class FakeAlbum : Album {
|
||||||
override val rawName: String?
|
override val name: Name
|
||||||
get() = throw NotImplementedError()
|
|
||||||
override val rawSortName: String?
|
|
||||||
get() = throw NotImplementedError()
|
|
||||||
override val sortName: SortName?
|
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
override val coverUri: Uri
|
override val coverUri: Uri
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
|
@ -88,18 +76,10 @@ open class FakeAlbum : Album {
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
override val uid: Music.UID
|
override val uid: Music.UID
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
|
|
||||||
override fun resolveName(context: Context): String {
|
|
||||||
throw NotImplementedError()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open class FakeArtist : Artist {
|
open class FakeArtist : Artist {
|
||||||
override val rawName: String?
|
override val name: Name
|
||||||
get() = throw NotImplementedError()
|
|
||||||
override val rawSortName: String?
|
|
||||||
get() = throw NotImplementedError()
|
|
||||||
override val sortName: SortName?
|
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
override val albums: List<Album>
|
override val albums: List<Album>
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
|
@ -113,18 +93,10 @@ open class FakeArtist : Artist {
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
override val uid: Music.UID
|
override val uid: Music.UID
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
|
|
||||||
override fun resolveName(context: Context): String {
|
|
||||||
throw NotImplementedError()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open class FakeGenre : Genre {
|
open class FakeGenre : Genre {
|
||||||
override val rawName: String?
|
override val name: Name
|
||||||
get() = throw NotImplementedError()
|
|
||||||
override val rawSortName: String?
|
|
||||||
get() = throw NotImplementedError()
|
|
||||||
override val sortName: SortName?
|
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
override val albums: List<Album>
|
override val albums: List<Album>
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
|
@ -136,8 +108,4 @@ open class FakeGenre : Genre {
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
override val uid: Music.UID
|
override val uid: Music.UID
|
||||||
get() = throw NotImplementedError()
|
get() = throw NotImplementedError()
|
||||||
|
|
||||||
override fun resolveName(context: Context): String {
|
|
||||||
throw NotImplementedError()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue