Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ import ooniprobe.composeapp.generated.resources.Res
import ooniprobe.composeapp.generated.resources.Settings_About_Label
import ooniprobe.composeapp.generated.resources.Settings_Advanced_Label
import ooniprobe.composeapp.generated.resources.Settings_Privacy_Label
import ooniprobe.composeapp.generated.resources.Settings_Proxy_Enabled
import ooniprobe.composeapp.generated.resources.Settings_Proxy_Label
import ooniprobe.composeapp.generated.resources.Settings_Proxy_Psiphon
import ooniprobe.composeapp.generated.resources.Settings_Sharing_UploadResults_Description
import ooniprobe.composeapp.generated.resources.Settings_TestOptions_Label
import ooniprobe.composeapp.generated.resources.Settings_Title
import ooniprobe.composeapp.generated.resources.Settings_Websites_Categories_Label
import ooniprobe.composeapp.generated.resources.Settings_Websites_CustomURL_Title
import ooniprobe.composeapp.generated.resources.TestResults
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Tab_Label
import ooniprobe.composeapp.generated.resources.Test_Dash_Fullname
import ooniprobe.composeapp.generated.resources.Test_Performance_Fullname
import ooniprobe.composeapp.generated.resources.Test_Websites_Fullname
import ooniprobe.composeapp.generated.resources.Tests_Title
import ooniprobe.composeapp.generated.resources.app_name
import org.junit.AfterClass
import org.junit.Before
Expand Down Expand Up @@ -106,6 +108,7 @@ class AutomateScreenshotsTest {
runTest {
if (!isOoni) return@runTest
preferences.setValueByKey(SettingsKey.FIRST_RUN, true)
preferences.setValueByKey(SettingsKey.TESTS_MOVED_NOTICE, true)
start()

with(compose) {
Expand Down Expand Up @@ -153,6 +156,32 @@ class AutomateScreenshotsTest {
}
}

@Test
fun tests() =
runTest {
if (!isOoni) return@runTest
skipOnboarding()
defaultSettings()
start()

with(compose) {
wait { onNodeWithContentDescription(Res.string.app_name).isDisplayed() }

wait(timeout = 30.seconds) {
onNodeWithText(Res.string.Dashboard_Progress_UpdateLink_Label)
.isNotDisplayed()
}

clickOnText(Res.string.Tests_Title)

wait {
onNodeWithText(Res.string.Test_Websites_Fullname).isDisplayed()
}
Screengrab.screenshot("2_" + locale())
Screengrab.screenshot("22-tests")
}
}

@Test
fun runTests() =
runTest {
Expand Down Expand Up @@ -257,17 +286,15 @@ class AutomateScreenshotsTest {

// back
clickOnContentDescription(Res.string.Common_Back)

wait { onNodeWithText(Res.string.Settings_About_Label).isDisplayed() }

clickOnText(Res.string.Settings_Proxy_Label)
wait { onNodeWithText(Res.string.Settings_Proxy_Enabled).isDisplayed() }
wait { onNodeWithText(Res.string.Settings_Proxy_Psiphon).isDisplayed() }

Screengrab.screenshot("14-proxy")

// back
clickOnContentDescription(Res.string.Common_Back)

wait { onNodeWithText(Res.string.Settings_About_Label).isDisplayed() }

clickOnText(Res.string.Settings_Advanced_Label)
Expand Down Expand Up @@ -298,14 +325,14 @@ class AutomateScreenshotsTest {
with(compose) {
wait { onNodeWithContentDescription(Res.string.app_name).isDisplayed() }

clickOnText(Res.string.TestResults_Overview_Tab_Label)
clickOnText(Res.string.TestResults)

wait { onNodeWithText(Res.string.Test_Websites_Fullname).isDisplayed() }

Screengrab.screenshot("17-results")

Thread.sleep(3000)
Screengrab.screenshot("2_" + locale())
Screengrab.screenshot("3_" + locale())

clickOnText(Res.string.Test_Websites_Fullname)

Expand All @@ -320,7 +347,7 @@ class AutomateScreenshotsTest {
checkTextAnywhereInsideWebView("https://z-lib.org/")

Screengrab.screenshot("19-website-measurement-anomaly")
Screengrab.screenshot("3_" + locale())
Screengrab.screenshot("4_" + locale())

clickOnContentDescription(Res.string.Common_Back)
wait { onNodeWithText(Res.string.Test_Websites_Fullname).isDisplayed() }
Expand All @@ -335,7 +362,7 @@ class AutomateScreenshotsTest {
Screengrab.screenshot("20-dash-measurement")

Thread.sleep(3000)
Screengrab.screenshot("4_" + locale())
Screengrab.screenshot("5_" + locale())
}
}

Expand All @@ -353,12 +380,13 @@ class AutomateScreenshotsTest {
.isNotDisplayed()
}

clickOnText(Res.string.Tests_Title)
clickOnText(Res.string.Test_Websites_Fullname)
wait { onNodeWithText(Res.string.Test_Websites_Fullname).isDisplayed() }
clickOnText(Res.string.Dashboard_Overview_ChooseWebsites)
wait { onNodeWithText(Res.string.Settings_Websites_CustomURL_Title).isDisplayed() }
Screengrab.screenshot("21-choose-websites")
Screengrab.screenshot("5_" + locale())
Screengrab.screenshot("6_" + locale())
}
}

Expand Down Expand Up @@ -387,14 +415,18 @@ class AutomateScreenshotsTest {

Screengrab.screenshot("1_${locale()}")

clickOnText(Res.string.Tests_Title)
wait { onNodeWithContentDescription(Res.string.Test_Websites_Fullname).isDisplayed() }
Screengrab.screenshot("2_${locale()}")

clickOnText(Res.string.Settings_Title)

wait { onNodeWithContentDescription(Res.string.Settings_About_Label).isDisplayed() }

clickOnText(Res.string.Settings_About_Label)

wait { onNodeWithTag("AboutScreen").isDisplayed() }
Screengrab.screenshot("5_${locale()}")
Screengrab.screenshot("6_${locale()}")

clickOnContentDescription(Res.string.Common_Back)

Expand All @@ -403,21 +435,21 @@ class AutomateScreenshotsTest {
wait { onNodeWithText(trustedName).isDisplayed() }

Thread.sleep(3000)
Screengrab.screenshot("2_${locale()}")
Screengrab.screenshot("3_${locale()}")

clickOnText(trustedName)

wait(10.seconds) { onNodeWithText("https://www.dw.com").isDisplayed() }

// Screenshot was coming up empty, so we need to explicitly sleep here
Thread.sleep(3000)
Screengrab.screenshot("3_${locale()}")
Screengrab.screenshot("4_${locale()}")

clickOnText("https://www.dw.com")

checkTextAnywhereInsideWebView("https://www.dw.com")

Screengrab.screenshot("4_${locale()}")
Screengrab.screenshot("5_${locale()}")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.ooni.probe.uitesting

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.junit4.createEmptyComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.test.runTest
import ooniprobe.composeapp.generated.resources.Dashboard_Articles_Title
import ooniprobe.composeapp.generated.resources.Dashboard_TestsMoved_Description
import ooniprobe.composeapp.generated.resources.Res
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.ooni.probe.data.models.SettingsKey
import org.ooni.probe.uitesting.helpers.disableRefreshArticles
import org.ooni.probe.uitesting.helpers.onNodeWithText
import org.ooni.probe.uitesting.helpers.preferences
import org.ooni.probe.uitesting.helpers.skipOnboarding
import org.ooni.probe.uitesting.helpers.start
import org.ooni.probe.uitesting.helpers.wait
import kotlin.time.Duration.Companion.minutes

@RunWith(AndroidJUnit4::class)
class DashboardTest {
@get:Rule
val compose = createEmptyComposeRule()

@Before
fun setUp() =
runTest {
skipOnboarding()
}

@Test
fun testsMovedNotice() =
runTest {
disableRefreshArticles()
preferences.setValueByKey(SettingsKey.TESTS_MOVED_NOTICE, false)
start()

with(compose) {
onNodeWithText(Res.string.Dashboard_TestsMoved_Description).assertIsDisplayed()
}
}

@Test
fun news() =
runTest {
preferences.setValueByKey(SettingsKey.LAST_ARTICLES_REFRESH, 0L)
start()

with(compose) {
wait(timeout = 1.minutes) {
onNodeWithText(Res.string.Dashboard_Articles_Title).isDisplayed()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import ooniprobe.composeapp.generated.resources.Dashboard_ReviewDescriptor_Butto
import ooniprobe.composeapp.generated.resources.Dashboard_Runv2_Overview_UninstallLink
import ooniprobe.composeapp.generated.resources.AddDescriptor_InstallForLater
import ooniprobe.composeapp.generated.resources.Res
import ooniprobe.composeapp.generated.resources.Tests_Title
import org.jetbrains.compose.resources.getString
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
Expand All @@ -38,6 +39,7 @@ import org.ooni.probe.MainActivity
import org.ooni.probe.uitesting.helpers.clickOnText
import org.ooni.probe.uitesting.helpers.context
import org.ooni.probe.uitesting.helpers.dependencies
import org.ooni.probe.uitesting.helpers.disableRefreshArticles
import org.ooni.probe.uitesting.helpers.isNewsMediaScan
import org.ooni.probe.uitesting.helpers.onAllNodesWithText
import org.ooni.probe.uitesting.helpers.onNodeWithText
Expand All @@ -56,6 +58,7 @@ class DescriptorsTest {
fun setUp() =
runTest {
skipOnboarding()
disableRefreshArticles()
}

@Test
Expand All @@ -82,8 +85,9 @@ class DescriptorsTest {

Thread.sleep(2000)

wait { onNodeWithTag("Dashboard-List").isDisplayed() }
onNodeWithTag("Dashboard-List")
clickOnText(Res.string.Tests_Title)
wait { onNodeWithTag("Descriptors-List").isDisplayed() }
onNodeWithTag("Descriptors-List")
.performScrollToNode(hasText("Android instrumented tests"))
onNodeWithText("Testing").assertIsDisplayed()

Expand Down Expand Up @@ -132,9 +136,10 @@ class DescriptorsTest {

setupTestEngine()

wait { onNodeWithTag("Dashboard-List").isDisplayed() }
clickOnText(Res.string.Tests_Title)
wait { onNodeWithTag("Descriptors-List").isDisplayed() }
// Pull down to refresh
onNodeWithTag("Dashboard-List").performTouchInput { swipeDown() }
onNodeWithTag("Descriptors-List").performTouchInput { swipeDown() }

clickOnText(
Res.string.Dashboard_Progress_ReviewLink_Action,
Expand All @@ -145,7 +150,7 @@ class DescriptorsTest {

clickOnText(getString(Res.string.Dashboard_ReviewDescriptor_Button_Last, 1, 1))

onNodeWithTag("Dashboard-List")
onNodeWithTag("Descriptors-List")
.performScrollToNode(hasText("Android instrumented tests"))
onNodeWithText("Testing 2").assertIsDisplayed()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.ooni.probe.data.models.SettingsKey
import org.ooni.probe.uitesting.helpers.clickOnTag
import org.ooni.probe.uitesting.helpers.clickOnText
import org.ooni.probe.uitesting.helpers.dependencies
import org.ooni.probe.uitesting.helpers.disableRefreshArticles
import org.ooni.probe.uitesting.helpers.isCrashReportingEnabled
import org.ooni.probe.uitesting.helpers.onNodeWithContentDescription
import org.ooni.probe.uitesting.helpers.onNodeWithText
Expand All @@ -41,6 +42,7 @@ class OnboardingTest {
@Before
fun setUp() =
runTest {
disableRefreshArticles()
start()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.test.runTest
import ooniprobe.composeapp.generated.resources.Common_Expand
import ooniprobe.composeapp.generated.resources.Dashboard_LastResults_SeeResults
import ooniprobe.composeapp.generated.resources.Dashboard_RunTests_RunButton_Label
import ooniprobe.composeapp.generated.resources.Dashboard_RunTests_SelectNone
import ooniprobe.composeapp.generated.resources.Dashboard_RunV2_RunFinished
import ooniprobe.composeapp.generated.resources.Measurement_Title
import ooniprobe.composeapp.generated.resources.OONIRun_Run
import ooniprobe.composeapp.generated.resources.Res
Expand All @@ -32,6 +32,7 @@ import org.ooni.probe.uitesting.helpers.checkSummaryInsideWebView
import org.ooni.probe.uitesting.helpers.checkTextAnywhereInsideWebView
import org.ooni.probe.uitesting.helpers.clickOnContentDescription
import org.ooni.probe.uitesting.helpers.clickOnText
import org.ooni.probe.uitesting.helpers.disableRefreshArticles
import org.ooni.probe.uitesting.helpers.isNewsMediaScan
import org.ooni.probe.uitesting.helpers.isOoni
import org.ooni.probe.uitesting.helpers.onNodeWithText
Expand All @@ -50,6 +51,7 @@ class RunningTestsTest {
fun setUp() =
runTest {
skipOnboarding()
disableRefreshArticles()
preferences.setValueByKey(SettingsKey.UPLOAD_RESULTS, true)
start()
}
Expand All @@ -66,7 +68,7 @@ class RunningTestsTest {
clickOnText(Res.string.Test_Signal_Fullname)
clickOnRunButton(1)

clickOnText(Res.string.Dashboard_RunV2_RunFinished, timeout = TEST_WAIT_TIMEOUT)
clickOnText(Res.string.Dashboard_LastResults_SeeResults, timeout = TEST_WAIT_TIMEOUT)

clickOnText(Res.string.Test_InstantMessaging_Fullname)
clickOnText(Res.string.Test_Signal_Fullname)
Expand All @@ -87,7 +89,7 @@ class RunningTestsTest {
clickOnText(Res.string.Test_Psiphon_Fullname)
clickOnRunButton(1)

clickOnText(Res.string.Dashboard_RunV2_RunFinished, timeout = TEST_WAIT_TIMEOUT)
clickOnText(Res.string.Dashboard_LastResults_SeeResults, timeout = TEST_WAIT_TIMEOUT)

clickOnText(Res.string.Test_Circumvention_Fullname)
clickOnText(Res.string.Test_Psiphon_Fullname)
Expand All @@ -108,7 +110,7 @@ class RunningTestsTest {
clickOnText("HTTP Header", substring = true)
clickOnRunButton(1)

clickOnText(Res.string.Dashboard_RunV2_RunFinished, timeout = TEST_WAIT_TIMEOUT)
clickOnText(Res.string.Dashboard_LastResults_SeeResults, timeout = TEST_WAIT_TIMEOUT)

clickOnText(Res.string.Test_Performance_Fullname)
clickOnText("HTTP Header", substring = true)
Expand All @@ -129,7 +131,7 @@ class RunningTestsTest {
clickOnText("stunreachability", substring = true)
clickOnRunButton(1)

clickOnText(Res.string.Dashboard_RunV2_RunFinished, timeout = TEST_WAIT_TIMEOUT)
clickOnText(Res.string.Dashboard_LastResults_SeeResults, timeout = TEST_WAIT_TIMEOUT)

clickOnText(Res.string.Test_Experimental_Fullname)
compose.onAllNodesWithText("stunreachability")[0].performClick()
Expand All @@ -150,7 +152,7 @@ class RunningTestsTest {
clickOnText("Trusted International Media")
clickOnRunButton(1)

clickOnText(Res.string.Dashboard_RunV2_RunFinished, timeout = TEST_WAIT_TIMEOUT)
clickOnText(Res.string.Dashboard_LastResults_SeeResults, timeout = TEST_WAIT_TIMEOUT)

clickOnText("Trusted International Media")
clickOnText("https://www.dw.com")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.ooni.probe.data.models.ProxyOption
import org.ooni.probe.data.models.SettingsKey
import org.ooni.probe.uitesting.helpers.clickOnContentDescription
import org.ooni.probe.uitesting.helpers.clickOnText
import org.ooni.probe.uitesting.helpers.disableRefreshArticles
import org.ooni.probe.uitesting.helpers.isCrashReportingEnabled
import org.ooni.probe.uitesting.helpers.isOoni
import org.ooni.probe.uitesting.helpers.preferences
Expand All @@ -55,6 +56,7 @@ class SettingsTest {
fun setUp() =
runTest {
skipOnboarding()
disableRefreshArticles()
start()
}

Expand Down
Loading
Loading