Use std::string for test expresslog std::map
In ag/29575518, we wrapped expresslog Counter calls with an std::function to help with testing. In the tests, we used a map, with the key being the Counter key as a char*, and the value being the aggregated count.
This approach caused test failures when we try to enable the flag in trunk_staging. After investigation, we realized that this is caused because the key of the std::map is the literal pointer (char*), meaning that the same string literals may be counted as different std::map keys in the test map.
To mitigate this, we're now using std::string as the test map key type instead. Because the hash/equality of std::string depend on the string's content (instead of the pointer), the test issues are expected to resolve.
Bug: 370353565
Test: atest RotaryEncoderInputMapperTest
Flag: com.android.input.flags.rotary_input_telemetry
Change-Id: Ibc89aeaf96e4627876929b76fe40b4a4a535b3df
diff --git a/services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp b/services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp
index 486d893..157bee3 100644
--- a/services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp
+++ b/services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp
@@ -103,7 +103,7 @@
.WillRepeatedly(Return(false));
}
- std::map<const char*, int64_t> mTelemetryLogCounts;
+ std::map<std::string, int64_t> mTelemetryLogCounts;
/**
* A fake function for telemetry logging.