blob: 0663f2c25fa29d67009720964b7f8a0d0814291e [file] [log] [blame]
Christopher Wileyb5e698c2015-10-17 09:32:22 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <iostream>
18
19#include <binder/IServiceManager.h>
20#include <utils/String16.h>
21#include <utils/StrongPointer.h>
22
Christopher Wiley521bb612015-10-22 11:40:30 -070023#include "android/aidl/tests/ITestService.h"
Samuel Tan546d27d2015-12-03 15:06:01 -080024
25#include "aidl_test_client_file_descriptors.h"
26#include "aidl_test_client_parcelables.h"
Christopher Wiley7621d4d2015-11-28 16:58:06 -080027#include "aidl_test_client_service_exceptions.h"
Samuel Tan546d27d2015-12-03 15:06:01 -080028#include "aidl_test_client_primitives.h"
Casey Dahlin57dbe242015-12-04 11:44:02 -080029#include "aidl_test_client_nullables.h"
Christopher Wileyb5e698c2015-10-17 09:32:22 -070030
31// libutils:
32using android::OK;
33using android::sp;
34using android::status_t;
35using android::String16;
36
37// libbinder:
38using android::getService;
39
40// generated
Christopher Wiley521bb612015-10-22 11:40:30 -070041using android::aidl::tests::ITestService;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070042
43using std::cerr;
44using std::cout;
45using std::endl;
46
Samuel Tan546d27d2015-12-03 15:06:01 -080047namespace android {
48namespace aidl {
49namespace tests {
50namespace client {
Christopher Wileyb5e698c2015-10-17 09:32:22 -070051
Christopher Wiley521bb612015-10-22 11:40:30 -070052const char kServiceName[] = "android.aidl.tests.ITestService";
Christopher Wileyb5e698c2015-10-17 09:32:22 -070053
Christopher Wiley521bb612015-10-22 11:40:30 -070054bool GetService(sp<ITestService>* service) {
55 cout << "Retrieving test service binder" << endl;
Christopher Wiley33ad81e2015-10-21 14:41:11 -070056 status_t status = getService(String16(kServiceName), service);
57 if (status != OK) {
58 cerr << "Failed to get service binder: '" << kServiceName
59 << "' status=" << status << endl;
60 return false;
61 }
62 return true;
63}
64
Samuel Tan546d27d2015-12-03 15:06:01 -080065} // namespace client
66} // namespace tests
67} // namespace aidl
68} // namespace android
Christopher Wileyd6130f22015-10-26 10:24:35 -070069
Samuel Tan546d27d2015-12-03 15:06:01 -080070/* Runs all the test cases in aidl_test_client_*.cpp files. */
Brian Carlstromad3b8062015-10-21 08:54:48 -070071int main(int /* argc */, char * /* argv */ []) {
Christopher Wiley521bb612015-10-22 11:40:30 -070072 sp<ITestService> service;
Christopher Wiley7621d4d2015-11-28 16:58:06 -080073 namespace client_tests = android::aidl::tests::client;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070074
Christopher Wiley33ad81e2015-10-21 14:41:11 -070075
Christopher Wiley7621d4d2015-11-28 16:58:06 -080076 if (!client_tests::GetService(&service)) return 1;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070077
Christopher Wiley7621d4d2015-11-28 16:58:06 -080078 if (!client_tests::ConfirmPrimitiveRepeat(service)) return 1;
Christopher Wiley8949f832015-10-27 15:32:03 -070079
Christopher Wiley7621d4d2015-11-28 16:58:06 -080080 if (!client_tests::ConfirmReverseArrays(service)) return 1;
Christopher Wiley56c9bf32015-10-30 10:41:12 -070081
Christopher Wiley7621d4d2015-11-28 16:58:06 -080082 if (!client_tests::ConfirmReverseLists(service)) return 1;
Christopher Wiley95d44b02015-11-19 07:11:30 -080083
Christopher Wiley7621d4d2015-11-28 16:58:06 -080084 if (!client_tests::ConfirmReverseBinderLists(service)) return 1;
Casey Dahlin7ecd69f2015-11-03 13:52:38 -080085
Samuel Tan88c32002015-12-03 16:30:43 -080086 if (!client_tests::ConfirmSimpleParcelables(service)) return 1;
87
88 if (!client_tests::ConfirmPersistableBundles(service)) return 1;
Casey Dahlina4ba4b62015-11-02 15:43:30 -080089
Christopher Wiley7621d4d2015-11-28 16:58:06 -080090 if (!client_tests::ConfirmFileDescriptors(service)) return 1;
91
92 if (!client_tests::ConfirmFileDescriptorArrays(service)) return 1;
93
94 if (!client_tests::ConfirmServiceSpecificExceptions(service)) return 1;
Casey Dahlina4ba4b62015-11-02 15:43:30 -080095
Casey Dahlin57dbe242015-12-04 11:44:02 -080096 if (!android::aidl::tests::client::ConfirmNullables(service)) return 1;
97
Christopher Wileyb5e698c2015-10-17 09:32:22 -070098 return 0;
99}