@@ -147,8 +147,6 @@ class FirebaseDatabaseTest : public FirebaseTest {
147147 // Shut down Firebase Database.
148148 void TerminateDatabase ();
149149
150- int64_t GetRemoteTimeInMilliseconds ();
151-
152150 firebase::database::DatabaseReference CreateWorkingPath (
153151 bool suppress_cleanup = false );
154152
@@ -368,30 +366,6 @@ firebase::database::DatabaseReference FirebaseDatabaseTest::CreateWorkingPath(
368366 return ref;
369367}
370368
371- int64_t FirebaseDatabaseTest::GetRemoteTimeInMilliseconds () {
372- firebase::database::DatabaseReference ref =
373- CreateWorkingPath ().Child (" timestamp" );
374- WaitForCompletionAnyResult (
375- ref.SetValue (firebase::database::ServerTimestamp ()),
376- " GetRemoteTime_SetValue" );
377- firebase::Future<firebase::database::DataSnapshot> future = ref.GetValue ();
378- WaitForCompletionAnyResult (future, " GetRemoteTime_GetValue" );
379- int64_t timestamp = 0 ;
380- if (future.error () == 0 && future.result () &&
381- future.result ()->value ().is_int64 ()) {
382- timestamp = future.result ()->value ().int64_value ();
383- }
384- if (timestamp > 0 ) {
385- LogDebug (" Got server timestamp: %lld" , timestamp);
386- LogDebug (" Local timestamp: %lld" ,
387- app_framework::GetCurrentTimeInMicroseconds () / 1000L );
388- return timestamp;
389- } else {
390- LogWarning (" Couldn't get remote timestamp, using local time" );
391- return app_framework::GetCurrentTimeInMicroseconds () / 1000L ;
392- }
393- }
394-
395369// Test cases below.
396370TEST_F (FirebaseDatabaseTest, TestInitializeAndTerminate) {
397371 // Already tested via SetUp() and TearDown().
@@ -487,7 +461,11 @@ TEST_F(FirebaseDatabaseTest, TestSetAndGetSimpleValues) {
487461 WaitForCompletion (f7, " GetLongDouble" );
488462
489463 // Get the current time to compare to the Timestamp.
490- int64_t current_time_milliseconds = GetRemoteTimeInMilliseconds ();
464+ int64_t current_time_milliseconds =
465+ GetCurrentTimeInSecondsSinceEpoch () * 1000LL ;
466+ LogDebug (" Comparing current time %" PRId64 " with timestamp %" PRId64,
467+ current_time_milliseconds,
468+ f5.result ()->value ().AsInt64 ().int64_value ());
491469
492470 EXPECT_EQ (f1.result ()->value ().AsString (), kSimpleString );
493471 EXPECT_EQ (f2.result ()->value ().AsInt64 (), kSimpleInt );
@@ -698,8 +676,12 @@ TEST_F(FirebaseDatabaseTest, TestUpdateChildren) {
698676 WaitForCompletion (update_future, " UpdateChildren" );
699677 read_future = ref.Child (test_name).GetValue ();
700678 WaitForCompletion (read_future, " GetValue 2" );
701- int64_t current_time_milliseconds = GetRemoteTimeInMilliseconds ();
702-
679+ int64_t current_time_milliseconds =
680+ GetCurrentTimeInSecondsSinceEpoch () * 1000L ;
681+ LogDebug (
682+ " Comparing current time %" PRId64 " with timestamp %" PRId64,
683+ current_time_milliseconds,
684+ read_future.result ()->value ().map ()[" timestamp" ].AsInt64 ().int64_value ());
703685 EXPECT_THAT (
704686 read_future.result ()->value ().map (),
705687 UnorderedElementsAre (
0 commit comments