|
| 1 | +// Copyright 2013 The Flutter Authors |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +package io.flutter.plugins.camerax; |
| 6 | + |
| 7 | +import static org.junit.Assert.fail; |
| 8 | + |
| 9 | +import org.junit.Test; |
| 10 | + |
| 11 | +/** |
| 12 | + * Regression test for https://github.com/flutter/flutter/issues/190505. |
| 13 | + * |
| 14 | + * <p>{@code camera-core}'s compiled classes carry jspecify {@code @NonNull} type annotations on |
| 15 | + * members that reference {@code androidx.concurrent.futures.CallbackToFutureAdapter}. javac needs |
| 16 | + * that class on the compile classpath to process those annotations, even though this plugin never |
| 17 | + * calls the annotated members directly. Without an explicit {@code |
| 18 | + * androidx.concurrent:concurrent-futures} dependency, resolution of that class can silently depend |
| 19 | + * on transitive dependency behavior and fail with "class file for |
| 20 | + * androidx.concurrent.futures.CallbackToFutureAdapter not found" during {@code |
| 21 | + * compileDebugJavaWithJavac}. |
| 22 | + * |
| 23 | + * <p>This test asserts the class is present on the test classpath, so if the explicit dependency |
| 24 | + * in {@code android/build.gradle.kts} is ever removed, this test fails instead of the break only |
| 25 | + * surfacing as a build error for consumers. |
| 26 | + */ |
| 27 | +public class ConcurrentFuturesDependencyTest { |
| 28 | + @Test |
| 29 | + public void callbackToFutureAdapter_isOnClasspath() { |
| 30 | + try { |
| 31 | + Class.forName("androidx.concurrent.futures.CallbackToFutureAdapter"); |
| 32 | + } catch (ClassNotFoundException e) { |
| 33 | + fail( |
| 34 | + "androidx.concurrent.futures.CallbackToFutureAdapter is not on the classpath. " |
| 35 | + + "This means the explicit androidx.concurrent:concurrent-futures dependency in " |
| 36 | + + "android/build.gradle.kts was removed or is no longer being resolved, which will " |
| 37 | + + "cause compileDebugJavaWithJavac to fail for consumers of this plugin. " |
| 38 | + + "See https://github.com/flutter/flutter/issues/190505."); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
0 commit comments