Merge "Testing all the Calling App UID Track Emits" into udc-dev
This commit is contained in:
@@ -15,14 +15,27 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.server.credentials;
|
package com.android.server.credentials;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.server.credentials.metrics.BrowsedAuthenticationMetric;
|
||||||
|
import com.android.server.credentials.metrics.CandidateAggregateMetric;
|
||||||
|
import com.android.server.credentials.metrics.CandidateBrowsingPhaseMetric;
|
||||||
|
import com.android.server.credentials.metrics.ChosenProviderFinalPhaseMetric;
|
||||||
import com.android.server.credentials.metrics.InitialPhaseMetric;
|
import com.android.server.credentials.metrics.InitialPhaseMetric;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given the secondary-system nature of the MetricUtilities, we expect absolutely nothing to
|
* Given the secondary-system nature of the MetricUtilities, we expect absolutely nothing to
|
||||||
* throw an error. If one presents itself, that is problematic.
|
* throw an error. If one presents itself, that is problematic.
|
||||||
@@ -33,6 +46,11 @@ import org.junit.runner.RunWith;
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
public final class MetricUtilitiesTest {
|
public final class MetricUtilitiesTest {
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws CertificateException {
|
||||||
|
final Context context = ApplicationProvider.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void logApiCalledInitialPhase_nullInitPhaseMetricAndNegativeSequence_success() {
|
public void logApiCalledInitialPhase_nullInitPhaseMetricAndNegativeSequence_success() {
|
||||||
MetricUtilities.logApiCalledInitialPhase(null, -1);
|
MetricUtilities.logApiCalledInitialPhase(null, -1);
|
||||||
@@ -49,4 +67,102 @@ public final class MetricUtilitiesTest {
|
|||||||
MetricUtilities.getHighlyUniqueInteger());
|
MetricUtilities.getHighlyUniqueInteger());
|
||||||
MetricUtilities.logApiCalledInitialPhase(validInitPhaseMetric, 1);
|
MetricUtilities.logApiCalledInitialPhase(validInitPhaseMetric, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledTotalCandidate_nullCandidateNegativeSequence_success() {
|
||||||
|
MetricUtilities.logApiCalledAggregateCandidate(null, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledTotalCandidate_invalidCandidatePhasePositiveSequence_success() {
|
||||||
|
MetricUtilities.logApiCalledAggregateCandidate(new CandidateAggregateMetric(-1), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledTotalCandidate_validPhaseMetric_success() {
|
||||||
|
MetricUtilities.logApiCalledAggregateCandidate(
|
||||||
|
new CandidateAggregateMetric(MetricUtilities.getHighlyUniqueInteger()), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledNoUidFinal_nullNoUidFinalNegativeSequenceAndStatus_success() {
|
||||||
|
MetricUtilities.logApiCalledNoUidFinal(null, null,
|
||||||
|
-1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledNoUidFinal_invalidNoUidFinalPhasePositiveSequenceAndStatus_success() {
|
||||||
|
MetricUtilities.logApiCalledNoUidFinal(new ChosenProviderFinalPhaseMetric(-1, -1),
|
||||||
|
List.of(new CandidateBrowsingPhaseMetric()), 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledNoUidFinal_validNoUidFinalMetric_success() {
|
||||||
|
MetricUtilities.logApiCalledNoUidFinal(
|
||||||
|
new ChosenProviderFinalPhaseMetric(MetricUtilities.getHighlyUniqueInteger(),
|
||||||
|
MetricUtilities.getHighlyUniqueInteger()),
|
||||||
|
List.of(new CandidateBrowsingPhaseMetric()), 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledCandidate_nullMapNullInitFinalNegativeSequence_success() {
|
||||||
|
MetricUtilities.logApiCalledCandidatePhase(null, -1,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledCandidate_invalidProvidersCandidatePositiveSequence_success() {
|
||||||
|
Map<String, ProviderSession> testMap = new HashMap<>();
|
||||||
|
testMap.put("s", null);
|
||||||
|
MetricUtilities.logApiCalledCandidatePhase(testMap, 1,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledCandidateGet_nullMapFinalNegativeSequence_success() {
|
||||||
|
MetricUtilities.logApiCalledCandidateGetMetric(null, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledCandidateGet_invalidProvidersCandidatePositiveSequence_success() {
|
||||||
|
Map<String, ProviderSession> testMap = new HashMap<>();
|
||||||
|
testMap.put("s", null);
|
||||||
|
MetricUtilities.logApiCalledCandidateGetMetric(testMap, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledAuthMetric_nullAuthMetricNegativeSequence_success() {
|
||||||
|
MetricUtilities.logApiCalledAuthenticationMetric(null, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledAuthMetric_invalidAuthMetricPositiveSequence_success() {
|
||||||
|
MetricUtilities.logApiCalledAuthenticationMetric(new BrowsedAuthenticationMetric(-1), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledAuthMetric_nullAuthMetricPositiveSequence_success() {
|
||||||
|
MetricUtilities.logApiCalledAuthenticationMetric(
|
||||||
|
new BrowsedAuthenticationMetric(MetricUtilities.getHighlyUniqueInteger()), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledFinal_nullFinalNegativeSequenceAndStatus_success() {
|
||||||
|
MetricUtilities.logApiCalledFinalPhase(null, null,
|
||||||
|
-1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledFinal_invalidFinalPhasePositiveSequenceAndStatus_success() {
|
||||||
|
MetricUtilities.logApiCalledFinalPhase(new ChosenProviderFinalPhaseMetric(-1, -1),
|
||||||
|
List.of(new CandidateBrowsingPhaseMetric()), 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logApiCalledFinal_validFinalMetric_success() {
|
||||||
|
MetricUtilities.logApiCalledFinalPhase(
|
||||||
|
new ChosenProviderFinalPhaseMetric(MetricUtilities.getHighlyUniqueInteger(),
|
||||||
|
MetricUtilities.getHighlyUniqueInteger()),
|
||||||
|
List.of(new CandidateBrowsingPhaseMetric()), 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user