@@ -30,7 +30,6 @@ namespace firestore {
30
30
namespace {
31
31
32
32
using jni::ArrayList;
33
- using jni::Env;
34
33
using jni::Global;
35
34
using jni::Local;
36
35
using jni::Object;
@@ -42,9 +41,7 @@ using ::testing::Not;
42
41
using ::testing::StrEq;
43
42
44
43
TEST_F (FirestoreAndroidIntegrationTest, ToDebugStringWithNonNull) {
45
- Env env;
46
-
47
- std::string debug_string = ToDebugString (env.NewStringUtf (" Test Value" ));
44
+ std::string debug_string = ToDebugString (env ().NewStringUtf (" Test Value" ));
48
45
49
46
EXPECT_EQ (debug_string, " Test Value" );
50
47
}
@@ -59,50 +56,45 @@ TEST_F(FirestoreAndroidIntegrationTest, ToDebugStringWithNull) {
59
56
60
57
TEST_F (FirestoreAndroidIntegrationTest,
61
58
ToDebugStringWithPendingExceptionAndNonNullObject) {
62
- Env env;
63
- Local<String> object = env.NewStringUtf (" Test Value" );
64
- ThrowException (env);
65
- ASSERT_FALSE (env.ok ());
59
+ Local<String> object = env ().NewStringUtf (" Test Value" );
60
+ ThrowException ();
61
+ ASSERT_FALSE (env ().ok ());
66
62
67
63
std::string debug_string = ToDebugString (object);
68
64
69
65
EXPECT_EQ (debug_string, " Test Value" );
70
- env.ExceptionClear ();
66
+ env () .ExceptionClear ();
71
67
}
72
68
73
69
TEST_F (FirestoreAndroidIntegrationTest,
74
70
ToDebugStringWithPendingExceptionAndNullObject) {
75
- Env env;
76
71
Object null_reference;
77
- ThrowException (env );
78
- ASSERT_FALSE (env.ok ());
72
+ ThrowException ();
73
+ ASSERT_FALSE (env () .ok ());
79
74
80
75
std::string debug_string = ToDebugString (null_reference);
81
76
82
77
EXPECT_EQ (debug_string, " null" );
83
- env.ExceptionClear ();
78
+ env () .ExceptionClear ();
84
79
}
85
80
86
81
TEST_F (FirestoreAndroidIntegrationTest, JavaEqShouldReturnTrueForEqualObjects) {
87
- Env env;
88
- Local<String> object1 = env.NewStringUtf (" string" );
89
- Local<String> object2 = env.NewStringUtf (" string" );
82
+ Local<String> object1 = env ().NewStringUtf (" string" );
83
+ Local<String> object2 = env ().NewStringUtf (" string" );
90
84
91
85
EXPECT_THAT (object1, JavaEq (object2));
92
86
}
93
87
94
88
TEST_F (FirestoreAndroidIntegrationTest,
95
89
JavaEqShouldReturnFalseForUnequalObjects) {
96
- Env env;
97
- Local<String> object1 = env.NewStringUtf (" string1" );
98
- Local<String> object2 = env.NewStringUtf (" string2" );
90
+ Local<String> object1 = env ().NewStringUtf (" string1" );
91
+ Local<String> object2 = env ().NewStringUtf (" string2" );
99
92
100
93
EXPECT_THAT (object1, Not (JavaEq (object2)));
101
94
}
102
95
103
96
TEST_F (FirestoreAndroidIntegrationTest,
104
97
JavaEqShouldReturnTrueForTwoNullReferences) {
105
- Env env;
106
98
Local<Object> null_reference1;
107
99
Local<Object> null_reference2;
108
100
@@ -111,28 +103,25 @@ TEST_F(FirestoreAndroidIntegrationTest,
111
103
112
104
TEST_F (FirestoreAndroidIntegrationTest,
113
105
JavaEqShouldReturnFalseIfExactlyOneObjectIsNull) {
114
- Env env;
115
106
Local<String> null_reference;
116
- Local<String> non_null_reference = env.NewStringUtf (" string2" );
107
+ Local<String> non_null_reference = env () .NewStringUtf (" string2" );
117
108
118
109
EXPECT_THAT (null_reference, Not (JavaEq (non_null_reference)));
119
110
EXPECT_THAT (non_null_reference, Not (JavaEq (null_reference)));
120
111
}
121
112
122
113
TEST_F (FirestoreAndroidIntegrationTest,
123
114
JavaEqShouldReturnFalseForObjectOfDifferentTypes) {
124
- Env env;
125
- Local<String> string_object = env.NewStringUtf (" string2" );
126
- Local<ArrayList> list_object = ArrayList::Create (env);
115
+ Local<String> string_object = env ().NewStringUtf (" string2" );
116
+ Local<ArrayList> list_object = ArrayList::Create (env ());
127
117
128
118
EXPECT_THAT (string_object, Not (JavaEq (list_object)));
129
119
EXPECT_THAT (list_object, Not (JavaEq (string_object)));
130
120
}
131
121
132
122
TEST_F (FirestoreAndroidIntegrationTest,
133
123
RefersToSameJavaObjectAsShouldReturnTrueForSameObjects) {
134
- Env env;
135
- Local<String> object1 = env.NewStringUtf (" string" );
124
+ Local<String> object1 = env ().NewStringUtf (" string" );
136
125
Global<String> object2 = object1;
137
126
138
127
EXPECT_THAT (object1, RefersToSameJavaObjectAs (object2));
@@ -148,19 +137,17 @@ TEST_F(FirestoreAndroidIntegrationTest,
148
137
149
138
TEST_F (FirestoreAndroidIntegrationTest,
150
139
RefersToSameJavaObjectAsShouldReturnFalseForDistinctObjects) {
151
- Env env;
152
- Local<String> object1 = env.NewStringUtf (" test string" );
153
- Local<String> object2 = env.NewStringUtf (" test string" );
154
- ASSERT_FALSE (env.IsSameObject (object1, object2));
140
+ Local<String> object1 = env ().NewStringUtf (" test string" );
141
+ Local<String> object2 = env ().NewStringUtf (" test string" );
142
+ ASSERT_FALSE (env ().IsSameObject (object1, object2));
155
143
156
144
EXPECT_THAT (object1, Not (RefersToSameJavaObjectAs (object2)));
157
145
}
158
146
159
147
TEST_F (FirestoreAndroidIntegrationTest,
160
148
RefersToSameJavaObjectAsShouldReturnFalseIfExactlyOneObjectIsNull) {
161
- Env env;
162
149
Local<String> null_reference;
163
- Local<String> non_null_reference = env.NewStringUtf (" string2" );
150
+ Local<String> non_null_reference = env () .NewStringUtf (" string2" );
164
151
165
152
EXPECT_THAT (null_reference,
166
153
Not (RefersToSameJavaObjectAs (non_null_reference)));
@@ -170,42 +157,38 @@ TEST_F(FirestoreAndroidIntegrationTest,
170
157
171
158
TEST_F (FirestoreAndroidIntegrationTest,
172
159
ThrowExceptionWithNoMessageShouldSetPendingExceptionWithAMessage) {
173
- Env env;
174
- Local<Throwable> throw_exception_return_value = ThrowException (env);
175
- Local<Throwable> actually_thrown_exception = env.ClearExceptionOccurred ();
160
+ Local<Throwable> throw_exception_return_value = ThrowException ();
161
+ Local<Throwable> actually_thrown_exception = env ().ClearExceptionOccurred ();
176
162
ASSERT_TRUE (actually_thrown_exception);
177
163
EXPECT_THAT (actually_thrown_exception,
178
164
RefersToSameJavaObjectAs (throw_exception_return_value));
179
- EXPECT_THAT (actually_thrown_exception.GetMessage (env), Not (IsEmpty ()));
165
+ EXPECT_THAT (actually_thrown_exception.GetMessage (env () ), Not (IsEmpty ()));
180
166
}
181
167
182
168
TEST_F (FirestoreAndroidIntegrationTest,
183
169
ThrowExceptionWithAMessageShouldSetPendingExceptionWithTheGivenMessage) {
184
- Env env;
185
170
Local<Throwable> throw_exception_return_value =
186
- ThrowException (env, " my test message" );
187
- Local<Throwable> actually_thrown_exception = env.ClearExceptionOccurred ();
171
+ ThrowException (" my test message" );
172
+ Local<Throwable> actually_thrown_exception = env () .ClearExceptionOccurred ();
188
173
ASSERT_TRUE (actually_thrown_exception);
189
174
EXPECT_THAT (actually_thrown_exception,
190
175
RefersToSameJavaObjectAs (throw_exception_return_value));
191
- EXPECT_THAT (actually_thrown_exception.GetMessage (env),
176
+ EXPECT_THAT (actually_thrown_exception.GetMessage (env () ),
192
177
StrEq (" my test message" ));
193
178
}
194
179
195
180
TEST_F (FirestoreAndroidIntegrationTest,
196
181
CreateExceptionWithNoMessageShouldReturnAnExceptionWithAMessage) {
197
- Env env;
198
- Local<Throwable> exception = CreateException (env);
182
+ Local<Throwable> exception = CreateException ();
199
183
ASSERT_TRUE (exception );
200
- EXPECT_THAT (exception .GetMessage (env), Not (IsEmpty ()));
184
+ EXPECT_THAT (exception .GetMessage (env () ), Not (IsEmpty ()));
201
185
}
202
186
203
187
TEST_F (FirestoreAndroidIntegrationTest,
204
188
CreateExceptionWithAMessageShouldReturnAnExceptionWithTheGivenMessage) {
205
- Env env;
206
- Local<Throwable> exception = CreateException (env, " my test message" );
189
+ Local<Throwable> exception = CreateException (" my test message" );
207
190
ASSERT_TRUE (exception );
208
- EXPECT_THAT (exception .GetMessage (env), StrEq (" my test message" ));
191
+ EXPECT_THAT (exception .GetMessage (env () ), StrEq (" my test message" ));
209
192
}
210
193
211
194
} // namespace
0 commit comments