• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_defaultimpl.h"
27 #include "aidl_test_client_file_descriptors.h"
28 #include "aidl_test_client_nullables.h"
29 #include "aidl_test_client_parcelables.h"
30 #include "aidl_test_client_primitives.h"
31 #include "aidl_test_client_service_exceptions.h"
32 #include "aidl_test_client_utf8_strings.h"
33 
34 // libutils:
35 using android::OK;
36 using android::sp;
37 using android::status_t;
38 using android::String16;
39 
40 // libbinder:
41 using android::getService;
42 
43 // generated
44 using android::aidl::tests::ITestService;
45 
46 using std::cerr;
47 using std::cout;
48 using std::endl;
49 
50 namespace android {
51 namespace aidl {
52 namespace tests {
53 namespace client {
54 
55 const char kServiceName[] = "android.aidl.tests.ITestService";
56 
GetService(sp<ITestService> * service)57 bool GetService(sp<ITestService>* service) {
58   cout << "Retrieving test service binder" << endl;
59   status_t status = getService(String16(kServiceName), service);
60   if (status != OK) {
61     cerr << "Failed to get service binder: '" << kServiceName
62          << "' status=" << status << endl;
63     return false;
64   }
65   return true;
66 }
67 
68 }  // namespace client
69 }  // namespace tests
70 }  // namespace aidl
71 }  // namespace android
72 
73 /* Runs all the test cases in aidl_test_client_*.cpp files. */
main(int,char * argv[])74 int main(int /* argc */, char * argv []) {
75   android::base::InitLogging(argv, android::base::StderrLogger);
76   sp<ITestService> service;
77   namespace client_tests = android::aidl::tests::client;
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::ConfirmIntfConstantExpressions(service)) return 1;
94 
95   if (!client_tests::ConfirmStructuredParcelables(service)) return 1;
96 
97   if (!client_tests::ConfirmStructuredParcelablesEquality(service)) return 1;
98 
99   if (!client_tests::ConfirmFileDescriptors(service)) return 1;
100 
101   if (!client_tests::ConfirmFileDescriptorArrays(service)) return 1;
102 
103   if (!client_tests::ConfirmParcelFileDescriptors(service)) return 1;
104 
105   if (!client_tests::ConfirmParcelFileDescriptorArrays(service)) return 1;
106 
107   if (!client_tests::ConfirmServiceSpecificExceptions(service)) return 1;
108 
109   if (!client_tests::ConfirmNullables(service)) return 1;
110 
111   if (!client_tests::ConfirmUtf8InCppStringRepeat(service)) return 1;
112 
113   if (!client_tests::ConfirmUtf8InCppStringArrayReverse(service)) return 1;
114 
115   if (!client_tests::ConfirmUtf8InCppStringListReverse(service)) return 1;
116 
117   if (!client_tests::ConfirmDefaultImpl(service)) return 1;
118 
119   return 0;
120 }
121