blob: 8236902b8296c69acf83f3cb94811571c24d311b [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"
Christopher Wileyb5e698c2015-10-17 09:32:22 -070029
30// libutils:
31using android::OK;
32using android::sp;
33using android::status_t;
34using android::String16;
35
36// libbinder:
37using android::getService;
38
39// generated
Christopher Wiley521bb612015-10-22 11:40:30 -070040using android::aidl::tests::ITestService;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070041
42using std::cerr;
43using std::cout;
44using std::endl;
45
Samuel Tan546d27d2015-12-03 15:06:01 -080046namespace android {
47namespace aidl {
48namespace tests {
49namespace client {
Christopher Wileyb5e698c2015-10-17 09:32:22 -070050
Christopher Wiley521bb612015-10-22 11:40:30 -070051const char kServiceName[] = "android.aidl.tests.ITestService";
Christopher Wileyb5e698c2015-10-17 09:32:22 -070052
Christopher Wiley521bb612015-10-22 11:40:30 -070053bool GetService(sp<ITestService>* service) {
54 cout << "Retrieving test service binder" << endl;
Christopher Wiley33ad81e2015-10-21 14:41:11 -070055 status_t status = getService(String16(kServiceName), service);
56 if (status != OK) {
57 cerr << "Failed to get service binder: '" << kServiceName
58 << "' status=" << status << endl;
59 return false;
60 }
61 return true;
62}
63
Samuel Tan546d27d2015-12-03 15:06:01 -080064} // namespace client
65} // namespace tests
66} // namespace aidl
67} // namespace android
Christopher Wileyd6130f22015-10-26 10:24:35 -070068
Samuel Tan546d27d2015-12-03 15:06:01 -080069/* Runs all the test cases in aidl_test_client_*.cpp files. */
Brian Carlstromad3b8062015-10-21 08:54:48 -070070int main(int /* argc */, char * /* argv */ []) {
Christopher Wiley521bb612015-10-22 11:40:30 -070071 sp<ITestService> service;
Christopher Wiley7621d4d2015-11-28 16:58:06 -080072 namespace client_tests = android::aidl::tests::client;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070073
Christopher Wiley33ad81e2015-10-21 14:41:11 -070074
Christopher Wiley7621d4d2015-11-28 16:58:06 -080075 if (!client_tests::GetService(&service)) return 1;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070076
Christopher Wiley7621d4d2015-11-28 16:58:06 -080077 if (!client_tests::ConfirmPrimitiveRepeat(service)) return 1;
Christopher Wiley8949f832015-10-27 15:32:03 -070078
Christopher Wiley7621d4d2015-11-28 16:58:06 -080079 if (!client_tests::ConfirmReverseArrays(service)) return 1;
Christopher Wiley56c9bf32015-10-30 10:41:12 -070080
Christopher Wiley7621d4d2015-11-28 16:58:06 -080081 if (!client_tests::ConfirmReverseLists(service)) return 1;
Christopher Wiley95d44b02015-11-19 07:11:30 -080082
Christopher Wiley7621d4d2015-11-28 16:58:06 -080083 if (!client_tests::ConfirmReverseBinderLists(service)) return 1;
Casey Dahlin7ecd69f2015-11-03 13:52:38 -080084
Christopher Wiley7621d4d2015-11-28 16:58:06 -080085 if (!client_tests::ConfirmParcelables(service)) return 1;
Casey Dahlina4ba4b62015-11-02 15:43:30 -080086
Christopher Wiley7621d4d2015-11-28 16:58:06 -080087 if (!client_tests::ConfirmFileDescriptors(service)) return 1;
88
89 if (!client_tests::ConfirmFileDescriptorArrays(service)) return 1;
90
91 if (!client_tests::ConfirmServiceSpecificExceptions(service)) return 1;
Casey Dahlina4ba4b62015-11-02 15:43:30 -080092
Christopher Wileyb5e698c2015-10-17 09:32:22 -070093 return 0;
94}