Skip to content

Commit 2149236

Browse files
committed
Run tests with plain HTTP when no user-trusting browser exists
1 parent 4ee46ec commit 2149236

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

app/src/main/java/tech/httptoolkit/android/MainActivity.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,24 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
407407
private fun testInterception() {
408408
app.trackEvent("Button", "test-interception")
409409

410-
val browserIntent = Intent(Intent.ACTION_VIEW,
411-
Uri.parse("https://amiusing.httptoolkit.tech")
412-
)
413-
414410
// If there's a supported browser available, make sure we use it. This prioritises
415411
// the default browser, and only returns null if no known supported browser is installed.
416412
val testBrowserPackage = getTestBrowserPackage(this)
417-
if (testBrowserPackage != null) browserIntent.setPackage(testBrowserPackage)
418413

414+
val browserIntent = Intent(
415+
Intent.ACTION_VIEW,
416+
Uri.parse(
417+
(
418+
// We test with just plain HTTP if there's no user-cert-trusting browser
419+
// installed, to reduce confusing failures.
420+
if (testBrowserPackage == null) "http" else "https"
421+
) + "://amiusing.httptoolkit.tech"
422+
)
423+
).apply {
424+
if (testBrowserPackage != null) {
425+
setPackage(testBrowserPackage)
426+
}
427+
}
419428
startActivity(browserIntent)
420429
}
421430

0 commit comments

Comments
 (0)