Skip to content

Simplifying FirebaseInstallations class by adding listeners. #847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions firebase-installations/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ package com.google.firebase.installations.local {
ctor public PersistedFid(@NonNull FirebaseApp);
method @NonNull public boolean clear();
method @NonNull public boolean insertOrUpdatePersistedFidEntry(@NonNull com.google.firebase.installations.local.PersistedFidEntry);
method @Nullable public com.google.firebase.installations.local.PersistedFidEntry readPersistedFidEntryValue();
method @NonNull public com.google.firebase.installations.local.PersistedFidEntry readPersistedFidEntryValue();
}

public enum PersistedFid.RegistrationStatus {
enum_constant public static final com.google.firebase.installations.local.PersistedFid.RegistrationStatus PENDING;
enum_constant public static final com.google.firebase.installations.local.PersistedFid.RegistrationStatus NOT_GENERATED;
enum_constant public static final com.google.firebase.installations.local.PersistedFid.RegistrationStatus REGISTERED;
enum_constant public static final com.google.firebase.installations.local.PersistedFid.RegistrationStatus REGISTER_ERROR;
enum_constant public static final com.google.firebase.installations.local.PersistedFid.RegistrationStatus UNREGISTERED;
Expand All @@ -44,10 +44,14 @@ package com.google.firebase.installations.local {
method @NonNull public static com.google.firebase.installations.local.PersistedFidEntry.Builder builder();
method @Nullable public abstract String getAuthToken();
method public abstract long getExpiresInSecs();
method @NonNull public abstract String getFirebaseInstallationId();
method @Nullable public abstract String getFirebaseInstallationId();
method @Nullable public abstract String getRefreshToken();
method @NonNull public abstract com.google.firebase.installations.local.PersistedFid.RegistrationStatus getRegistrationStatus();
method public abstract long getTokenCreationEpochInSecs();
method public boolean isErrored();
method public boolean isNotGenerated();
method public boolean isRegistered();
method public boolean isUnregistered();
method @NonNull public abstract com.google.firebase.installations.local.PersistedFidEntry.Builder toBuilder();
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

package com.google.firebase.installations;

import com.google.firebase.installations.local.PersistedFidEntry;
import com.google.firebase.installations.remote.InstallationResponse;

public final class FisAndroidTestConstants {
public static final String TEST_FID_1 = "cccccccccccccccccccccc";

Expand All @@ -35,5 +38,24 @@ public final class FisAndroidTestConstants {
public static final long TEST_TOKEN_EXPIRATION_TIMESTAMP_2 = 2000L;

public static final long TEST_CREATION_TIMESTAMP_1 = 2000L;
public static final long TEST_CREATION_TIMESTAMP_2 = 2000L;
public static final long TEST_CREATION_TIMESTAMP_2 = 2L;

public static final PersistedFidEntry DEFAULT_PERSISTED_FID_ENTRY =
PersistedFidEntry.builder().build();
public static final InstallationResponse TEST_INSTALLATION_RESPONSE =
InstallationResponse.builder()
.setName("/projects/" + TEST_PROJECT_ID + "/installations/" + TEST_FID_1)
.setRefreshToken(TEST_REFRESH_TOKEN)
.setAuthToken(
InstallationTokenResult.builder()
.setToken(TEST_AUTH_TOKEN)
.setTokenExpirationInSecs(TEST_TOKEN_EXPIRATION_TIMESTAMP)
.build())
.build();

public static final InstallationTokenResult TEST_INSTALLATION_TOKEN_RESULT =
InstallationTokenResult.builder()
.setToken(TEST_AUTH_TOKEN_2)
.setTokenExpirationInSecs(TEST_TOKEN_EXPIRATION_TIMESTAMP)
.build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.firebase.installations.local;

import static com.google.firebase.installations.FisAndroidTestConstants.DEFAULT_PERSISTED_FID_ENTRY;
import static com.google.firebase.installations.FisAndroidTestConstants.TEST_APP_ID_1;
import static com.google.firebase.installations.FisAndroidTestConstants.TEST_APP_ID_2;
import static com.google.firebase.installations.FisAndroidTestConstants.TEST_AUTH_TOKEN;
Expand All @@ -23,7 +24,6 @@
import static com.google.firebase.installations.FisAndroidTestConstants.TEST_REFRESH_TOKEN;
import static com.google.firebase.installations.FisAndroidTestConstants.TEST_TOKEN_EXPIRATION_TIMESTAMP;
import static com.google.firebase.installations.local.PersistedFidEntrySubject.assertThat;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import androidx.test.core.app.ApplicationProvider;
Expand Down Expand Up @@ -69,8 +69,8 @@ public void cleanUp() throws Exception {

@Test
public void testReadPersistedFidEntry_Null() {
assertNull(persistedFid0.readPersistedFidEntryValue());
assertNull(persistedFid1.readPersistedFidEntryValue());
assertThat(persistedFid0.readPersistedFidEntryValue()).isEqualTo(DEFAULT_PERSISTED_FID_ENTRY);
assertThat(persistedFid1.readPersistedFidEntryValue()).isEqualTo(DEFAULT_PERSISTED_FID_ENTRY);
}

@Test
Expand Down
Loading