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