1 /*
2 * Copyright (C) 2020 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 <aidl/metadata.h>
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
20
21 #include <optional>
22
23 using ::android::AidlInterfaceMetadata;
24 using ::testing::ElementsAre;
25
metadataForModule(const std::string & name)26 static std::optional<AidlInterfaceMetadata> metadataForModule(const std::string& name) {
27 for (const AidlInterfaceMetadata& info : AidlInterfaceMetadata::all()) {
28 if (name == info.name) return info;
29 }
30 return std::nullopt;
31 }
32
TEST(AidlMetadata,HasTestInstances)33 TEST(AidlMetadata, HasTestInstances) {
34 const auto& info = metadataForModule("test-piece-1");
35 ASSERT_NE(info, std::nullopt);
36 EXPECT_EQ(info->stability, "");
37 EXPECT_THAT(info->types,
38 ElementsAre("some_package.IFoo", "some_package.Thing",
39 "some_package.sub_package.IFoo", "some_package.sub_package.SubThing"));
40 EXPECT_THAT(info->hashes, ElementsAre("13e24b2fac6a979971819fba2ab0d6d7c4182122",
41 "dc2a9292847e43b4360bb183f7491f0e9895eaa9",
42 "54f935920ab0934c242145cf00f9852ae3f5a63e"));
43 }
44