diff options
| author | 2024-10-02 08:10:19 +0000 | |
|---|---|---|
| committer | 2024-10-02 08:59:34 +0000 | |
| commit | 12c4ce6b908ba89d4a6a19b0403f30cc5c2561a1 (patch) | |
| tree | 7e1da25741d96c5a4434a2fc62d7160b90f32011 | |
| parent | 8072f42c35dc614749f9696762555b66696599e8 (diff) | |
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
| -rw-r--r-- | services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp b/services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp index 486d893944..157bee33e1 100644 --- a/services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp +++ b/services/inputflinger/tests/RotaryEncoderInputMapper_test.cpp @@ -103,7 +103,7 @@ protected: .WillRepeatedly(Return(false)); } - std::map<const char*, int64_t> mTelemetryLogCounts; + std::map<std::string, int64_t> mTelemetryLogCounts; /** * A fake function for telemetry logging. |