Merge "Only do prints for network tests that fail"

This commit is contained in:
TreeHugger Robot
2016-09-14 16:24:49 +00:00
committed by Android (Google) Code Review

View File

@@ -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);