mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-18 03:48:08 +00:00
fix dns and close assistant view on app first launch
This commit is contained in:
parent
1efd03e367
commit
a5c0aebbe7
3 changed files with 21 additions and 29 deletions
|
|
@ -5,6 +5,7 @@ import androidx.test.espresso.action.ViewActions
|
|||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
|
|
@ -23,6 +24,16 @@ class OutgoingCallUITests {
|
|||
@get:Rule
|
||||
val screenshotsRule = ScreenshotsRule(true)
|
||||
|
||||
@get:Rule
|
||||
var mGrantPermissionRule = GrantPermissionRule.grant(
|
||||
"android.permission.READ_PHONE_NUMBERS",
|
||||
"android.permission.MANAGE_OWN_CALLS",
|
||||
"android.permission.POST_NOTIFICATIONS",
|
||||
"android.permission.READ_PHONE_STATE",
|
||||
"android.permission.BLUETOOTH_CONNECT",
|
||||
"android.permission.RECORD_AUDIO"
|
||||
)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
UITestsUtils.testAppSetup()
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
package org.linphone.methods
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.core.app.ApplicationProvider.getApplicationContext
|
||||
import androidx.test.espresso.*
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.*
|
||||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||
import java.util.*
|
||||
import kotlinx.coroutines.*
|
||||
import org.hamcrest.Matcher
|
||||
import org.junit.rules.TestWatcher
|
||||
import org.junit.runner.Description
|
||||
import org.linphone.LinphoneApplication
|
||||
|
|
@ -48,6 +48,11 @@ object UITestsUtils {
|
|||
// launch app
|
||||
Log.i("[UITests] Launch Linphone app")
|
||||
if (!isAppLaunch()) { launchApp() }
|
||||
try {
|
||||
onView(withId(R.id.assistant_welcome_layout)).check(doesNotExist())
|
||||
} catch (e: Throwable) {
|
||||
onView(withId(R.id.back)).perform(click())
|
||||
}
|
||||
if (!rightAccountConnected() || !accountIsConnected()) {
|
||||
removeAllAccounts()
|
||||
connectAccount()
|
||||
|
|
@ -99,7 +104,8 @@ object UITestsUtils {
|
|||
Log.i("[UITests] Connect ${manager.appAccountAuthInfo.username} user to Linphone app")
|
||||
val core = LinphoneApplication.coreContext.core
|
||||
LinphoneApplication.corePreferences.useDnsServer = true
|
||||
LinphoneApplication.corePreferences.dnsServerAddress = manager.dnsServer.first()
|
||||
LinphoneApplication.corePreferences.dnsServerAddress = manager.dnsServer.last()
|
||||
core.setDnsServersApp(manager.dnsServer)
|
||||
val accountParams = core.createAccountParams()
|
||||
val identity = manager.createAddress(manager.appAccountAuthInfo)
|
||||
accountParams.identityAddress = identity
|
||||
|
|
@ -123,32 +129,6 @@ object UITestsUtils {
|
|||
}
|
||||
}
|
||||
|
||||
fun waitForExistence(matcher: Matcher<View>, timeout: Double) {
|
||||
return waitForView(matcher, timeout, true)
|
||||
}
|
||||
|
||||
fun waitForNonExistence(matcher: Matcher<View>, timeout: Double) {
|
||||
return waitForView(matcher, timeout, false)
|
||||
}
|
||||
|
||||
private fun waitForView(matcher: Matcher<View>, timeout: Double, exist: Boolean) = runBlocking {
|
||||
var result = false
|
||||
val wait = launch(Dispatchers.Default) {
|
||||
repeat(timeout.toInt() * 10) {
|
||||
try {
|
||||
onView(matcher).check(matches(isDisplayed()))
|
||||
result = true
|
||||
cancel()
|
||||
} catch (_: Exception) {
|
||||
// do nothing to retry until timeout
|
||||
}
|
||||
delay(100)
|
||||
}
|
||||
}
|
||||
wait.join()
|
||||
assert(result) { "[UITests] $matcher still ${if (exist) "not " else ""}displayed after $timeout seconds" }
|
||||
}
|
||||
|
||||
fun ViewInteraction.checkWithTimeout(viewAssert: ViewAssertion, timeout: Double): ViewInteraction = runBlocking {
|
||||
val wait = launch(Dispatchers.Default) {
|
||||
repeat(timeout.toInt() * 10) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
</data>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/assistant_welcome_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue