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