Adding primitive types to binderRecordReplayTest

Adding AIDL supported primitive types to record replay test

Test: m binderRecordReplayTest && adb sync data && adb shell /data/nativetest64/binderRecordReplayTest/binderRecordReplayTest
Bug: 279646634
Change-Id: If163fe2a8a4e66794cf09e57db98000507811b94
diff --git a/libs/binder/tests/IBinderRecordReplayTest.aidl b/libs/binder/tests/IBinderRecordReplayTest.aidl
index 3c8c722..2497277 100644
--- a/libs/binder/tests/IBinderRecordReplayTest.aidl
+++ b/libs/binder/tests/IBinderRecordReplayTest.aidl
@@ -15,6 +15,24 @@
  */
 
 interface IBinderRecordReplayTest {
+    void setByte(byte input);
+    byte getByte();
+
+    void setChar(char input);
+    char getChar();
+
+    void setBoolean(boolean input);
+    boolean getBoolean();
+
     void setInt(int input);
     int getInt();
+
+    void setFloat(float input);
+    float getFloat();
+
+    void setLong(long input);
+    long getLong();
+
+    void setDouble(double input);
+    double getDouble();
 }
diff --git a/libs/binder/tests/binderRecordReplayTest.cpp b/libs/binder/tests/binderRecordReplayTest.cpp
index fac74aa..599889c 100644
--- a/libs/binder/tests/binderRecordReplayTest.cpp
+++ b/libs/binder/tests/binderRecordReplayTest.cpp
@@ -33,19 +33,27 @@
 
 const String16 kServerName = String16("binderRecordReplay");
 
+#define GENERATE_GETTER_SETTER(name, T) \
+    Status set##name(T input) {         \
+        m##name = input;                \
+        return Status::ok();            \
+    }                                   \
+                                        \
+    Status get##name(T* output) {       \
+        *output = m##name;              \
+        return Status::ok();            \
+    }                                   \
+    T m##name
+
 class MyRecordReplay : public BnBinderRecordReplayTest {
 public:
-    Status setInt(int input) {
-        mInt = input;
-        return Status::ok();
-    }
-    Status getInt(int* output) {
-        *output = mInt;
-        return Status::ok();
-    }
-
-private:
-    int mInt = 0;
+    GENERATE_GETTER_SETTER(Boolean, bool);
+    GENERATE_GETTER_SETTER(Byte, int8_t);
+    GENERATE_GETTER_SETTER(Int, int);
+    GENERATE_GETTER_SETTER(Char, char16_t);
+    GENERATE_GETTER_SETTER(Long, int64_t);
+    GENERATE_GETTER_SETTER(Float, float);
+    GENERATE_GETTER_SETTER(Double, double);
 };
 
 class BinderClearBuf : public ::testing::Test {
@@ -60,8 +68,8 @@
     }
 
     template <typename T>
-    void DoTest(Status (IBinderRecordReplayTest::*set)(T), T recordedValue,
-                Status (IBinderRecordReplayTest::*get)(T*), T changedValue) {
+    void recordReplay(Status (IBinderRecordReplayTest::*set)(T), T recordedValue,
+                      Status (IBinderRecordReplayTest::*get)(T*), T changedValue) {
         base::unique_fd fd(open("/data/local/tmp/binderRecordReplayTest.rec",
                                 O_RDWR | O_CREAT | O_CLOEXEC, 0666));
         ASSERT_TRUE(fd.ok());
@@ -112,8 +120,38 @@
     sp<IBinderRecordReplayTest> mInterface;
 };
 
+TEST_F(BinderClearBuf, RecordReplayRepeatByte) {
+    recordReplay(&IBinderRecordReplayTest::setByte, int8_t{122}, &IBinderRecordReplayTest::getByte,
+                 int8_t{90});
+}
+
+TEST_F(BinderClearBuf, RecordReplayRepeatBoolean) {
+    recordReplay(&IBinderRecordReplayTest::setBoolean, true, &IBinderRecordReplayTest::getBoolean,
+                 false);
+}
+
+TEST_F(BinderClearBuf, RecordReplayRepeatChar) {
+    recordReplay(&IBinderRecordReplayTest::setChar, char16_t{'G'},
+                 &IBinderRecordReplayTest::getChar, char16_t{'K'});
+}
+
 TEST_F(BinderClearBuf, RecordReplayRepeatInt) {
-    DoTest(&IBinderRecordReplayTest::setInt, 3, &IBinderRecordReplayTest::getInt, 5);
+    recordReplay(&IBinderRecordReplayTest::setInt, 3, &IBinderRecordReplayTest::getInt, 5);
+}
+
+TEST_F(BinderClearBuf, RecordReplayRepeatFloat) {
+    recordReplay(&IBinderRecordReplayTest::setFloat, 1.1f, &IBinderRecordReplayTest::getFloat,
+                 22.0f);
+}
+
+TEST_F(BinderClearBuf, RecordReplayRepeatLong) {
+    recordReplay(&IBinderRecordReplayTest::setLong, int64_t{1LL << 55},
+                 &IBinderRecordReplayTest::getLong, int64_t{1LL << 12});
+}
+
+TEST_F(BinderClearBuf, RecordReplayRepeatDouble) {
+    recordReplay(&IBinderRecordReplayTest::setDouble, 0.00, &IBinderRecordReplayTest::getDouble,
+                 1.11);
 }
 
 int main(int argc, char** argv) {