Mårten Kongstad | f242ec8 | 2024-04-16 17:12:26 +0200 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package com.android.checkflaggedapis |
| 17 | |
| 18 | import com.android.tradefed.testtype.DeviceJUnit4ClassRunner |
| 19 | import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test |
Mårten Kongstad | 20de405 | 2024-04-16 11:33:56 +0200 | [diff] [blame^] | 20 | import org.junit.Assert.assertEquals |
Mårten Kongstad | f242ec8 | 2024-04-16 17:12:26 +0200 | [diff] [blame] | 21 | import org.junit.Test |
| 22 | import org.junit.runner.RunWith |
| 23 | |
Mårten Kongstad | 20de405 | 2024-04-16 11:33:56 +0200 | [diff] [blame^] | 24 | private 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 Kongstad | f242ec8 | 2024-04-16 17:12:26 +0200 | [diff] [blame] | 36 | @RunWith(DeviceJUnit4ClassRunner::class) |
| 37 | class CheckFlaggedApisTest : BaseHostJUnit4Test() { |
Mårten Kongstad | 20de405 | 2024-04-16 11:33:56 +0200 | [diff] [blame^] | 38 | @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 Kongstad | f242ec8 | 2024-04-16 17:12:26 +0200 | [diff] [blame] | 44 | } |