Skip to content

changed the instrumentation tests into unit tests #1053

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 3 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions firebase-installations/firebase-installations.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ dependencies {
testImplementation 'junit:junit:4.12'
testImplementation "org.robolectric:robolectric:$robolectricVersion"
testImplementation "com.google.truth:truth:$googleTruthVersion"

testImplementation 'org.mockito:mockito-core:2.25.0'
testImplementation 'org.mockito:mockito-inline:2.25.0'

androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation "com.google.truth:truth:$googleTruthVersion"
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation "androidx.annotation:annotation:1.0.0"
androidTestImplementation 'org.mockito:mockito-core:2.25.0'
androidTestImplementation 'org.mockito:mockito-android:2.25.0'
androidTestImplementation 'org.mockito:mockito-inline:2.25.0'
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,11 @@
package com.google.firebase.installations;

import com.google.firebase.installations.local.PersistedInstallationEntry;
import com.google.firebase.installations.remote.InstallationResponse;
import com.google.firebase.installations.remote.InstallationResponse.ResponseCode;
import com.google.firebase.installations.remote.TokenResult;

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

public static final String TEST_PROJECT_ID = "777777777777";

public static final String TEST_AUTH_TOKEN = "fis.auth.token";
public static final String TEST_AUTH_TOKEN_2 = "fis.auth.token2";
public static final String TEST_AUTH_TOKEN_3 = "fis.auth.token3";
public static final String TEST_AUTH_TOKEN_4 = "fis.auth.token4";

public static final String TEST_API_KEY = "apiKey";

public static final String TEST_REFRESH_TOKEN = "1:test-refresh-token";

Expand All @@ -41,40 +31,6 @@ public final class FisAndroidTestConstants {
public static final long TEST_CREATION_TIMESTAMP_1 = 2000L;
public static final long TEST_CREATION_TIMESTAMP_2 = 2L;

public static final String TEST_INSTANCE_ID_1 = "ccccccccccc";

public static final PersistedInstallationEntry DEFAULT_PERSISTED_INSTALLATION_ENTRY =
PersistedInstallationEntry.builder().build();
public static final InstallationResponse TEST_INSTALLATION_RESPONSE =
InstallationResponse.builder()
.setUri("/projects/" + TEST_PROJECT_ID + "/installations/" + TEST_FID_1)
.setFid(TEST_FID_1)
.setRefreshToken(TEST_REFRESH_TOKEN)
.setAuthToken(
TokenResult.builder()
.setToken(TEST_AUTH_TOKEN)
.setTokenExpirationTimestamp(TEST_TOKEN_EXPIRATION_TIMESTAMP)
.build())
.setResponseCode(ResponseCode.OK)
.build();

public static final InstallationResponse TEST_INSTALLATION_RESPONSE_WITH_IID =
InstallationResponse.builder()
.setUri("/projects/" + TEST_PROJECT_ID + "/installations/" + TEST_INSTANCE_ID_1)
.setFid(TEST_INSTANCE_ID_1)
.setRefreshToken(TEST_REFRESH_TOKEN)
.setAuthToken(
TokenResult.builder()
.setToken(TEST_AUTH_TOKEN)
.setTokenExpirationTimestamp(TEST_TOKEN_EXPIRATION_TIMESTAMP)
.build())
.setResponseCode(ResponseCode.OK)
.build();

public static final TokenResult TEST_TOKEN_RESULT =
TokenResult.builder()
.setToken(TEST_AUTH_TOKEN_2)
.setTokenExpirationTimestamp(TEST_TOKEN_EXPIRATION_TIMESTAMP)
.setResponseCode(TokenResult.ResponseCode.OK)
.build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static PersistedInstallationEntrySubject assertThat(

/**
* Constructor for use by subclasses. If you want to create an instance of this class itself, call
* {@link Subject#check(String, PersistedInstallationEntry ..) check(...)}{@code .that(actual)}.
* {@link Subject#check(String, Object ...) check(...)}{@code .that(actual)}.
*
* @param metadata
* @param actual
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private PersistedInstallationEntry getPrefsWithGeneratedIdMultiProcessSafe() {
}

/** Use file locking to acquire a lock that will also block other processes. */
private FileLock getCrossProcessLock() {
FileLock getCrossProcessLock() {
try {
File file =
new File(firebaseApp.getApplicationContext().getFilesDir(), LOCKFILE_NAME_GENERATE_FID);
Expand All @@ -351,7 +351,7 @@ private FileLock getCrossProcessLock() {
}

/** Release a previously acquired lock. */
private void releaseCrossProcessLock(FileLock fileLock) {
void releaseCrossProcessLock(FileLock fileLock) {
try {
fileLock.release();
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public FakeCalendar(long initialTimeInMillis) {
timeInMillis = initialTimeInMillis;
}

@Override
public long getTimeInMillis() {
return timeInMillis;
}

@Override
public void setTimeInMillis(long timeInMillis) {
this.timeInMillis = timeInMillis;
}
Expand Down
Loading