summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2022-03-07 09:45:52 +0100
committerAlbin <albin@mullvad.net>2022-04-20 17:52:30 +0200
commitf45276ac2dca91ad6a36d3a4ef948b2cbe3f9bd1 (patch)
tree88beb83b117c88dd3203dcfd96d8e5c7e6fd07c0 /android
parentbb549db6c6e203e1d76abb7f858e04490822ad65 (diff)
downloadmullvadvpn-f45276ac2dca91ad6a36d3a4ef948b2cbe3f9bd1.tar.xz
mullvadvpn-f45276ac2dca91ad6a36d3a4ef948b2cbe3f9bd1.zip
Add webview to enable e2e test verification
The webview is added to the debug build type of the main app, but it's current purpose is only to enable verification as part of e2e tests. One example is to open the webview on the device while connected and verify the results of the Mullvad Connection Check.
Diffstat (limited to 'android')
-rw-r--r--android/app/build.gradle.kts1
-rw-r--r--android/app/src/debug/AndroidManifest.xml22
-rw-r--r--android/app/src/debug/kotlin/net.mullvad.mullvadvpn/TestActivity.kt23
-rw-r--r--android/app/src/debug/res/layout/activity_test.xml13
4 files changed, 59 insertions, 0 deletions
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 173c9c86b7..1a17abf92c 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -68,6 +68,7 @@ android {
assets.srcDirs(extraAssetsDirectory)
jniLibs.srcDirs(extraJniDirectory)
java.srcDirs("src/main/kotlin/")
+ java.srcDirs("src/debug/kotlin/")
}
getByName("test") {
diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml
new file mode 100644
index 0000000000..0eee767e98
--- /dev/null
+++ b/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,22 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ package="net.mullvad.mullvadvpn">
+ <application android:label="@string/app_name"
+ android:icon="@mipmap/ic_launcher"
+ android:roundIcon="@mipmap/ic_launcher"
+ android:theme="@style/AppTheme"
+ android:extractNativeLibs="true"
+ android:allowBackup="false"
+ android:banner="@drawable/banner"
+ android:name=".MullvadApplication"
+ tools:ignore="GoogleAppIndexingWarning">
+ <activity android:name="net.mullvad.mullvadvpn.TestActivity"
+ android:label="@string/app_name"
+ android:launchMode="singleTask"
+ android:configChanges="orientation|screenSize|screenLayout"
+ android:screenOrientation="locked"
+ android:windowSoftInputMode="adjustPan"
+ android:exported="true">
+ </activity>
+ </application>
+</manifest>
diff --git a/android/app/src/debug/kotlin/net.mullvad.mullvadvpn/TestActivity.kt b/android/app/src/debug/kotlin/net.mullvad.mullvadvpn/TestActivity.kt
new file mode 100644
index 0000000000..df36947eab
--- /dev/null
+++ b/android/app/src/debug/kotlin/net.mullvad.mullvadvpn/TestActivity.kt
@@ -0,0 +1,23 @@
+package net.mullvad.mullvadvpn
+
+import android.annotation.SuppressLint
+import android.app.Activity
+import android.os.Bundle
+import android.webkit.WebView
+import android.widget.Toast
+
+class TestActivity : Activity() {
+ @SuppressLint("SetJavaScriptEnabled")
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_test)
+ val testWebView: WebView = findViewById(R.id.webview)
+ testWebView.settings.javaScriptEnabled = true
+ val url = intent.getStringExtra("url")
+ if (url != null) {
+ testWebView.loadUrl(url)
+ } else {
+ Toast.makeText(applicationContext, "No url specified!", Toast.LENGTH_SHORT).show()
+ }
+ }
+}
diff --git a/android/app/src/debug/res/layout/activity_test.xml b/android/app/src/debug/res/layout/activity_test.xml
new file mode 100644
index 0000000000..18f7eafef6
--- /dev/null
+++ b/android/app/src/debug/res/layout/activity_test.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".TestActivity">
+ <WebView
+ android:id="@+id/webview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+</androidx.constraintlayout.widget.ConstraintLayout>