| 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" |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 29 | |
| 30 | // libutils: |
| 31 | using android::OK; |
| 32 | using android::sp; |
| 33 | using android::status_t; |
| 34 | using android::String16; |
| 35 | |
| 36 | // libbinder: |
| 37 | using android::getService; |
| 38 | |
| 39 | // generated |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 40 | using android::aidl::tests::ITestService; |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 41 | |
| 42 | using std::cerr; |
| 43 | using std::cout; |
| 44 | using std::endl; |
| 45 | |
| Samuel Tan | 546d27d | 2015-12-03 15:06:01 -0800 | [diff] [blame] | 46 | namespace android { |
| 47 | namespace aidl { |
| 48 | namespace tests { |
| 49 | namespace client { |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 50 | |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 51 | const char kServiceName[] = "android.aidl.tests.ITestService"; |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 52 | |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 53 | bool GetService(sp<ITestService>* service) { |
| 54 | cout << "Retrieving test service binder" << endl; |
| Christopher Wiley | 33ad81e | 2015-10-21 14:41:11 -0700 | [diff] [blame] | 55 | 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 Tan | 546d27d | 2015-12-03 15:06:01 -0800 | [diff] [blame] | 64 | } // namespace client |
| 65 | } // namespace tests |
| 66 | } // namespace aidl |
| 67 | } // namespace android |
| Christopher Wiley | d6130f2 | 2015-10-26 10:24:35 -0700 | [diff] [blame] | 68 | |
| Samuel Tan | 546d27d | 2015-12-03 15:06:01 -0800 | [diff] [blame] | 69 | /* Runs all the test cases in aidl_test_client_*.cpp files. */ |
| Brian Carlstrom | ad3b806 | 2015-10-21 08:54:48 -0700 | [diff] [blame] | 70 | int main(int /* argc */, char * /* argv */ []) { |
| Christopher Wiley | 521bb61 | 2015-10-22 11:40:30 -0700 | [diff] [blame] | 71 | sp<ITestService> service; |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame^] | 72 | namespace client_tests = android::aidl::tests::client; |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 73 | |
| Christopher Wiley | 33ad81e | 2015-10-21 14:41:11 -0700 | [diff] [blame] | 74 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame^] | 75 | if (!client_tests::GetService(&service)) return 1; |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 76 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame^] | 77 | if (!client_tests::ConfirmPrimitiveRepeat(service)) return 1; |
| Christopher Wiley | 8949f83 | 2015-10-27 15:32:03 -0700 | [diff] [blame] | 78 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame^] | 79 | if (!client_tests::ConfirmReverseArrays(service)) return 1; |
| Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 80 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame^] | 81 | if (!client_tests::ConfirmReverseLists(service)) return 1; |
| Christopher Wiley | 95d44b0 | 2015-11-19 07:11:30 -0800 | [diff] [blame] | 82 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame^] | 83 | if (!client_tests::ConfirmReverseBinderLists(service)) return 1; |
| Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 84 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame^] | 85 | if (!client_tests::ConfirmParcelables(service)) return 1; |
| Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 86 | |
| Christopher Wiley | 7621d4d | 2015-11-28 16:58:06 -0800 | [diff] [blame^] | 87 | 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 Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 92 | |
| Christopher Wiley | b5e698c | 2015-10-17 09:32:22 -0700 | [diff] [blame] | 93 | return 0; |
| 94 | } |