Skip to content

Commit

Permalink
Use the center parameter from MockFoldingFeature annotation (#111)
Browse files Browse the repository at this point in the history
* Use the `center` parameter from MockFoldingFeature annotation

* Added validation rules for MockFoldingFeature.WindowBounds width and height
  • Loading branch information
ancirja-m authored Jun 23, 2022
1 parent 6a4b8b6 commit 5aebd3e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class FoldableTestRule : TestRule {
val displayFeatures = if (forDualScreenTest) {
val foldingFeature = FoldingFeature(
windowBounds = Rect(0, 0, uiDevice.displayWidth, uiDevice.displayHeight),
state = FoldingFeature.State.HALF_OPENED,
size = 0,
state = FoldingFeature.State.HALF_OPENED,
orientation = getFoldingFeatureOrientation(deviceOrientation)
)
listOf(foldingFeature)
Expand All @@ -142,8 +142,9 @@ class FoldableTestRule : TestRule {
private fun mockFoldingFeature(mockFoldingFeatureAnnotation: MockFoldingFeature) {
val foldingFeature = FoldingFeature(
windowBounds = mockFoldingFeatureAnnotation.windowBoundsRect,
state = mockFoldingFeatureAnnotation.foldingFeatureState,
center = mockFoldingFeatureAnnotation.center,
size = mockFoldingFeatureAnnotation.size,
state = mockFoldingFeatureAnnotation.foldingFeatureState,
orientation = mockFoldingFeatureAnnotation.foldingFeatureOrientation
)
val windowLayoutInfo = TestWindowLayoutInfo(listOf(foldingFeature))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.microsoft.device.dualscreen.testing.filters.DualScreenTest
import com.microsoft.device.dualscreen.testing.filters.MockFoldingFeature
import com.microsoft.device.dualscreen.testing.filters.SingleScreenTest
import com.microsoft.device.dualscreen.testing.filters.TargetDevices
import com.microsoft.device.dualscreen.testing.filters.windowBoundsRect
import com.microsoft.device.dualscreen.testing.getDeviceModel
import org.junit.Test
import org.junit.runner.Description
Expand Down Expand Up @@ -123,6 +124,22 @@ class FoldableJUnit4ClassRunner : AndroidJUnit4ClassRunner {
)
)
}

if (it.windowBoundsRect.width() <= 0) {
errors?.add(
Exception(
"Method " + method.name + ": @MockFoldingFeature.windowBounds.width should be greater than 0"
)
)
}

if (it.windowBoundsRect.height() <= 0) {
errors?.add(
Exception(
"Method " + method.name + ": @MockFoldingFeature.windowBounds.height should be greater than 0"
)
)
}
}
}

Expand Down

0 comments on commit 5aebd3e

Please sign in to comment.