Only do prints for network tests that fail
There's a lot of variance in the network tests, but this appears
to save ~1 second when running them all.
Change-Id: I4629f8d123313a5acf3ff076f0a5960719e35f13
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
index c51cef0..6c9cfe0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
@@ -37,6 +37,9 @@
import com.android.systemui.SysuiTestCase;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
@@ -76,6 +79,19 @@
private NetworkCapabilities mNetCapabilities;
+ @Rule
+ public TestWatcher failWatcher = new TestWatcher() {
+ @Override
+ protected void failed(Throwable e, Description description) {
+ // Print out mNetworkController state if the test fails.
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ mNetworkController.dump(null, pw, null);
+ pw.flush();
+ Log.d(TAG, sw.toString());
+ }
+ };
+
@Before
public void setUp() throws Exception {
mMockWm = mock(WifiManager.class);
@@ -147,15 +163,6 @@
}
- @After
- public void tearDown() throws Exception {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- mNetworkController.dump(null, pw, null);
- pw.flush();
- Log.d(TAG, sw.toString());
- }
-
// 2 Bars 3G GSM.
public void setupDefaultSignal() {
setIsGsm(true);