From d0d5c64babf5d5dcf262ac2085fe7b00083127eb Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Mon, 6 Sep 2021 17:52:21 +0900 Subject: [PATCH] Add debug logs to CaptivePortalTests The point is to help with debugging flakes of this test by clarifying the timing of these calls with respect to when NetworkMonitor reads the settings and the values it obtains. Test: CaptivePortalTest Change-Id: I29ac1d8cff1f96c91be2459e9a8f34f8ba1f38e3 --- tests/cts/net/src/android/net/cts/CaptivePortalTest.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/cts/net/src/android/net/cts/CaptivePortalTest.kt b/tests/cts/net/src/android/net/cts/CaptivePortalTest.kt index 9f079c42ed..9f98e3fab5 100644 --- a/tests/cts/net/src/android/net/cts/CaptivePortalTest.kt +++ b/tests/cts/net/src/android/net/cts/CaptivePortalTest.kt @@ -46,6 +46,7 @@ import android.platform.test.annotations.AppModeFull import android.provider.DeviceConfig import android.provider.DeviceConfig.NAMESPACE_CONNECTIVITY import android.text.TextUtils +import android.util.Log import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import androidx.test.runner.AndroidJUnit4 import com.android.testutils.RecorderCallback @@ -79,6 +80,8 @@ private const val LOCALHOST_HOSTNAME = "localhost" private const val WIFI_CONNECT_TIMEOUT_MS = 120_000L private const val TEST_TIMEOUT_MS = 10_000L +private const val TAG = "CaptivePortalTest" + private fun CompletableFuture.assertGet(timeoutMs: Long, message: String): T { try { return get(timeoutMs, TimeUnit.MILLISECONDS) @@ -155,6 +158,7 @@ class CaptivePortalTest { server.addResponse(Request(TEST_HTTP_URL_PATH), Status.REDIRECT, headers) setHttpsUrlDeviceConfig(makeUrl(TEST_HTTPS_URL_PATH)) setHttpUrlDeviceConfig(makeUrl(TEST_HTTP_URL_PATH)) + Log.d(TAG, "Set portal URLs to $TEST_HTTPS_URL_PATH and $TEST_HTTP_URL_PATH") // URL expiration needs to be in the next 10 minutes assertTrue(WIFI_CONNECT_TIMEOUT_MS < TimeUnit.MINUTES.toMillis(10)) setUrlExpirationDeviceConfig(System.currentTimeMillis() + WIFI_CONNECT_TIMEOUT_MS)