Skip to content

Commit 31ed684

Browse files
committed
Fix tests to account for unconditional change to target and current at open
1 parent 8d1491e commit 31ed684

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/app/tests/TestValveConfigurationAndControl.cpp

+21-10
Original file line numberDiff line numberDiff line change
@@ -1388,11 +1388,14 @@ TEST_F(TestValveConfigurationAndControlClusterLogic, TestAttributeUpdates)
13881388
EXPECT_EQ(valElapsedSNullable, DataModel::NullNullable);
13891389
EXPECT_EQ(logic.GetRemainingDuration(valElapsedSNullable), CHIP_NO_ERROR);
13901390
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).
13921395
EXPECT_TRUE(HasAttributeChanges(context.GetDirtyList(), Attributes::CurrentLevel::Id));
13931396
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));
13961399
EXPECT_FALSE(HasAttributeChanges(context.GetDirtyList(), Attributes::OpenDuration::Id));
13971400
EXPECT_FALSE(HasAttributeChanges(context.GetDirtyList(), Attributes::RemainingDuration::Id));
13981401

@@ -1413,12 +1416,16 @@ TEST_F(TestValveConfigurationAndControlClusterLogic, TestAttributeUpdates)
14131416
EXPECT_EQ(valElapsedSNullable.ValueOr(0), openDuration.Value());
14141417
EXPECT_EQ(logic.GetCurrentLevel(valPercentNullable), CHIP_NO_ERROR);
14151418
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.
14181425
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));
14221429
EXPECT_TRUE(HasAttributeChanges(context.GetDirtyList(), Attributes::OpenDuration::Id));
14231430
EXPECT_TRUE(HasAttributeChanges(context.GetDirtyList(), Attributes::RemainingDuration::Id));
14241431

@@ -1509,8 +1516,10 @@ TEST_F(TestValveConfigurationAndControlClusterLogic, TestAttributeUpdates)
15091516
EXPECT_EQ(logic.HandleOpenCommand(std::make_optional(openDuration), std::make_optional(requestedLevel)), CHIP_NO_ERROR);
15101517
EXPECT_TRUE(HasAttributeChanges(context.GetDirtyList(), Attributes::RemainingDuration::Id));
15111518
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.
15121521
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));
15141523

15151524
// TODO: Clarify, should we get a report if we use open to set the remaining duration down? I think so.
15161525
// 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)
15241533
EXPECT_TRUE(HasAttributeChanges(context.GetDirtyList(), Attributes::RemainingDuration::Id));
15251534
EXPECT_TRUE(HasAttributeChanges(context.GetDirtyList(), Attributes::OpenDuration::Id));
15261535
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));
15281539

15291540
context.ClearDirtyList();
15301541

0 commit comments

Comments
 (0)