• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "gtest/gtest.h"
18 #include "chre/pal/version.h"
19 
TEST(PalVersionTest,CreateApiVersion)20 TEST(PalVersionTest, CreateApiVersion) {
21   constexpr uint32_t version = CHRE_PAL_CREATE_API_VERSION(3, 6);
22   EXPECT_EQ(version, 0x03060000);
23   EXPECT_EQ(CHRE_PAL_GET_API_MAJOR_VERSION(version), 3);
24 }
25 
TEST(PalVersionTest,CompatibilityCheck)26 TEST(PalVersionTest, CompatibilityCheck) {
27   constexpr uint32_t pal_version = CHRE_PAL_CREATE_API_VERSION(2, 8);
28 
29   uint32_t requested_version = CHRE_PAL_CREATE_API_VERSION(3, 6);
30   EXPECT_FALSE(CHRE_PAL_VERSIONS_ARE_COMPATIBLE(pal_version,
31                                                 requested_version));
32 
33   requested_version = CHRE_PAL_CREATE_API_VERSION(1, 5);
34   EXPECT_FALSE(CHRE_PAL_VERSIONS_ARE_COMPATIBLE(pal_version,
35                                                 requested_version));
36 
37   requested_version = CHRE_PAL_CREATE_API_VERSION(2, 7);
38   EXPECT_TRUE(CHRE_PAL_VERSIONS_ARE_COMPATIBLE(pal_version,
39                                                requested_version));
40 
41   requested_version = CHRE_PAL_CREATE_API_VERSION(2, 4);
42   EXPECT_TRUE(CHRE_PAL_VERSIONS_ARE_COMPATIBLE(pal_version,
43                                                requested_version));
44 
45   requested_version = CHRE_PAL_CREATE_API_VERSION(2, 9);
46   EXPECT_TRUE(CHRE_PAL_VERSIONS_ARE_COMPATIBLE(pal_version,
47                                                requested_version));
48 }
49