| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 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 <binder/IServiceManager.h> |
| 20 | #include <utils/String16.h> |
| 21 | #include <utils/StrongPointer.h> |
| 22 | |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 23 | #include "android/aidl/tests/ITestService.h" |
| Samuel Tan | 546d27d | 2015-12-03 15:06:01 -0800 | [diff] [blame] | 24 | |
| 25 | #include "aidl_test_client_file_descriptors.h" |
| 26 | #include "aidl_test_client_parcelables.h" |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame] | 27 | #include "aidl_test_client_service_exceptions.h" |
| Samuel Tan | 546d27d | 2015-12-03 15:06:01 -0800 | [diff] [blame] | 28 | #include "aidl_test_client_primitives.h" |
| Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 29 | #include "aidl_test_client_nullables.h" |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 30 | |
| 31 | // libutils: |
| 32 | using android::OK; |
| 33 | using android::sp; |
| 34 | using android::status_t; |
| 35 | using android::String16; |
| 36 | |
| 37 | // libbinder: |
| 38 | using android::getService; |
| 39 | |
| 40 | // generated |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 41 | using android::aidl::tests::ITestService; |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 42 | |
| 43 | using std::cerr; |
| 44 | using std::cout; |
| 45 | using std::endl; |
| 46 | |
| Samuel Tan | 546d27d | 2015-12-03 15:06:01 -0800 | [diff] [blame] | 47 | namespace android { |
| 48 | namespace aidl { |
| 49 | namespace tests { |
| 50 | namespace client { |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 51 | |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 52 | const char kServiceName[] = "android.aidl.tests.ITestService"; |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 53 | |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 54 | bool GetService(sp<ITestService>* service) { |
| 55 | cout << "Retrieving test service binder" << endl; |
| Christopher Wiley | 33ad81e | 2015-10-21 14:41:11 -0700 | [diff] [blame] | 56 | status_t status = getService(String16(kServiceName), service); |
| 57 | if (status != OK) { |
| 58 | cerr << "Failed to get service binder: '" << kServiceName |
| 59 | << "' status=" << status << endl; |
| 60 | return false; |
| 61 | } |
| 62 | return true; |
| 63 | } |
| 64 | |
| Samuel Tan | 546d27d | 2015-12-03 15:06:01 -0800 | [diff] [blame] | 65 | } // namespace client |
| 66 | } // namespace tests |
| 67 | } // namespace aidl |
| 68 | } // namespace android |
| Christopher Wiley | d6130f2 | 2015-10-26 10:24:35 -0700 | [diff] [blame] | 69 | |
| Samuel Tan | 546d27d | 2015-12-03 15:06:01 -0800 | [diff] [blame] | 70 | /* Runs all the test cases in aidl_test_client_*.cpp files. */ |
| Brian Carlstrom | ad3b806 | 2015-10-21 08:54:48 -0700 | [diff] [blame] | 71 | int main(int /* argc */, char * /* argv */ []) { |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 72 | sp<ITestService> service; |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame] | 73 | namespace client_tests = android::aidl::tests::client; |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 74 | |
| Christopher Wiley | 33ad81e | 2015-10-21 14:41:11 -0700 | [diff] [blame] | 75 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame] | 76 | if (!client_tests::GetService(&service)) return 1; |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 77 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame] | 78 | if (!client_tests::ConfirmPrimitiveRepeat(service)) return 1; |
| Christopher Wiley | 8949f83 | 2015-10-27 15:32:03 -0700 | [diff] [blame] | 79 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame] | 80 | if (!client_tests::ConfirmReverseArrays(service)) return 1; |
| Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 81 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame] | 82 | if (!client_tests::ConfirmReverseLists(service)) return 1; |
| Christopher Wiley | 95d44b0 | 2015-11-19 07:11:30 -0800 | [diff] [blame] | 83 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame] | 84 | if (!client_tests::ConfirmReverseBinderLists(service)) return 1; |
| Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 85 | |
| Samuel Tan | 88c3200 | 2015-12-03 16:30:43 -0800 | [diff] [blame] | 86 | if (!client_tests::ConfirmSimpleParcelables(service)) return 1; |
| 87 | |
| 88 | if (!client_tests::ConfirmPersistableBundles(service)) return 1; |
| Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 89 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame] | 90 | if (!client_tests::ConfirmFileDescriptors(service)) return 1; |
| 91 | |
| 92 | if (!client_tests::ConfirmFileDescriptorArrays(service)) return 1; |
| 93 | |
| 94 | if (!client_tests::ConfirmServiceSpecificExceptions(service)) return 1; |
| Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 95 | |
| Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 96 | if (!android::aidl::tests::client::ConfirmNullables(service)) return 1; |
| 97 | |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 98 | return 0; |
| 99 | } |