From c6e7fd8b76398114980a43c5d90197939c1ddfeb Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Tue, 25 Jul 2017 13:30:48 -0700 Subject: Dump latest unfiltered scan result Bug: 63810310 Test: compile, unit tests, manual test Change-Id: I090aaacb00c3a774edd5c353037f2265f3bf138f --- .../server/wifi/scanner/WificondScannerTest.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java index 3a5f6b973..ed7c58298 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java @@ -37,8 +37,12 @@ import org.junit.Before; import org.junit.Test; import org.mockito.InOrder; +import java.io.FileDescriptor; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.ArrayList; import java.util.Set; +import java.util.regex.Pattern; /** * Unit tests for {@link com.android.server.wifi.scanner.WificondScannerImpl}. @@ -553,6 +557,28 @@ public class WificondScannerTest extends BaseWifiScannerImplTest { verifyNoMoreInteractions(eventHandler); } + /** + * Test that dump() of WificondScannerImpl dumps native scan results. + */ + @Test + public void dumpContainsNativeScanResults() { + assertDumpContainsRequestLog("Latest native scan results:"); + } + + private void assertDumpContainsRequestLog(String log) { + String objectDump = dumpObject(); + Pattern logLineRegex = Pattern.compile(".*" + log + ".*"); + assertTrue("dump did not contain log = " + log + "\n " + objectDump + "\n", + logLineRegex.matcher(objectDump).find()); + } + + private String dumpObject() { + StringWriter stringWriter = new StringWriter(); + mScanner.dump(new FileDescriptor(), new PrintWriter(stringWriter), + new String[0]); + return stringWriter.toString(); + } + /** * Run a test with the given settings where all native scans succeed * This will execute expectedPeriods.length scan periods by first -- cgit v1.2.3