-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix UI tests, update dependencies and GH Actions runner
- Loading branch information
Showing
8 changed files
with
154 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/src/androidTest/java/nl/eduvpn/app/ui_test/BrowserTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package nl.eduvpn.app.ui_test | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.UiObjectNotFoundException | ||
import androidx.test.uiautomator.UiSelector | ||
import nl.eduvpn.app.utils.Log | ||
|
||
abstract class BrowserTest { | ||
|
||
companion object { | ||
private val TAG = BrowserTest::class.java.name | ||
} | ||
fun prepareBrowser() { | ||
// Switch over to UI Automator now, to control the browser | ||
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
// Wait for the browser to open and load | ||
Thread.sleep(2_000L) | ||
try { | ||
// Newer Chrome versions ask if you want to log in | ||
val acceptButton = device.findObject(UiSelector().text("Use without an account")) | ||
acceptButton.click() | ||
} catch (ex: UiObjectNotFoundException) { | ||
Log.w(TAG, "No Chrome user account shown, continuing", ex) | ||
} | ||
try { | ||
// Chrome asks at first launch to accept data usage | ||
val acceptButton = device.findObject(UiSelector().className("android.widget.Button").text("Accept & continue")) | ||
acceptButton.click() | ||
} catch (ex: UiObjectNotFoundException) { | ||
Log.w(TAG, "No Chrome accept window shown, continuing", ex) | ||
} | ||
try { | ||
// Do not send all our web traffic to Google | ||
val liteModeToggle = device.findObject(UiSelector().className("android.widget.Switch")) | ||
if(liteModeToggle.isChecked) { | ||
liteModeToggle.click() | ||
} | ||
val nextButton = device.findObject(UiSelector().className("android.widget.Button").text("Next")) | ||
nextButton.click() | ||
} catch (ex: UiObjectNotFoundException) { | ||
Log.w(TAG, "No lite mode window shown, continuing", ex) | ||
} | ||
try { | ||
// Now it wants us to Sign in... | ||
val noThanksButton = device.findObject(UiSelector().text("No thanks")) | ||
noThanksButton.click() | ||
} catch (ex: UiObjectNotFoundException) { | ||
Log.w(TAG, "No request for sign in, continung", ex) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.