1 /*
2  * Copyright (C) 2019 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 // This is a compilation test only, to see that types are generated as
18 // expected.
19 
20 #include <hidl2aidl/BnBar.h>
21 #include <hidl2aidl/BnFoo.h>
22 #include <hidl2aidl/BpBar.h>
23 #include <hidl2aidl/BpFoo.h>
24 #include <hidl2aidl/IBar.h>
25 #include <hidl2aidl/IBarInner.h>
26 #include <hidl2aidl/IFoo.h>
27 #include <hidl2aidl/IFooBigStruct.h>
28 #include <hidl2aidl/NameCollision.h>
29 #include <hidl2aidl/OnlyIn10.h>
30 #include <hidl2aidl/OnlyIn11.h>
31 #include <hidl2aidl/Outer.h>
32 #include <hidl2aidl/OuterInner.h>
33 #include <hidl2aidl/OverrideMe.h>
34 #include <hidl2aidl/Value.h>
35 #include <hidl2aidl2/BnFoo.h>
36 #include <hidl2aidl2/BpFoo.h>
37 #include <hidl2aidl2/IFoo.h>
38 
39 using android::sp;
40 using android::String16;
41 using android::binder::Status;
42 
testIFoo(const sp<hidl2aidl::IFoo> & foo)43 void testIFoo(const sp<hidl2aidl::IFoo>& foo) {
44     Status status1 = foo->someBar(String16(), String16());
45     (void)status1;
46     String16 f;
47     Status status2 = foo->oneOutput(&f);
48     (void)status2;
49     hidl2aidl::IFooBigStruct big_struct;
50     big_struct.type = 2;
51     big_struct.value = 3;
52     // Test some of the types here as well
53     hidl2aidl::Outer outer;
54     outer.inner.a = 1;
55     outer.a = 2;
56     hidl2aidl::OverrideMe override;
57     override.a = String16();
58     hidl2aidl::NameCollision collision;
59     collision.a = 1;
60     collision.b = String16();
61     collision.c = String16();
62 }
63 
testIBar(const sp<hidl2aidl::IBar> & bar)64 void testIBar(const sp<hidl2aidl::IBar>& bar) {
65     String16 out;
66     Status status1 = bar->someBar(String16(), 3, &out);
67     (void)status1;
68     hidl2aidl::IBarInner inner;
69     inner.a = 3;
70     Status status2 = bar->extraMethod(inner);
71     (void)status2;
72 }
73 
74 static_assert(static_cast<int>(hidl2aidl::Value::A) == 3);
75 static_assert(static_cast<int>(hidl2aidl::Value::B) == 7);
76 static_assert(static_cast<int>(hidl2aidl::Value::C) == 8);
77 static_assert(static_cast<int>(hidl2aidl::Value::D) == 9);
78 static_assert(static_cast<int>(hidl2aidl::Value::E) == 27);
79 static_assert(static_cast<int>(hidl2aidl::Value::F) == 28);
80 
testIFoo2(const sp<hidl2aidl2::IFoo> & foo)81 void testIFoo2(const sp<hidl2aidl2::IFoo>& foo) {
82     Status status = foo->someFoo(3);
83     (void)status;
84 }
85