Home | History | Annotate | Download | only in vintf
      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 <vintf/VintfObject.h>
     20 #include "SingleManifestTest.h"
     21 
     22 namespace android {
     23 namespace vintf {
     24 namespace testing {
     25 
     26 void DeviceManifestTest::SetUp() {
     27   VtsTrebleVintfTestBase::SetUp();
     28 
     29   vendor_manifest_ = VintfObject::GetDeviceHalManifest();
     30   ASSERT_NE(vendor_manifest_, nullptr)
     31       << "Failed to get vendor HAL manifest." << endl;
     32 }
     33 
     34 // Tests that Shipping FCM Version in the device manifest is at least the
     35 // minimum Shipping FCM Version as required by Shipping API level.
     36 TEST_F(DeviceManifestTest, ShippingFcmVersion) {
     37   uint64_t shipping_api_level = GetShippingApiLevel();
     38   ASSERT_NE(shipping_api_level, 0u)
     39       << "Device's shipping API level cannot be determined.";
     40 
     41   Level shipping_fcm_version = VintfObject::GetDeviceHalManifest()->level();
     42   if (shipping_fcm_version == Level::UNSPECIFIED) {
     43     // O / O-MR1 vendor image doesn't have shipping FCM version declared and
     44     // shipping FCM version is inferred from Shipping API level, hence it always
     45     // meets the requirement.
     46     return;
     47   }
     48 
     49   ASSERT_GE(shipping_api_level, kFcm2ApiLevelMap.begin()->first /* 25 */)
     50       << "Pre-N devices should not run this test.";
     51 
     52   auto it = kFcm2ApiLevelMap.find(shipping_api_level);
     53   ASSERT_TRUE(it != kFcm2ApiLevelMap.end())
     54       << "No launch requirement is set yet for Shipping API level "
     55       << shipping_api_level << ". Please update the test.";
     56 
     57   Level required_fcm_version = it->second;
     58 
     59   ASSERT_GE(shipping_fcm_version, required_fcm_version)
     60       << "Shipping API level == " << shipping_api_level
     61       << " requires Shipping FCM Version >= " << required_fcm_version
     62       << " (but is " << shipping_fcm_version << ")";
     63 }
     64 
     65 // Tests that deprecated HALs are not in the manifest, unless a higher,
     66 // non-deprecated minor version is in the manifest.
     67 TEST_F(DeviceManifestTest, NoDeprecatedHalsOnManifest) {
     68   string error;
     69   EXPECT_EQ(android::vintf::NO_DEPRECATED_HALS,
     70             VintfObject::CheckDeprecation(&error))
     71       << error;
     72 }
     73 
     74 static std::vector<HalManifestPtr> GetTestManifests() {
     75   return {
     76       VintfObject::GetDeviceHalManifest(),
     77   };
     78 }
     79 
     80 INSTANTIATE_TEST_CASE_P(DeviceManifest, SingleManifestTest,
     81                         ::testing::ValuesIn(GetTestManifests()));
     82 
     83 }  // namespace testing
     84 }  // namespace vintf
     85 }  // namespace android
     86