summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Geoffrey Pitsch <gpitsch@google.com> 2016-09-14 09:34:17 -0400
committer Geoffrey Pitsch <gpitsch@google.com> 2016-09-14 10:16:25 -0400
commitd80035a750ed1222c3599f72d0a771a29684de1c (patch)
treec66a41e7598065541e1c1725e682fea00113c78b
parent182f9abdf427996249cb953ffd6133fde3bbfba2 (diff)
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
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java25
1 files changed, 16 insertions, 9 deletions
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 c51cef0a81e8..6c9cfe04ed80 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.statusbar.policy.NetworkControllerImpl.SubscriptionD
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 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
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 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
}
- @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);