Integration test for parcelables
This test demonstrates the equivalence of C++ and Java parcelable
handling from an AIDL/libbinder perspective.
Bug: 23600712
Test: These integration tests pass.
Change-Id: I49d9d9bd1baaa1c2c49b6d02a5bfeefc0a53612c
diff --git a/tests/aidl_test_client.cpp b/tests/aidl_test_client.cpp
index c3ae443..e9df4b5 100644
--- a/tests/aidl_test_client.cpp
+++ b/tests/aidl_test_client.cpp
@@ -40,6 +40,7 @@
// generated
using android::aidl::tests::ITestService;
using android::aidl::tests::INamedCallback;
+using android::aidl::tests::SimpleParcelable;
using std::cerr;
using std::cout;
@@ -170,6 +171,41 @@
return true;
}
+bool ConfirmParcelables(const sp<ITestService>& s) {
+ cout << "Confirming passing and returning Parcelables works." << endl;
+
+ SimpleParcelable input("Booya", 42);
+ SimpleParcelable out_param, returned;
+ Status status = s->RepeatParcelable(input, &out_param, &returned);
+ if (!status.isOk()) {
+ cout << "Binder call failed." << endl;
+ return false;
+ }
+ if (input != out_param || input != returned) {
+ cout << "Failed to repeat parcelables." << endl;
+ return false;
+ }
+
+ cout << "Attempting to reverse an array of parcelables." << endl;
+ const vector<SimpleParcelable> original{SimpleParcelable("first", 0),
+ SimpleParcelable("second", 1),
+ SimpleParcelable("third", 2)};
+ vector<SimpleParcelable> repeated;
+ vector<SimpleParcelable> reversed;
+ status = s->ReverseParcelables(original, &repeated, &reversed);
+ if (!status.isOk()) {
+ cout << "Binder call failed." << endl;
+ return false;
+ }
+ std::reverse(reversed.begin(), reversed.end());
+ if (repeated != original || reversed != original) {
+ cout << "Failed to reverse an array of parcelables." << endl;
+ return false;
+ }
+
+ return true;
+}
+
bool ConfirmReverseBinderLists(const sp<ITestService>& s) {
Status status;
cout << "Confirming passing and returning List<T> works with binders." << endl;
@@ -261,6 +297,8 @@
if (!ConfirmReverseLists(service)) return 1;
+ if (!ConfirmParcelables(service)) return 1;
+
if (!ConfirmReverseBinderLists(service)) return 1;
return 0;