Skip to content

Commit

Permalink
Take screenshots of the about view and dynamic color themed main view
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbakker committed May 6, 2024
1 parent 738d7a3 commit f2b093d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ android {
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
buildConfigField "String", "GIT_BRANCH", "\"${getGitBranch()}\""
buildConfigField "java.util.concurrent.atomic.AtomicBoolean", "TEST", "new java.util.concurrent.atomic.AtomicBoolean(false)"
buildConfigField "java.util.concurrent.atomic.AtomicBoolean", "DYNAMIC_COLORS", "new java.util.concurrent.atomic.AtomicBoolean(true)"

kapt {
arguments {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.takeScreenshot
import androidx.test.core.graphics.writeToTestStorage
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.openContextualActionModeOverflowMenu
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.longClick
import androidx.test.espresso.action.ViewActions.pressBack
Expand Down Expand Up @@ -77,6 +78,11 @@ class ScreenshotTest {
onView(withId(R.id.rvAccounts))
.check(matches(hasDescendant(withText("Nextcloud"))))

takeScreenshot().writeToTestStorage("screenshot6")

BuildConfig.DYNAMIC_COLORS.set(false)
scenario.recreate()

takeScreenshot().writeToTestStorage("screenshot1")

onView(withId(R.id.rvAccounts)).perform(
Expand All @@ -91,6 +97,13 @@ class ScreenshotTest {

onView(isRoot()).perform(pressBack())

openContextualActionModeOverflowMenu()
onView(withText(R.string.action_about)).perform(click())

takeScreenshot().writeToTestStorage("screenshot5")

onView(isRoot()).perform(pressBack())

onView(withId(R.id.rvAccounts)).perform(
RecyclerViewActions.actionOnItem<AccountAdapter.Holder>(
hasDescendant(withText("Nextcloud")),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package dev.rocli.android.webdav

import android.app.Application
import com.google.android.material.color.DynamicColors
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class WebDavApplication : Application() {
override fun onCreate() {
super.onCreate()
DynamicColors.applyToActivitiesIfAvailable(this)
}
}
class WebDavApplication : Application()
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.navigation.NavController
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.findNavController
import androidx.navigation.ui.NavigationUI.setupActionBarWithNavController
import com.google.android.material.color.DynamicColors
import com.google.android.material.color.MaterialColors
import dagger.hilt.android.AndroidEntryPoint
import dev.rocli.android.webdav.BuildConfig
Expand All @@ -29,6 +30,9 @@ class MainActivity : AppCompatActivity() {
private lateinit var statusGuardHack: ActionModeStatusGuardHack

override fun onCreate(savedInstanceState: Bundle?) {
if (BuildConfig.DYNAMIC_COLORS.get()) {
DynamicColors.applyToActivityIfAvailable(this)
}
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.*
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.databinding.DataBindingUtil
Expand Down Expand Up @@ -35,6 +39,12 @@ class AboutFragment : LibsSupportFragment() {
super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true)

// Override the app name during instrumented tests so that
// we don't see "(Debug)" in the automatically generated screenshots.
if (BuildConfig.TEST.get()) {
binding.textAppName.text = getString(R.string.app_name_release)
}

binding.appVersion.text = getCurrentAppVersion()
binding.btnLicense.setOnClickListener {
LicenseDialog.create().show(parentFragmentManager, null)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Licenced under GPLv3
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/textAppName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
Expand Down

0 comments on commit f2b093d

Please sign in to comment.