@@ -101,6 +101,11 @@ struct AttributeInstruction
101
101
}
102
102
}
103
103
104
+ ConcreteAttributePath GetAttributePath () const
105
+ {
106
+ return ConcreteAttributePath (mEndpointId , Clusters::UnitTesting::Id, GetAttributeId ());
107
+ }
108
+
104
109
static uint8_t sInstructionId ;
105
110
};
106
111
@@ -626,6 +631,94 @@ void RunAndValidateSequence(AttributeInstructionListType list)
626
631
627
632
++bufferSize;
628
633
} while (true );
634
+
635
+ // Now check clearing behavior. First for attributes.
636
+ ConcreteAttributePath firstAttr = list[0 ].GetAttributePath ();
637
+
638
+ TLV::TLVReader reader;
639
+ CHIP_ERROR err = cache.Get (firstAttr, reader);
640
+ // Should have gotten a value or status for now.
641
+ EXPECT_NE (err, CHIP_ERROR_KEY_NOT_FOUND);
642
+
643
+ cache.ClearAttribute (firstAttr);
644
+
645
+ err = cache.Get (firstAttr, reader);
646
+ // Should have gotten no value.
647
+ EXPECT_EQ (err, CHIP_ERROR_KEY_NOT_FOUND);
648
+
649
+ // Now clearing for clusters. First check that things that should be there are.
650
+ for (auto & listItem : list)
651
+ {
652
+ ConcreteAttributePath path = listItem.GetAttributePath ();
653
+ if (path == firstAttr)
654
+ {
655
+ // We removed this one already.
656
+ continue ;
657
+ }
658
+
659
+ err = cache.Get (path, reader);
660
+
661
+ // Should have gotten a value or status for now.
662
+ EXPECT_NE (err, CHIP_ERROR_KEY_NOT_FOUND);
663
+ }
664
+
665
+ auto firstCluster = ConcreteClusterPath (firstAttr);
666
+ cache.ClearAttributes (firstCluster);
667
+
668
+ for (auto & listItem : list)
669
+ {
670
+ ConcreteAttributePath path = listItem.GetAttributePath ();
671
+
672
+ err = cache.Get (path, reader);
673
+
674
+ if (ConcreteClusterPath (path) == firstCluster)
675
+ {
676
+ EXPECT_EQ (err, CHIP_ERROR_KEY_NOT_FOUND);
677
+ }
678
+ else
679
+ {
680
+ // Should still have a value or status
681
+ EXPECT_NE (err, CHIP_ERROR_KEY_NOT_FOUND);
682
+ }
683
+ }
684
+
685
+ // Now clearing for endpoints. First check that things that should be there are.
686
+ // TODO: Since all our attributes have the same cluster, this is not
687
+ // actually testing anything useful right now.
688
+ for (auto & listItem : list)
689
+ {
690
+ ConcreteAttributePath path = listItem.GetAttributePath ();
691
+ if (ConcreteClusterPath (path) == firstCluster)
692
+ {
693
+ // We removed this one already.
694
+ continue ;
695
+ }
696
+
697
+ err = cache.Get (path, reader);
698
+
699
+ // Should have gotten a value or status for now.
700
+ EXPECT_NE (err, CHIP_ERROR_KEY_NOT_FOUND);
701
+ }
702
+
703
+ auto firstEndpoint = firstAttr.mEndpointId ;
704
+ cache.ClearAttributes (firstEndpoint);
705
+
706
+ for (auto & listItem : list)
707
+ {
708
+ ConcreteAttributePath path = listItem.GetAttributePath ();
709
+
710
+ err = cache.Get (path, reader);
711
+
712
+ if (path.mEndpointId == firstEndpoint)
713
+ {
714
+ EXPECT_EQ (err, CHIP_ERROR_KEY_NOT_FOUND);
715
+ }
716
+ else
717
+ {
718
+ // Should still have a value or status
719
+ EXPECT_NE (err, CHIP_ERROR_KEY_NOT_FOUND);
720
+ }
721
+ }
629
722
}
630
723
631
724
/*
0 commit comments