1 /*
2 * Copyright (C) 2018 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 "DeviceManifestTest.h"
18
19 #include <android-base/result.h>
20 #include <libvts_vintf_test_common/common.h>
21 #include <vintf/VintfObject.h>
22
23 #include "SingleManifestTest.h"
24
25 namespace android {
26 namespace vintf {
27 namespace testing {
28
SetUp()29 void DeviceManifestTest::SetUp() {
30 VtsTrebleVintfTestBase::SetUp();
31
32 vendor_manifest_ = VintfObject::GetDeviceHalManifest();
33 ASSERT_NE(vendor_manifest_, nullptr)
34 << "Failed to get vendor HAL manifest." << endl;
35 }
36
37 // Tests that Shipping FCM Version in the device manifest is at least the
38 // minimum Shipping FCM Version as required by Shipping API level.
TEST_F(DeviceManifestTest,ShippingFcmVersion)39 TEST_F(DeviceManifestTest, ShippingFcmVersion) {
40 uint64_t shipping_api_level = GetShippingApiLevel();
41 Level shipping_fcm_version = VintfObject::GetDeviceHalManifest()->level();
42 auto res = TestTargetFcmVersion(shipping_fcm_version, shipping_api_level);
43 ASSERT_RESULT_OK(res);
44 }
45
46 // Tests that deprecated HALs are not in the manifest, unless a higher,
47 // non-deprecated minor version is in the manifest.
TEST_F(DeviceManifestTest,NoDeprecatedHalsOnManifest)48 TEST_F(DeviceManifestTest, NoDeprecatedHalsOnManifest) {
49 string error;
50 EXPECT_EQ(android::vintf::NO_DEPRECATED_HALS,
51 VintfObject::GetInstance()->checkDeprecation(
52 HidlInterfaceMetadata::all(), &error))
53 << error;
54 }
55
GetTestManifests()56 static std::vector<HalManifestPtr> GetTestManifests() {
57 return {
58 VintfObject::GetDeviceHalManifest(),
59 };
60 }
61
62 INSTANTIATE_TEST_CASE_P(DeviceManifest, SingleManifestTest,
63 ::testing::ValuesIn(GetTestManifests()));
64
65 } // namespace testing
66 } // namespace vintf
67 } // namespace android
68