1/*
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 <android-base/logging.h>
20#include <binder/IServiceManager.h>
21#include <utils/String16.h>
22#include <utils/StrongPointer.h>
23
24#include "android/aidl/tests/ITestService.h"
25
26#include "aidl_test_client_file_descriptors.h"
27#include "aidl_test_client_nullables.h"
28#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"
32
33// libutils:
34using android::OK;
35using android::sp;
36using android::status_t;
37using android::String16;
38
39// libbinder:
40using android::getService;
41
42// generated
43using android::aidl::tests::ITestService;
44
45using std::cerr;
46using std::cout;
47using std::endl;
48
49namespace android {
50namespace aidl {
51namespace tests {
52namespace client {
53
54const char kServiceName[] = "android.aidl.tests.ITestService";
55
56bool GetService(sp<ITestService>* service) {
57  cout << "Retrieving test service binder" << endl;
58  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
67}  // namespace client
68}  // namespace tests
69}  // namespace aidl
70}  // namespace android
71
72/* Runs all the test cases in aidl_test_client_*.cpp files. */
73int main(int /* argc */, char * argv []) {
74  android::base::InitLogging(argv, android::base::StderrLogger);
75  sp<ITestService> service;
76  namespace client_tests = android::aidl::tests::client;
77
78
79  if (!client_tests::GetService(&service)) return 1;
80
81  if (!client_tests::ConfirmPrimitiveRepeat(service)) return 1;
82
83  if (!client_tests::ConfirmReverseArrays(service)) return 1;
84
85  if (!client_tests::ConfirmReverseLists(service)) return 1;
86
87  if (!client_tests::ConfirmReverseBinderLists(service)) return 1;
88
89  if (!client_tests::ConfirmSimpleParcelables(service)) return 1;
90
91  if (!client_tests::ConfirmPersistableBundles(service)) return 1;
92
93  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;
98
99  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;
104
105  if (!client_tests::ConfirmUtf8InCppStringListReverse(service)) return 1;
106
107  return 0;
108}
109