@@ -1388,11 +1388,14 @@ TEST_F(TestValveConfigurationAndControlClusterLogic, TestAttributeUpdates)
1388
1388
EXPECT_EQ (valElapsedSNullable, DataModel::NullNullable);
1389
1389
EXPECT_EQ (logic.GetRemainingDuration (valElapsedSNullable), CHIP_NO_ERROR);
1390
1390
EXPECT_EQ (valElapsedSNullable, DataModel::NullNullable);
1391
- // We should see the currentLevel and currentState marked as dirty, and the targets should not be
1391
+
1392
+ // We should see the CurrentLevel and CurrentState marked as dirty because they are changed.
1393
+ // TargetState and TargetLevel should ALSO be marked as dirty because the target state should transition through
1394
+ // from target back to NULL per the spec (effect of receipt for open command).
1392
1395
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentLevel::Id));
1393
1396
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentState::Id));
1394
- EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::TargetLevel::Id));
1395
- EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::TargetState::Id));
1397
+ EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::TargetLevel::Id));
1398
+ EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::TargetState::Id));
1396
1399
EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::OpenDuration::Id));
1397
1400
EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::RemainingDuration::Id));
1398
1401
@@ -1413,12 +1416,16 @@ TEST_F(TestValveConfigurationAndControlClusterLogic, TestAttributeUpdates)
1413
1416
EXPECT_EQ (valElapsedSNullable.ValueOr (0 ), openDuration.Value ());
1414
1417
EXPECT_EQ (logic.GetCurrentLevel (valPercentNullable), CHIP_NO_ERROR);
1415
1418
EXPECT_EQ (valPercentNullable.ValueOr (0 ), requestedLevel);
1416
- // We should see the following attributes marked as dirty: currentLevel, remainingDuration, openDuration
1417
- // The targetLevel and targetState should be null, and thus we should see no update.
1419
+ // We should see the following attributes marked as dirty since they are different at the end
1420
+ // of the command: currentLevel, remainingDuration, openDuration
1421
+ // The TargetLevel and TargetState should be NULL at the end of the open call, but will still be
1422
+ // marked dirty per the spec since they are set to the target values and and back to NULL.
1423
+ // Similarly, TargetState is also set to transitioning during the call then back to open and should
1424
+ // therefore be marked as dirty.
1418
1425
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentLevel::Id));
1419
- EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentState::Id));
1420
- EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::TargetLevel::Id));
1421
- EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::TargetState::Id));
1426
+ EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentState::Id));
1427
+ EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::TargetLevel::Id));
1428
+ EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::TargetState::Id));
1422
1429
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::OpenDuration::Id));
1423
1430
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::RemainingDuration::Id));
1424
1431
@@ -1509,8 +1516,10 @@ TEST_F(TestValveConfigurationAndControlClusterLogic, TestAttributeUpdates)
1509
1516
EXPECT_EQ (logic.HandleOpenCommand (std::make_optional (openDuration), std::make_optional (requestedLevel)), CHIP_NO_ERROR);
1510
1517
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::RemainingDuration::Id));
1511
1518
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::OpenDuration::Id));
1519
+ // Current level should remain unchanged and therefore won't be marked as dirty, but the current state is unconditionally
1520
+ // set to transitioning and then back to open per the spec and therefore should be marked as dirty.
1512
1521
EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentLevel::Id));
1513
- EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentState::Id));
1522
+ EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentState::Id));
1514
1523
1515
1524
// TODO: Clarify, should we get a report if we use open to set the remaining duration down? I think so.
1516
1525
// TODO: Add such tests here. I don't think the underlying layer handles that properly right now.
@@ -1524,7 +1533,9 @@ TEST_F(TestValveConfigurationAndControlClusterLogic, TestAttributeUpdates)
1524
1533
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::RemainingDuration::Id));
1525
1534
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::OpenDuration::Id));
1526
1535
EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentLevel::Id));
1527
- EXPECT_FALSE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentState::Id));
1536
+ // Current state will also be marked dirty since every open call sets the current state to transitioning
1537
+ // unconditionally even if it is then set back to the original value.
1538
+ EXPECT_TRUE (HasAttributeChanges (context.GetDirtyList (), Attributes::CurrentState::Id));
1528
1539
1529
1540
context.ClearDirtyList ();
1530
1541
0 commit comments