summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shared/src/test/java/com/android/tools/analytics/stubs/StubGraphicsDevice.kt22
1 files changed, 14 insertions, 8 deletions
diff --git a/shared/src/test/java/com/android/tools/analytics/stubs/StubGraphicsDevice.kt b/shared/src/test/java/com/android/tools/analytics/stubs/StubGraphicsDevice.kt
index 7bfb862..59b5ae6 100644
--- a/shared/src/test/java/com/android/tools/analytics/stubs/StubGraphicsDevice.kt
+++ b/shared/src/test/java/com/android/tools/analytics/stubs/StubGraphicsDevice.kt
@@ -21,6 +21,7 @@ import org.junit.Assert.fail
import java.awt.GraphicsConfiguration
import java.awt.GraphicsDevice
import java.awt.Rectangle
+import java.awt.geom.AffineTransform
/**
* A Stub implementation of [GraphicsDevice] for use in tests. By default fails on any call.
@@ -51,16 +52,21 @@ open class StubGraphicsDevice : GraphicsDevice() {
@JvmStatic
/** Creates a GraphicsDevice with specified width & height. */
- fun withBounds(width: Int, height: Int): GraphicsDevice {
- return object : StubGraphicsDevice() {
- override fun getDefaultConfiguration(): GraphicsConfiguration? {
- return object : StubGraphicsConfiguration() {
- override fun getBounds(): Rectangle? {
- return Rectangle(width, height)
- }
- }
+ fun withBounds(width: Int, height: Int): GraphicsDevice =
+ StubGraphicsDeviceWithBounds(width, height)
+
+ private class StubGraphicsDeviceWithBounds constructor(
+ val width: Int,
+ val height: Int
+ ) : StubGraphicsDevice() {
+ override fun getDefaultConfiguration(): GraphicsConfiguration {
+ return object : StubGraphicsConfiguration() {
+ override fun getBounds() = Rectangle(width, height)
+ override fun getDevice() = this@StubGraphicsDeviceWithBounds
+ override fun getDefaultTransform() = AffineTransform()
}
}
+ override fun getType(): Int = TYPE_RASTER_SCREEN
}
}
}