@@ -182,6 +182,20 @@ TEST_F(UIManagerMediaFeaturesTest, reactCommitResolvesAChangeDuringIt) {
182182 EXPECT_FLOAT_EQ (committedOpacity (), 0.5 );
183183}
184184
185+ TEST_F (
186+ UIManagerMediaFeaturesTest,
187+ firstConditionalViewResolvesAChangeDuringItsCommit) {
188+ // The committed tree has no conditional values yet, only the React commit.
189+ SetMediaFeaturesDuringCommitHook commitHook;
190+ commitHook.mediaFeatures = MediaFeatures{.colorScheme = ColorScheme::Dark};
191+ uiManager_->registerCommitHook (commitHook);
192+ reactCommit (createView ());
193+ uiManager_->unregisterCommitHook (commitHook);
194+
195+ EXPECT_FALSE (commitHook.mediaFeatures .has_value ());
196+ EXPECT_FLOAT_EQ (committedOpacity (), 0.5 );
197+ }
198+
185199TEST_F (UIManagerMediaFeaturesTest, cancelledReactCommitDoesNotSaveTheChange) {
186200 auto view = createView ();
187201 reactCommit (view);
@@ -254,17 +268,22 @@ TEST_F(UIManagerMediaFeaturesTest, aCommitOfAnOlderTreeResolvesAChange) {
254268 EXPECT_FLOAT_EQ (committedOpacity (), 0.5 );
255269}
256270
257- TEST_F (UIManagerMediaFeaturesTest, aChangeDoesNotCommitATreeWithoutThem ) {
271+ TEST_F (UIManagerMediaFeaturesTest, aChangeDoesNotCloneViewsOfATreeWithoutThem ) {
258272 reactCommit (uiManager_->createNode (
259273 viewTag_,
260274 " View" ,
261275 surfaceId_,
262276 RawProps (folly::dynamic::object (" opacity" , 1 )),
263277 nullptr ));
264- auto revisionNumber = shadowTree_->getCurrentRevision (). number ;
278+ auto revisionBeforeChange = shadowTree_->getCurrentRevision ();
265279
280+ // The change commits only a new root.
266281 uiManager_->setMediaFeatures ({.colorScheme = ColorScheme::Dark});
267- EXPECT_EQ (shadowTree_->getCurrentRevision ().number , revisionNumber);
282+ auto revision = shadowTree_->getCurrentRevision ();
283+ EXPECT_EQ (revision.number , revisionBeforeChange.number + 1 );
284+ EXPECT_EQ (
285+ revision.rootShadowNode ->getChildren ().front (),
286+ revisionBeforeChange.rootShadowNode ->getChildren ().front ());
268287}
269288
270289TEST_F (UIManagerMediaFeaturesTest, aChangeDoesNotCloneViewsThatDoNotReadIt) {
0 commit comments