mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
fix: fix tests, don't use iterables
This commit is contained in:
parent
665a69a0df
commit
f934c79078
@ -13,6 +13,7 @@ import org.junit.Assert.*
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.session.libsignal.utilities.Hex
|
import org.session.libsignal.utilities.Hex
|
||||||
|
import org.session.libsignal.utilities.Log
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instrumented test, which will execute on an Android device.
|
* Instrumented test, which will execute on an Android device.
|
||||||
@ -491,7 +492,7 @@ class InstrumentedTests {
|
|||||||
assertTrue(x2.unread)
|
assertTrue(x2.unread)
|
||||||
|
|
||||||
val anotherId = "051111111111111111111111111111111111111111111111111111111111111111"
|
val anotherId = "051111111111111111111111111111111111111111111111111111111111111111"
|
||||||
val c2 = convos.getOrConstructLegacyClosedGroup(anotherId)
|
val c2 = convos.getOrConstructOneToOne(anotherId)
|
||||||
c2.unread = true
|
c2.unread = true
|
||||||
convos2.set(c2)
|
convos2.set(c2)
|
||||||
|
|
||||||
@ -513,29 +514,27 @@ class InstrumentedTests {
|
|||||||
assertEquals(seqNo2, convos.push().seqNo)
|
assertEquals(seqNo2, convos.push().seqNo)
|
||||||
|
|
||||||
val seen = mutableListOf<String>()
|
val seen = mutableListOf<String>()
|
||||||
for (conv in listOf(convos, convos2)) {
|
for ((ind, conv) in listOf(convos, convos2).withIndex()) {
|
||||||
|
Log.e("Test","Testing seen from convo #$ind")
|
||||||
seen.clear()
|
seen.clear()
|
||||||
assertEquals(4, conv.size())
|
assertEquals(4, conv.size())
|
||||||
assertEquals(2, conv.sizeOneToOnes())
|
assertEquals(2, conv.sizeOneToOnes())
|
||||||
assertEquals(1, conv.sizeOpenGroups())
|
assertEquals(1, conv.sizeOpenGroups())
|
||||||
assertEquals(1, conv.sizeLegacyClosedGroups())
|
assertEquals(1, conv.sizeLegacyClosedGroups())
|
||||||
assertFalse(conv.empty())
|
assertFalse(conv.empty())
|
||||||
for (convo in conv.all()) {
|
val allConvos = conv.all()
|
||||||
|
for (convo in allConvos) {
|
||||||
when (convo) {
|
when (convo) {
|
||||||
is Conversation.OneToOne -> seen.add("1-to-1: ${convo.sessionId}")
|
is Conversation.OneToOne -> seen.add("1-to-1: ${convo.sessionId}")
|
||||||
is Conversation.OpenGroup -> seen.add("og: ${convo.baseUrl}/r/${convo.room}")
|
is Conversation.OpenGroup -> seen.add("og: ${convo.baseUrl}/r/${convo.room}")
|
||||||
is Conversation.LegacyClosedGroup -> seen.add("cl: ${convo.groupId}")
|
is Conversation.LegacyClosedGroup -> seen.add("cl: ${convo.groupId}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals(listOf(
|
|
||||||
"1-to-1: " +
|
assertTrue(seen.contains("1-to-1: 051111111111111111111111111111111111111111111111111111111111111111"))
|
||||||
"051111111111111111111111111111111111111111111111111111111111111111",
|
assertTrue(seen.contains("1-to-1: 055000000000000000000000000000000000000000000000000000000000000000"))
|
||||||
"1-to-1: " +
|
assertTrue(seen.contains("og: http://example.org:5678/r/sudokuroom"))
|
||||||
"055000000000000000000000000000000000000000000000000000000000000000",
|
assertTrue(seen.contains("cl: 05cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"))
|
||||||
"og: http://example.org:5678/r/sudokuroom",
|
|
||||||
"cl: " +
|
|
||||||
"05ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
|
|
||||||
), seen)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assertFalse(convos.needsPush())
|
assertFalse(convos.needsPush())
|
||||||
|
@ -305,3 +305,32 @@ Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_erase(JN
|
|||||||
if (deserialized == nullptr) return false;
|
if (deserialized == nullptr) return false;
|
||||||
return convos->erase(*deserialized);
|
return convos->erase(*deserialized);
|
||||||
}
|
}
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_sizeOpenGroups(JNIEnv *env,
|
||||||
|
jobject thiz) {
|
||||||
|
auto convos = ptrToConvoInfo(env, thiz);
|
||||||
|
return convos->size_open();
|
||||||
|
}
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_sizeLegacyClosedGroups(
|
||||||
|
JNIEnv *env, jobject thiz) {
|
||||||
|
auto convos = ptrToConvoInfo(env, thiz);
|
||||||
|
return convos->size_open();
|
||||||
|
}
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jobject JNICALL
|
||||||
|
Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_all(JNIEnv *env,
|
||||||
|
jobject thiz) {
|
||||||
|
auto contacts = ptrToConvoInfo(env, thiz);
|
||||||
|
jclass stack = env->FindClass("java/util/Stack");
|
||||||
|
jmethodID init = env->GetMethodID(stack, "<init>", "()V");
|
||||||
|
jobject our_stack = env->NewObject(stack, init);
|
||||||
|
jmethodID push = env->GetMethodID(stack, "push", "(Ljava/lang/Object;)Ljava/lang/Object;");
|
||||||
|
for (const auto& contact : *contacts) {
|
||||||
|
auto contact_obj = serialize_any(env, contact);
|
||||||
|
env->CallObjectMethod(our_stack, push, contact_obj);
|
||||||
|
}
|
||||||
|
return our_stack;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user