forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix updating root constraints (#1387)
Since `owner.size` doesn't really observed during composition setting scene size might not trigger invalidations - Manually run `updateRootConstraints` instead of marking size as state - Pick extra conditions from [aosp/2598886](https://android-review.googlesource.com/c/platform/frameworks/support/+/2598886) Fixes stretching reported in JetBrains/compose-multiplatform#4850 ## Testing Run `MultiLayerComposeSceneTest` ## Release Notes ### Fixes - iOS - Fix missing invalidations during native view resize
- Loading branch information
1 parent
155403a
commit e0fe94b
Showing
2 changed files
with
96 additions
and
19 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
47 changes: 47 additions & 0 deletions
47
compose/ui/ui/src/skikoTest/kotlin/androidx/compose/ui/scene/MultiLayerComposeSceneTest.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,47 @@ | ||
/* | ||
* Copyright 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package androidx.compose.ui.scene | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.IntSize | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlinx.coroutines.test.StandardTestDispatcher | ||
import kotlinx.coroutines.test.runTest | ||
|
||
class MultiLayerComposeSceneTest { | ||
|
||
@Test | ||
fun sceneSizeChangeTriggersInvalidation() = runTest(StandardTestDispatcher()) { | ||
var invalidationCount = 0 | ||
val scene = MultiLayerComposeScene( | ||
size = IntSize(100, 100), | ||
invalidate = { invalidationCount++ } | ||
) | ||
try { | ||
scene.setContent { Box(Modifier.fillMaxSize()) } | ||
|
||
assertEquals(1, invalidationCount) | ||
scene.size = IntSize(120, 120) | ||
assertEquals(2, invalidationCount) | ||
} finally { | ||
scene.close() | ||
} | ||
} | ||
} |