Skip to content

Commit

Permalink
Remove unnecessary recording of espresso usage in test storage proper…
Browse files Browse the repository at this point in the history
…ties.

PiperOrigin-RevId: 682399851
  • Loading branch information
brettchabot authored and copybara-androidxtest committed Oct 4, 2024
1 parent 21a81c6 commit d81f250
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions espresso/core/java/androidx/test/espresso/GraphHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@

import static androidx.test.internal.util.Checks.checkNotNull;

import android.util.Log;
import androidx.test.platform.io.PlatformTestStorage;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

/** Holds Espresso's object graph. */
Expand All @@ -43,10 +38,6 @@ static BaseLayerComponent baseLayer() {
if (null == instanceRef) {
instanceRef = new GraphHolder(DaggerBaseLayerComponent.create());
if (instance.compareAndSet(null, instanceRef)) {
// Also adds the usage data as test output properties. By default it's no-op.
Map<String, Serializable> usageProperties = new HashMap<>();
usageProperties.put("Espresso", "1");
addUsageToOutputProperties(usageProperties, instanceRef.component.testStorage());
return instanceRef.component;
} else {
return instance.get().component;
Expand All @@ -55,19 +46,4 @@ static BaseLayerComponent baseLayer() {
return instanceRef.component;
}
}

private static void addUsageToOutputProperties(
Map<String, Serializable> usageProperties, PlatformTestStorage testStorage) {
try {
testStorage.addOutputProperties(usageProperties);
} catch (RuntimeException e) {
// The properties.dat file can be created only once on an automotive emulator with API 30,
// which causes the `addOutputProperties` call to fail when running multiple test cases. Catch
// the exception and log until the issue is fixed in the emulator.
Log.w(
TAG,
"Failed to add the output properties. This could happen when running on Robolectric or an"
+ " automotive emulator with API 30. Ignore for now.");
}
}
}

0 comments on commit d81f250

Please sign in to comment.