3
3
#include " android/firestore_integration_test_android.h"
4
4
#include " firebase_test_framework.h"
5
5
#include " firestore/src/include/firebase/firestore/snapshot_metadata.h"
6
+ #include " firestore/src/jni/declaration.h"
6
7
#include " firestore/src/jni/env.h"
7
8
#include " firestore_integration_test.h"
8
9
#include " gmock/gmock.h"
@@ -14,30 +15,33 @@ namespace firestore {
14
15
using SnapshotMetadataAndroidTest = FirestoreAndroidIntegrationTest;
15
16
16
17
using jni::Class;
18
+ using jni::Constructor;
17
19
using jni::Env;
18
20
using jni::Local;
19
21
20
22
TEST_F (SnapshotMetadataAndroidTest, Converts) {
21
- SKIP_TEST_ON_ANDROID; // TODO(b/183294303): Fix this test on Android.
22
-
23
23
Env env;
24
-
25
- Local<Class> clazz =
26
- env.FindClass (" com/google/firebase/firestore/SnapshotMetadata" );
27
- jmethodID ctor = env.GetMethodId (clazz, " <init>" , " (ZZ)V" );
28
-
29
- auto java_metadata = env.New <SnapshotMetadataInternal>(
30
- clazz, ctor, /* has_pending_writes=*/ true , /* is_from_cache=*/ false );
31
- SnapshotMetadata result = java_metadata.ToPublic (env);
32
- EXPECT_TRUE (result.has_pending_writes ());
33
- EXPECT_FALSE (result.is_from_cache ());
34
-
35
- java_metadata = env.New <SnapshotMetadataInternal>(
36
- clazz, ctor, /* has_pending_writes=*/ false ,
37
- /* is_from_cache=*/ true );
38
- result = java_metadata.ToPublic (env);
39
- EXPECT_FALSE (result.has_pending_writes ());
40
- EXPECT_TRUE (result.is_from_cache ());
24
+ Constructor<SnapshotMetadataInternal> ctor (" (ZZ)V" );
25
+ loader ().LoadClass (" com/google/firebase/firestore/SnapshotMetadata" , ctor);
26
+ ASSERT_TRUE (loader ().ok ());
27
+
28
+ {
29
+ auto java_metadata =
30
+ env.New (ctor, /* has_pending_writes=*/ true , /* is_from_cache=*/ false );
31
+ SnapshotMetadata result = java_metadata.ToPublic (env);
32
+ EXPECT_TRUE (env.ok ());
33
+ EXPECT_TRUE (result.has_pending_writes ());
34
+ EXPECT_FALSE (result.is_from_cache ());
35
+ }
36
+
37
+ {
38
+ auto java_metadata =
39
+ env.New (ctor, /* has_pending_writes=*/ false , /* is_from_cache=*/ true );
40
+ SnapshotMetadata result = java_metadata.ToPublic (env);
41
+ EXPECT_TRUE (env.ok ());
42
+ EXPECT_FALSE (result.has_pending_writes ());
43
+ EXPECT_TRUE (result.is_from_cache ());
44
+ }
41
45
}
42
46
43
47
} // namespace firestore
0 commit comments