blob: d7890d7583fd1685bb8360f28c21e751746a3b94 [file] [log] [blame]
Mårten Kongstadf242ec82024-04-16 17:12:26 +02001/*
2 * Copyright (C) 2024 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 */
16package com.android.checkflaggedapis
17
18import com.android.tradefed.testtype.DeviceJUnit4ClassRunner
19import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test
Mårten Kongstad20de4052024-04-16 11:33:56 +020020import org.junit.Assert.assertEquals
Mårten Kongstadf242ec82024-04-16 17:12:26 +020021import org.junit.Test
22import org.junit.runner.RunWith
23
Mårten Kongstad20de4052024-04-16 11:33:56 +020024private val API_SIGNATURE =
25 """
26 // Signature format: 2.0
27 package android {
28 public final class Clazz {
29 ctor public Clazz();
30 field @FlaggedApi("android.flag.foo") public static final int FOO = 1; // 0x1
31 }
32 }
33"""
34 .trim()
35
Mårten Kongstadf242ec82024-04-16 17:12:26 +020036@RunWith(DeviceJUnit4ClassRunner::class)
37class CheckFlaggedApisTest : BaseHostJUnit4Test() {
Mårten Kongstad20de4052024-04-16 11:33:56 +020038 @Test
39 fun testParseApiSignature() {
40 val expected = setOf(Pair(Symbol("android.Clazz.FOO"), Flag("android.flag.foo")))
41 val actual = parseApiSignature("in-memory", API_SIGNATURE.byteInputStream())
42 assertEquals(expected, actual)
43 }
Mårten Kongstadf242ec82024-04-16 17:12:26 +020044}