@@ -170,21 +170,32 @@ static const firebase::remote_config::ConfigKeyValueVariant kServerValue[] = {
170
170
{" TestDefaultOnly" , firebase::Variant::FromMutableString (
171
171
" Default value that won't be overridden" )}};
172
172
173
- static Future<void > SetDefaultsV2 (RemoteConfig* rc) {
173
+ static Future<void > SetDefaults (RemoteConfig* rc) {
174
174
size_t default_count = FIREBASE_ARRAYSIZE (defaults);
175
175
return rc->SetDefaults (defaults, default_count);
176
176
}
177
177
178
+ static Future<void > SetDefaultConfigSettings (RemoteConfig* rc) {
179
+ firebase::remote_config::ConfigSettings defaultConfigSettings;
180
+ return rc->SetConfigSettings (defaultConfigSettings);
181
+ }
182
+
183
+ static Future<void > SetZeroIntervalConfigSettings (RemoteConfig* rc) {
184
+ firebase::remote_config::ConfigSettings zeroIntervalConfigSettings;
185
+ zeroIntervalConfigSettings.minimum_fetch_interval_in_milliseconds = 0 ;
186
+ return rc->SetConfigSettings (zeroIntervalConfigSettings);
187
+ }
188
+
178
189
// Test cases below.
179
190
180
191
TEST_F (FirebaseRemoteConfigTest, TestInitializeAndTerminate) {
181
192
// Already tested via SetUp() and TearDown().
182
193
}
183
194
184
- TEST_F (FirebaseRemoteConfigTest, TestSetDefaultsV2 ) {
195
+ TEST_F (FirebaseRemoteConfigTest, TestSetDefault ) {
185
196
ASSERT_NE (rc_, nullptr );
186
197
187
- EXPECT_TRUE (WaitForCompletion (SetDefaultsV2 (rc_), " SetDefaultsV2 " ));
198
+ EXPECT_TRUE (WaitForCompletion (SetDefaults (rc_), " SetDefaults " ));
188
199
189
200
bool validated_defaults = true ;
190
201
firebase::remote_config::ValueInfo value_info;
@@ -243,10 +254,10 @@ TEST_F(FirebaseRemoteConfigTest, TestSetDefaultsV2) {
243
254
}
244
255
}
245
256
246
- TEST_F (FirebaseRemoteConfigTest, TestGetKeysV2 ) {
257
+ TEST_F (FirebaseRemoteConfigTest, TestGetKeys ) {
247
258
ASSERT_NE (rc_, nullptr );
248
259
249
- EXPECT_TRUE (WaitForCompletion (SetDefaultsV2 (rc_), " SetDefaultsV2 " ));
260
+ EXPECT_TRUE (WaitForCompletion (SetDefaults (rc_), " SetDefaults " ));
250
261
251
262
std::vector<std::string> keys = rc_->GetKeys ();
252
263
EXPECT_THAT (
@@ -265,7 +276,7 @@ TEST_F(FirebaseRemoteConfigTest, TestGetKeysV2) {
265
276
TEST_F (FirebaseRemoteConfigTest, TestGetAll) {
266
277
ASSERT_NE (rc_, nullptr );
267
278
268
- EXPECT_TRUE (WaitForCompletion (SetDefaultsV2 (rc_), " SetDefaultsV2 " ));
279
+ EXPECT_TRUE (WaitForCompletion (SetDefaults (rc_), " SetDefaults " ));
269
280
EXPECT_TRUE (WaitForCompletion (
270
281
RunWithRetry ([](RemoteConfig* rc) { return rc->Fetch (); }, rc_),
271
282
" Fetch" ));
@@ -288,10 +299,10 @@ TEST_F(FirebaseRemoteConfigTest, TestGetAll) {
288
299
TestBoolean true
289
300
TestString This is a string
290
301
*/
291
- TEST_F (FirebaseRemoteConfigTest, TestFetchV2 ) {
302
+ TEST_F (FirebaseRemoteConfigTest, TestFetch ) {
292
303
ASSERT_NE (rc_, nullptr );
293
304
294
- EXPECT_TRUE (WaitForCompletion (SetDefaultsV2 (rc_), " SetDefaultsV2 " ));
305
+ EXPECT_TRUE (WaitForCompletion (SetDefaults (rc_), " SetDefaults " ));
295
306
EXPECT_TRUE (WaitForCompletion (
296
307
RunWithRetry ([](RemoteConfig* rc) { return rc->Fetch (); }, rc_),
297
308
" Fetch" ));
@@ -334,4 +345,31 @@ TEST_F(FirebaseRemoteConfigTest, TestFetchV2) {
334
345
sizeof (kExpectedBlobServerValue )));
335
346
}
336
347
348
+ TEST_F (FirebaseRemoteConfigTest, TestFetchInterval) {
349
+ ASSERT_NE (rc_, nullptr );
350
+ EXPECT_TRUE (WaitForCompletion (
351
+ RunWithRetry ([](RemoteConfig* rc) { return rc->Fetch (); }, rc_),
352
+ " Fetch" ));
353
+ EXPECT_TRUE (WaitForCompletion (rc_->Activate (), " Activate" ));
354
+ uint64_t current_fetch_time = rc_->GetInfo ().fetch_time ;
355
+ // Making sure the config settings's fetch interval is 12 hours
356
+ EXPECT_TRUE (WaitForCompletion (SetDefaultConfigSettings (rc_),
357
+ " SetDefaultConfigSettings" ));
358
+ // Second fetch, should respect fetch interval and don't change data.
359
+ EXPECT_TRUE (WaitForCompletion (
360
+ RunWithRetry ([](RemoteConfig* rc) { return rc->Fetch (); }, rc_),
361
+ " Fetch" ));
362
+ EXPECT_EQ (current_fetch_time, rc_->GetInfo ().fetch_time );
363
+ // Update fetch interval to 0
364
+ EXPECT_TRUE (WaitForCompletion (SetZeroIntervalConfigSettings (rc_),
365
+ " SetZeroIntervalConfigSettings" ));
366
+ LogDebug (" Current Fetch Interval: %lld" ,
367
+ rc_->GetConfigSettings ().minimum_fetch_interval_in_milliseconds );
368
+ // Third fetch, this should operate the real fetch and update the fetch time.
369
+ EXPECT_TRUE (WaitForCompletion (
370
+ RunWithRetry ([](RemoteConfig* rc) { return rc->Fetch (); }, rc_),
371
+ " Fetch" ));
372
+ EXPECT_NE (current_fetch_time, rc_->GetInfo ().fetch_time );
373
+ }
374
+
337
375
} // namespace firebase_testapp_automated
0 commit comments