Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
236 additions
and
159 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
Binary file modified
BIN
-47.4 KB
(12%)
...radle-plugin/src/test/projects/compose-wear/src/test/resources/compose_wear.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
paparazzi/paparazzi-gradle-plugin/src/test/projects/widgets/build.gradle
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,25 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'kotlin-android' | ||
id 'app.cash.paparazzi' | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "file://${projectDir.absolutePath}/../../../../../build/localMaven" | ||
} | ||
mavenCentral() | ||
//mavenLocal() | ||
google() | ||
} | ||
|
||
android { | ||
compileSdk libs.versions.compileSdk.get() as int | ||
defaultConfig { | ||
minSdk libs.versions.minSdk.get() as int | ||
} | ||
} | ||
|
||
dependencies { | ||
testImplementation libs.testParameterInjector | ||
} |
104 changes: 104 additions & 0 deletions
104
...c/test/projects/widgets/src/test/java/app/cash/paparazzi/plugin/test/RenderingModeTest.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,104 @@ | ||
package app.cash.paparazzi.plugin.test | ||
|
||
import android.content.Context | ||
import android.graphics.Color | ||
import android.graphics.drawable.GradientDrawable | ||
import android.view.Gravity | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT | ||
import android.widget.Button | ||
import android.widget.LinearLayout | ||
import android.widget.TextView | ||
import app.cash.paparazzi.DeviceConfig | ||
import app.cash.paparazzi.Paparazzi | ||
import com.android.ide.common.rendering.api.SessionParams.RenderingMode | ||
import com.android.ide.common.rendering.api.SessionParams.RenderingMode.NORMAL | ||
import com.android.ide.common.rendering.api.SessionParams.RenderingMode.SHRINK | ||
import com.google.testing.junit.testparameterinjector.TestParameter | ||
import com.google.testing.junit.testparameterinjector.TestParameterInjector | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(TestParameterInjector::class) | ||
class RenderingModeTest( | ||
@TestParameter val mode: Mode | ||
) { | ||
@get:Rule | ||
val paparazzi = Paparazzi( | ||
deviceConfig = DeviceConfig.PIXEL_3.copy(softButtons = false), | ||
renderingMode = mode.renderingMode | ||
) | ||
|
||
@Test fun default() { | ||
paparazzi.snapshot(buildView(paparazzi.context)) | ||
} | ||
|
||
enum class Mode( | ||
val renderingMode: RenderingMode | ||
) { | ||
WIDGET(renderingMode = SHRINK), | ||
FULL_SCREEN(renderingMode = NORMAL) | ||
} | ||
|
||
private fun buildView(context: Context): View { | ||
return LinearLayout(context).apply { | ||
orientation = LinearLayout.VERTICAL | ||
layoutParams = ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) | ||
addView( | ||
TextView(context).apply { | ||
id = 1 | ||
text = "Text View Sample" | ||
} | ||
) | ||
|
||
addView( | ||
View(context).apply { | ||
id = 2 | ||
layoutParams = LinearLayout.LayoutParams(100, 100) | ||
contentDescription = "Content Description Sample" | ||
} | ||
) | ||
|
||
addView( | ||
View(context).apply { | ||
id = 3 | ||
layoutParams = LinearLayout.LayoutParams(100, 100).apply { | ||
setMargins(20, 20, 20, 20) | ||
} | ||
contentDescription = "Margin Sample" | ||
} | ||
) | ||
|
||
addView( | ||
View(context).apply { | ||
id = 4 | ||
layoutParams = LinearLayout.LayoutParams(100, 100).apply { | ||
setMargins(20, 20, 20, 20) | ||
} | ||
foreground = GradientDrawable( | ||
GradientDrawable.Orientation.TL_BR, | ||
intArrayOf(Color.YELLOW, Color.BLUE) | ||
).apply { | ||
shape = GradientDrawable.OVAL | ||
} | ||
contentDescription = "Foreground Drawable" | ||
} | ||
) | ||
|
||
addView( | ||
Button(context).apply { | ||
id = 5 | ||
layoutParams = LinearLayout.LayoutParams( | ||
WRAP_CONTENT, | ||
WRAP_CONTENT | ||
).apply { | ||
gravity = Gravity.CENTER | ||
} | ||
text = "Button Sample" | ||
} | ||
) | ||
} | ||
} | ||
} |
Binary file added
BIN
+11.3 KB
...azzi-gradle-plugin/src/test/projects/widgets/src/test/resources/full_screen.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13 KB
...paparazzi-gradle-plugin/src/test/projects/widgets/src/test/resources/widget.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
159 changes: 0 additions & 159 deletions
159
paparazzi/paparazzi/src/test/java/app/cash/paparazzi/RenderingModeTest.kt
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.