From d4e5af630f856088041a5f8bdc50679122ce4488 Mon Sep 17 00:00:00 2001 From: James Aley Date: Wed, 28 Dec 2022 11:27:48 +0000 Subject: [PATCH] Barebones test and proxy interface for issue #865 --- .../tracking/test/android/common/AblyProxy.kt | 39 +++++++++++++++++++ .../tests/NetworkConnectivityTests.kt | 14 +++++++ 2 files changed, 53 insertions(+) create mode 100644 android-test-common/src/main/java/com/ably/tracking/test/android/common/AblyProxy.kt create mode 100644 integration-testing-app/src/androidTest/java/com/ably/tracking/tests/NetworkConnectivityTests.kt diff --git a/android-test-common/src/main/java/com/ably/tracking/test/android/common/AblyProxy.kt b/android-test-common/src/main/java/com/ably/tracking/test/android/common/AblyProxy.kt new file mode 100644 index 000000000..43f4416ed --- /dev/null +++ b/android-test-common/src/main/java/com/ably/tracking/test/android/common/AblyProxy.kt @@ -0,0 +1,39 @@ +package com.ably.tracking.test.android.common + +import io.ably.lib.realtime.AblyRealtime +import io.ably.lib.types.ClientOptions + +sealed class ProtocolAction { + /** + * `presence.enter` realtime protocol action + */ + object PresenceEnter : ProtocolAction() + // ... +} + +sealed class ProxyResponse { + /** + * Terminate the connection when configured action has been detected + */ + object Disconnect : ProxyResponse() + // ... +} + +interface RealtimeProxy { + /** + * Return an AblyRealtime client that has been congfigured to pass traffic + * through the proxy + */ + fun proxy(opts: ClientOptions) : AblyRealtime + + /** + * Configure proxy to give specified response when given protocol action + * occurs across proxied traffic. All other actions pass through. + */ + fun onAction(action: ProtocolAction, response: ProxyResponse) + + /** + * Reset any configured responses/actions so that all traffic is back to pass-through. + */ + fun reset() +} diff --git a/integration-testing-app/src/androidTest/java/com/ably/tracking/tests/NetworkConnectivityTests.kt b/integration-testing-app/src/androidTest/java/com/ably/tracking/tests/NetworkConnectivityTests.kt new file mode 100644 index 000000000..39ebde02a --- /dev/null +++ b/integration-testing-app/src/androidTest/java/com/ably/tracking/tests/NetworkConnectivityTests.kt @@ -0,0 +1,14 @@ +package com.ably.tracking.tests + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.Assert +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class NetworkConnectivityTests { + @Test + fun emptyTest() { + Assert.assertTrue(true) + } +}