blob: 6d123351bd2ce779ce71dfadd6fdb6d2e82eaaf5 [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"
27#include "aidl_test_client_primitives.h"
Christopher Wileyb5e698c2015-10-17 09:32:22 -070028
29// libutils:
30using android::OK;
31using android::sp;
32using android::status_t;
33using android::String16;
34
35// libbinder:
36using android::getService;
37
38// generated
Christopher Wiley521bb612015-10-22 11:40:30 -070039using android::aidl::tests::ITestService;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070040
41using std::cerr;
42using std::cout;
43using std::endl;
44
Samuel Tan546d27d2015-12-03 15:06:01 -080045namespace android {
46namespace aidl {
47namespace tests {
48namespace client {
Christopher Wileyb5e698c2015-10-17 09:32:22 -070049
Christopher Wiley521bb612015-10-22 11:40:30 -070050const char kServiceName[] = "android.aidl.tests.ITestService";
Christopher Wileyb5e698c2015-10-17 09:32:22 -070051
Christopher Wiley521bb612015-10-22 11:40:30 -070052bool GetService(sp<ITestService>* service) {
53 cout << "Retrieving test service binder" << endl;
Christopher Wiley33ad81e2015-10-21 14:41:11 -070054 status_t status = getService(String16(kServiceName), service);
55 if (status != OK) {
56 cerr << "Failed to get service binder: '" << kServiceName
57 << "' status=" << status << endl;
58 return false;
59 }
60 return true;
61}
62
Samuel Tan546d27d2015-12-03 15:06:01 -080063} // namespace client
64} // namespace tests
65} // namespace aidl
66} // namespace android
Christopher Wileyd6130f22015-10-26 10:24:35 -070067
Samuel Tan546d27d2015-12-03 15:06:01 -080068/* Runs all the test cases in aidl_test_client_*.cpp files. */
Brian Carlstromad3b8062015-10-21 08:54:48 -070069int main(int /* argc */, char * /* argv */ []) {
Christopher Wiley521bb612015-10-22 11:40:30 -070070 sp<ITestService> service;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070071
Samuel Tan546d27d2015-12-03 15:06:01 -080072 if (!android::aidl::tests::client::GetService(&service)) return 1;
Christopher Wiley33ad81e2015-10-21 14:41:11 -070073
Samuel Tan546d27d2015-12-03 15:06:01 -080074 if (!android::aidl::tests::client::ConfirmPrimitiveRepeat(service)) return 1;
Christopher Wileyb5e698c2015-10-17 09:32:22 -070075
Samuel Tan546d27d2015-12-03 15:06:01 -080076 if (!android::aidl::tests::client::ConfirmReverseArrays(service)) return 1;
Christopher Wiley8949f832015-10-27 15:32:03 -070077
Samuel Tan546d27d2015-12-03 15:06:01 -080078 if (!android::aidl::tests::client::ConfirmReverseLists(service)) return 1;
Christopher Wiley56c9bf32015-10-30 10:41:12 -070079
Samuel Tan546d27d2015-12-03 15:06:01 -080080 if (!android::aidl::tests::client::ConfirmReverseBinderLists(service)) {
81 return 1;
82 }
Christopher Wiley95d44b02015-11-19 07:11:30 -080083
Samuel Tan546d27d2015-12-03 15:06:01 -080084 if (!android::aidl::tests::client::ConfirmParcelables(service)) return 1;
Casey Dahlin7ecd69f2015-11-03 13:52:38 -080085
Samuel Tan546d27d2015-12-03 15:06:01 -080086 if (!android::aidl::tests::client::ConfirmFileDescriptors(service)) return 1;
Casey Dahlina4ba4b62015-11-02 15:43:30 -080087
Samuel Tan546d27d2015-12-03 15:06:01 -080088 if (!android::aidl::tests::client::ConfirmFileDescriptorArrays(service)) {
89 return 1;
90 }
Casey Dahlina4ba4b62015-11-02 15:43:30 -080091
Christopher Wileyb5e698c2015-10-17 09:32:22 -070092 return 0;
93}