mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
feat: add all iterators and tests
This commit is contained in:
parent
f934c79078
commit
f7c5953f5d
@ -535,6 +535,7 @@ class InstrumentedTests {
|
|||||||
assertTrue(seen.contains("1-to-1: 055000000000000000000000000000000000000000000000000000000000000000"))
|
assertTrue(seen.contains("1-to-1: 055000000000000000000000000000000000000000000000000000000000000000"))
|
||||||
assertTrue(seen.contains("og: http://example.org:5678/r/sudokuroom"))
|
assertTrue(seen.contains("og: http://example.org:5678/r/sudokuroom"))
|
||||||
assertTrue(seen.contains("cl: 05cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"))
|
assertTrue(seen.contains("cl: 05cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"))
|
||||||
|
assertTrue(seen.size == 4) // for some reason iterative checks aren't working in test cases
|
||||||
}
|
}
|
||||||
|
|
||||||
assertFalse(convos.needsPush())
|
assertFalse(convos.needsPush())
|
||||||
@ -543,7 +544,18 @@ class InstrumentedTests {
|
|||||||
convos.eraseOneToOne("055000000000000000000000000000000000000000000000000000000000000000")
|
convos.eraseOneToOne("055000000000000000000000000000000000000000000000000000000000000000")
|
||||||
assertTrue(convos.needsPush())
|
assertTrue(convos.needsPush())
|
||||||
|
|
||||||
|
assertEquals(1, convos.allOneToOnes().size)
|
||||||
|
assertEquals("051111111111111111111111111111111111111111111111111111111111111111",
|
||||||
|
convos.allOneToOnes().map(Conversation.OneToOne::sessionId).first()
|
||||||
|
)
|
||||||
|
assertEquals(1, convos.allOpenGroups().size)
|
||||||
|
assertEquals("http://example.org:5678",
|
||||||
|
convos.allOpenGroups().map(Conversation.OpenGroup::baseUrl).first()
|
||||||
|
)
|
||||||
|
assertEquals(1, convos.allLegacyClosedGroups().size)
|
||||||
|
assertEquals("05cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||||
|
convos.allLegacyClosedGroups().map(Conversation.LegacyClosedGroup::groupId).first()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -323,14 +323,53 @@ extern "C"
|
|||||||
JNIEXPORT jobject JNICALL
|
JNIEXPORT jobject JNICALL
|
||||||
Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_all(JNIEnv *env,
|
Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_all(JNIEnv *env,
|
||||||
jobject thiz) {
|
jobject thiz) {
|
||||||
auto contacts = ptrToConvoInfo(env, thiz);
|
auto convos = ptrToConvoInfo(env, thiz);
|
||||||
jclass stack = env->FindClass("java/util/Stack");
|
jclass stack = env->FindClass("java/util/Stack");
|
||||||
jmethodID init = env->GetMethodID(stack, "<init>", "()V");
|
jmethodID init = env->GetMethodID(stack, "<init>", "()V");
|
||||||
jobject our_stack = env->NewObject(stack, init);
|
jobject our_stack = env->NewObject(stack, init);
|
||||||
jmethodID push = env->GetMethodID(stack, "push", "(Ljava/lang/Object;)Ljava/lang/Object;");
|
jmethodID push = env->GetMethodID(stack, "push", "(Ljava/lang/Object;)Ljava/lang/Object;");
|
||||||
for (const auto& contact : *contacts) {
|
for (const auto& convo : *convos) {
|
||||||
auto contact_obj = serialize_any(env, contact);
|
auto contact_obj = serialize_any(env, convo);
|
||||||
env->CallObjectMethod(our_stack, push, contact_obj);
|
env->CallObjectMethod(our_stack, push, contact_obj);
|
||||||
}
|
}
|
||||||
return our_stack;
|
return our_stack;
|
||||||
|
}
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jobject JNICALL
|
||||||
|
Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_allOneToOnes(JNIEnv *env,
|
||||||
|
jobject thiz) {
|
||||||
|
auto convos = 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 (auto contact = convos->begin_1to1(); contact != convos->end(); ++contact)
|
||||||
|
env->CallObjectMethod(our_stack, push, serialize_one_to_one(env, *contact));
|
||||||
|
return our_stack;
|
||||||
|
}
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jobject JNICALL
|
||||||
|
Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_allOpenGroups(JNIEnv *env,
|
||||||
|
jobject thiz) {
|
||||||
|
auto convos = 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 (auto contact = convos->begin_open(); contact != convos->end(); ++contact)
|
||||||
|
env->CallObjectMethod(our_stack, push, serialize_open_group(env, *contact));
|
||||||
|
return our_stack;
|
||||||
|
}
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jobject JNICALL
|
||||||
|
Java_network_loki_messenger_libsession_1util_ConversationVolatileConfig_allLegacyClosedGroups(
|
||||||
|
JNIEnv *env, jobject thiz) {
|
||||||
|
auto convos = 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 (auto contact = convos->begin_legacy_closed(); contact != convos->end(); ++contact)
|
||||||
|
env->CallObjectMethod(our_stack, push, serialize_legacy_group(env, *contact));
|
||||||
|
return our_stack;
|
||||||
}
|
}
|
@ -107,6 +107,9 @@ class ConversationVolatileConfig(pointer: Long): ConfigBase(pointer) {
|
|||||||
|
|
||||||
external fun empty(): Boolean
|
external fun empty(): Boolean
|
||||||
|
|
||||||
|
external fun allOneToOnes(): List<Conversation.OneToOne>
|
||||||
|
external fun allOpenGroups(): List<Conversation.OpenGroup>
|
||||||
|
external fun allLegacyClosedGroups(): List<Conversation.LegacyClosedGroup>
|
||||||
external fun all(): List<Conversation>
|
external fun all(): List<Conversation>
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user