mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-07-05 07:44:43 -04:00
Only show languages for selected book category
Previously displayed all languages, period. Also includes some testing updates to make sure everything is still covered.
This commit is contained in:
@ -1,46 +0,0 @@
|
||||
package org.bspeice.minimalbible.test.activity.downloader.manager;
|
||||
|
||||
import org.bspeice.minimalbible.activity.downloader.manager.LocaleManager;
|
||||
import org.crosswire.common.util.Language;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test cases for the Locale Manager
|
||||
*/
|
||||
public class LocaleManagerTest {
|
||||
|
||||
@Test
|
||||
public void testSortedLanguagesList() {
|
||||
Language english = new Language("en");
|
||||
Language russian = new Language("ru");
|
||||
Language french = new Language("fr");
|
||||
Language german = new Language("de");
|
||||
Language hebrew = new Language("he");
|
||||
Language afrikaans = new Language("af");
|
||||
|
||||
Observable<Language> languages = Observable.just(english, russian, french,
|
||||
german, hebrew, afrikaans);
|
||||
|
||||
LocaleManager.Core core = LocaleManager.Core.INSTANCE$;
|
||||
|
||||
//noinspection ConstantConditions
|
||||
List<Language> sortedLanguages = core.sortedLanguagesList(languages, english)
|
||||
.toBlocking().first();
|
||||
|
||||
// First language should be the 'current' (note this is an identity compare)
|
||||
assertTrue(sortedLanguages.get(0) == english);
|
||||
// Second language should be 'less than' third
|
||||
assertTrue(sortedLanguages.toString(),
|
||||
sortedLanguages.get(1).toString().compareTo(
|
||||
sortedLanguages.get(2).toString()) < 0);
|
||||
// Fifth language should be greater than the fourth
|
||||
assertTrue(sortedLanguages.toString(), sortedLanguages.get(4).toString().compareTo(
|
||||
sortedLanguages.get(3).toString()) > 0);
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import org.mockito.Mockito.mock
|
||||
import org.jetbrains.spek.api.Spek
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class DLProgressEventSpecs : Spek() {{
|
||||
class DLProgressEventSpek : Spek() {{
|
||||
|
||||
given("a DLProgressEvent created with 50% progress and a mock book") {
|
||||
val mockBook = mock(javaClass<Book>())
|
@ -0,0 +1,66 @@
|
||||
package org.bspeice.minimalbible.activity.downloader.manager
|
||||
|
||||
import org.jetbrains.spek.api.Spek
|
||||
import org.crosswire.common.util.Language
|
||||
|
||||
/**
|
||||
* Created by bspeice on 12/14/14.
|
||||
*/
|
||||
|
||||
class LocaleManagerSpek() : Spek() {{
|
||||
|
||||
given("some example language objects") {
|
||||
val english = Language("en")
|
||||
val russian = Language("ru")
|
||||
val french = Language("fr");
|
||||
|
||||
on("sorting between english and russian with current as english") {
|
||||
val result = LocaleManager.compareLanguages(english, russian, english)
|
||||
|
||||
it("should prioritize english") {
|
||||
assert(result < 0)
|
||||
}
|
||||
}
|
||||
|
||||
on("sorting between russian and english with current as english") {
|
||||
val result = LocaleManager.compareLanguages(russian, english, english)
|
||||
|
||||
it("should prioritize english") {
|
||||
assert(result > 0)
|
||||
}
|
||||
}
|
||||
|
||||
on("sorting between russian and english with current as french") {
|
||||
val result = LocaleManager.compareLanguages(russian, english, french)
|
||||
|
||||
it("should inform us that russian is greater") {
|
||||
assert(result > 0)
|
||||
}
|
||||
}
|
||||
|
||||
on("sorting between english and russian with current as french") {
|
||||
val result = LocaleManager.compareLanguages(english, russian, french)
|
||||
|
||||
it("should inform us that english is lesser") {
|
||||
assert(result < 0)
|
||||
}
|
||||
}
|
||||
|
||||
on("comparing the same languages with current language as the language being compared") {
|
||||
val result = LocaleManager.compareLanguages(english, english, english)
|
||||
|
||||
it("should report that the languages are duplicate") {
|
||||
assert(result == 0)
|
||||
}
|
||||
}
|
||||
|
||||
on("comparing the same languages with current language as something different") {
|
||||
val result = LocaleManager.compareLanguages(english, english, russian)
|
||||
|
||||
it("should report that the languages are duplicate") {
|
||||
assert(result == 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user