-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added snapshot test for Preview activity
MOB-2955
- Loading branch information
1 parent
5a878bd
commit c73b2b4
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...t/snapshots/images/com.glia.widgets.filepreview_FilePreviewTest_defaultView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions
57
widgetssdk/src/testSnapshot/java/com/glia/widgets/filepreview/FilePreviewTest.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,57 @@ | ||
package com.glia.widgets.filepreview | ||
|
||
import android.view.MenuInflater | ||
import androidx.annotation.RawRes | ||
import com.android.ide.common.rendering.api.SessionParams | ||
import com.glia.widgets.R | ||
import com.glia.widgets.SnapshotTest | ||
import com.glia.widgets.StringProvider | ||
import com.glia.widgets.databinding.FilePreviewActivityBinding | ||
import com.glia.widgets.di.Dependencies | ||
import com.glia.widgets.snapshotutils.SnapshotStringProvider | ||
import org.junit.Test | ||
|
||
internal class FilePreviewTest : SnapshotTest( | ||
renderingMode = SessionParams.RenderingMode.NORMAL, | ||
theme = "Application_Glia_FilePreview_Activity" | ||
) { | ||
|
||
override fun setUp() { | ||
super.setUp() | ||
|
||
val sp: StringProvider = SnapshotStringProvider(context) | ||
Dependencies.setStringProvider(sp) | ||
} | ||
|
||
@Test | ||
fun defaultView() { | ||
snapshot( | ||
setupView().root | ||
) | ||
} | ||
|
||
fun setupView( | ||
title: String? = "Snapshot preview", | ||
showDownloadIcon: Boolean = true, | ||
showShareIcon: Boolean = false, | ||
@RawRes imageRes: Int? = R.drawable.test_banner | ||
): FilePreviewActivityBinding { | ||
val filePreviewActivityBinding = FilePreviewActivityBinding.inflate(layoutInflater) | ||
|
||
filePreviewActivityBinding.toolbar.title = title | ||
|
||
val menu = filePreviewActivityBinding.toolbar.menu | ||
MenuInflater(context).inflate(R.menu.menu_file_preview, menu) | ||
menu.findItem(R.id.save_item).also { | ||
it.isVisible = showDownloadIcon | ||
} | ||
menu.findItem(R.id.share_item).also { | ||
it.isVisible = showShareIcon | ||
} | ||
|
||
imageRes?.also { filePreviewActivityBinding.filePreviewView.setImageResource(it) } | ||
|
||
return filePreviewActivityBinding | ||
} | ||
|
||
} |