Changed UsageTableHeader::Shrink to tolerate over shrinking.
[ Merge of http://go/wvgerrit/83804 ] There is a private helper method in `UsageTableHeader` which is used by other methods to shrink the table by removing a specified number of entries. Prior to this change, if `Shrink` was called to remove more entries than there are, it would: 1) do nothing and 2) return `NO_ERROR`. Obviously, at least one of those action should change. Instead of doing nothing, it will simply remove all the entries from the table and return `NO_ERROR`. A warning will be logged that it was requested to shrink by more entries than there are. Four (4) new tests have been created to ensure that `Shrink()` works as expected. Test: Linux unit tests Bug: 138242127 Change-Id: Idedd922bd883d7ae1b84ce8ec1255fdce00c0948
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
#include "metrics_collections.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
#if defined(UNIT_TEST)
|
||||
# include <gtest/gtest_prod.h>
|
||||
#endif
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
// Offline licenses/secure stops may be securely tracked using usage
|
||||
@@ -133,8 +137,14 @@ class UsageTableHeader {
|
||||
|
||||
metrics::CryptoMetrics alternate_crypto_metrics_;
|
||||
|
||||
#if defined(UNIT_TEST)
|
||||
// Test related declarations
|
||||
friend class UsageTableHeaderTest;
|
||||
FRIEND_TEST(UsageTableHeaderTest, Shrink_NoneOfTable);
|
||||
FRIEND_TEST(UsageTableHeaderTest, Shrink_PartOfTable);
|
||||
FRIEND_TEST(UsageTableHeaderTest, Shrink_AllOfTable);
|
||||
FRIEND_TEST(UsageTableHeaderTest, Shrink_MoreThanTable);
|
||||
#endif
|
||||
|
||||
// These setters are for testing only. Takes ownership of the pointers.
|
||||
void SetDeviceFiles(DeviceFiles* device_files) {
|
||||
|
||||
Reference in New Issue
Block a user