blob: af4312ba3b3553bc8b6ea5755f5dfda448259cdf [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
Christopher Wileydca2ecf2016-01-29 10:55:43 -080019#include <android-base/logging.h>
Christopher Wileyb5e698c2015-10-17 09:32:22 -070020#include <binder/IServiceManager.h>
21#include <utils/String16.h>
22#include <utils/StrongPointer.h>
23
Christopher Wiley521bb612015-10-22 11:40:30 -070024#include "android/aidl/tests/ITestService.h"
Samuel Tan546d27d2015-12-03 15:06:01 -080025
26#include "aidl_test_client_file_descriptors.h"
Casey Dahlin57dbe242015-12-04 11:44:02 -080027#include "aidl_test_client_nullables.h"
Christopher Wileydca2ecf2016-01-29 10:55:43 -080028#include "aidl_test_client_parcelables.h"
29#include "aidl_test_client_primitives.h"
30#include "aidl_test_client_service_exceptions.h"
31#include "aidl_test_client_utf8_strings.h"
Christopher Wileyb5e698c2015-10-17 09:32:22 -070032
33// libutils:
34using android::OK;
35using android::sp;
36using android::status_t;
37using android::String16;
38
39// libbinder:
40using android::getService;
41
42// generated
Christopher Wiley521bb612015-10-22 11:40:30 -070043using android::aidl::tests::ITestService;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070044
45using std::cerr;
46using std::cout;
47using std::endl;
48
Samuel Tan546d27d2015-12-03 15:06:01 -080049namespace android {
50namespace aidl {
51namespace tests {
52namespace client {
Christopher Wileyb5e698c2015-10-17 09:32:22 -070053
Christopher Wiley521bb612015-10-22 11:40:30 -070054const char kServiceName[] = "android.aidl.tests.ITestService";
Christopher Wileyb5e698c2015-10-17 09:32:22 -070055
Christopher Wiley521bb612015-10-22 11:40:30 -070056bool GetService(sp<ITestService>* service) {
57 cout << "Retrieving test service binder" << endl;
Christopher Wiley33ad81e2015-10-21 14:41:11 -070058 status_t status = getService(String16(kServiceName), service);
59 if (status != OK) {
60 cerr << "Failed to get service binder: '" << kServiceName
61 << "' status=" << status << endl;
62 return false;
63 }
64 return true;
65}
66
Samuel Tan546d27d2015-12-03 15:06:01 -080067} // namespace client
68} // namespace tests
69} // namespace aidl
70} // namespace android
Christopher Wileyd6130f22015-10-26 10:24:35 -070071
Samuel Tan546d27d2015-12-03 15:06:01 -080072/* Runs all the test cases in aidl_test_client_*.cpp files. */
Christopher Wileydca2ecf2016-01-29 10:55:43 -080073int main(int /* argc */, char * argv []) {
74 android::base::InitLogging(argv, android::base::StderrLogger);
Christopher Wiley521bb612015-10-22 11:40:30 -070075 sp<ITestService> service;
Christopher Wiley7621d4d2015-11-28 16:58:06 -080076 namespace client_tests = android::aidl::tests::client;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070077
Christopher Wiley33ad81e2015-10-21 14:41:11 -070078
Christopher Wiley7621d4d2015-11-28 16:58:06 -080079 if (!client_tests::GetService(&service)) return 1;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070080
Christopher Wiley7621d4d2015-11-28 16:58:06 -080081 if (!client_tests::ConfirmPrimitiveRepeat(service)) return 1;
Christopher Wiley8949f832015-10-27 15:32:03 -070082
Christopher Wiley7621d4d2015-11-28 16:58:06 -080083 if (!client_tests::ConfirmReverseArrays(service)) return 1;
Christopher Wiley56c9bf32015-10-30 10:41:12 -070084
Christopher Wiley7621d4d2015-11-28 16:58:06 -080085 if (!client_tests::ConfirmReverseLists(service)) return 1;
Christopher Wiley95d44b02015-11-19 07:11:30 -080086
Christopher Wiley7621d4d2015-11-28 16:58:06 -080087 if (!client_tests::ConfirmReverseBinderLists(service)) return 1;
Casey Dahlin7ecd69f2015-11-03 13:52:38 -080088
Samuel Tan88c32002015-12-03 16:30:43 -080089 if (!client_tests::ConfirmSimpleParcelables(service)) return 1;
90
91 if (!client_tests::ConfirmPersistableBundles(service)) return 1;
Casey Dahlina4ba4b62015-11-02 15:43:30 -080092
Christopher Wiley7621d4d2015-11-28 16:58:06 -080093 if (!client_tests::ConfirmFileDescriptors(service)) return 1;
94
95 if (!client_tests::ConfirmFileDescriptorArrays(service)) return 1;
96
97 if (!client_tests::ConfirmServiceSpecificExceptions(service)) return 1;
Casey Dahlina4ba4b62015-11-02 15:43:30 -080098
Christopher Wileydca2ecf2016-01-29 10:55:43 -080099 if (!client_tests::ConfirmNullables(service)) return 1;
100
101 if (!client_tests::ConfirmUtf8InCppStringRepeat(service)) return 1;
102
103 if (!client_tests::ConfirmUtf8InCppStringArrayReverse(service)) return 1;
Casey Dahlin57dbe242015-12-04 11:44:02 -0800104
Christopher Wileyb5e698c2015-10-17 09:32:22 -0700105 return 0;
106}