Skip to content

Commit

Permalink
Merge "Disable pending draw check in ComposeIdlingResource" into andr…
Browse files Browse the repository at this point in the history
…oidx-master-dev
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Nov 26, 2020
2 parents 7c7b965 + cfac1cf commit 3126b56
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ internal class ComposeIdlingResource : IdlingResource, IdlingResourceWithDiagnos
private var hadNoRecomposerChanges = true
private var lastCompositionAwaiters = 0
private var hadNoPendingMeasureLayout = true
private var hadNoPendingDraw = true
// TODO(b/174244530): Include hadNoPendingDraw when it is reliable
// private var hadNoPendingDraw = true

private var compositionAwaiters = AtomicInteger(0)

Expand All @@ -156,10 +157,11 @@ internal class ComposeIdlingResource : IdlingResource, IdlingResourceWithDiagnos
lastCompositionAwaiters = compositionAwaiters.get()
val owners = androidOwnerRegistry.getUnfilteredOwners()
hadNoPendingMeasureLayout = !owners.any { it.hasPendingMeasureOrLayout }
hadNoPendingDraw = !owners.any {
val hasContent = it.view.measuredWidth != 0 && it.view.measuredHeight != 0
it.view.isDirty && (hasContent || it.view.isLayoutRequested)
}
// TODO(b/174244530): Include hadNoPendingDraw when it is reliable
// hadNoPendingDraw = !owners.any {
// val hasContent = it.view.measuredWidth != 0 && it.view.measuredHeight != 0
// it.view.isDirty && (hasContent || it.view.isLayoutRequested)
// }

check(lastCompositionAwaiters >= 0) {
"More CompositionAwaiters were removed then added ($lastCompositionAwaiters)"
Expand All @@ -169,8 +171,9 @@ internal class ComposeIdlingResource : IdlingResource, IdlingResourceWithDiagnos
hadNoRecomposerChanges &&
hadAnimationClocksIdle &&
lastCompositionAwaiters == 0 &&
hadNoPendingMeasureLayout &&
hadNoPendingDraw
// TODO(b/174244530): Include hadNoPendingDraw when it is reliable
hadNoPendingMeasureLayout /*&&
hadNoPendingDraw*/
}
}

Expand Down Expand Up @@ -255,7 +258,8 @@ internal class ComposeIdlingResource : IdlingResource, IdlingResourceWithDiagnos
val numCompositionAwaiters = lastCompositionAwaiters
val wasAwaitingCompositions = numCompositionAwaiters > 0
val hadPendingMeasureLayout = !hadNoPendingMeasureLayout
val hadPendingDraw = !hadNoPendingDraw
// TODO(b/174244530): Include hadNoPendingDraw when it is reliable
// val hadPendingDraw = !hadNoPendingDraw

val wasIdle = !hadSnapshotChanges && !hadRecomposerChanges &&
!hadRunningAnimations && !wasAwaitingCompositions
Expand All @@ -280,8 +284,9 @@ internal class ComposeIdlingResource : IdlingResource, IdlingResourceWithDiagnos
message += "- Debug: hadRecomposerChanges = $hadRecomposerChanges, "
message += "hadSnapshotChanges = $hadSnapshotChanges, "
message += "numCompositionAwaiters = $numCompositionAwaiters, "
message += "hadPendingMeasureLayout = $hadPendingMeasureLayout, "
message += "hadPendingDraw = $hadPendingDraw"
message += "hadPendingMeasureLayout = $hadPendingMeasureLayout"
// TODO(b/174244530): Include hadNoPendingDraw when it is reliable
// message += ", hadPendingDraw = $hadPendingDraw"
}
return message
}
Expand Down

0 comments on commit 3126b56

Please sign in to comment.