diff --git a/packages/google_mobile_ads/android/src/test/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProviderTest.java b/packages/google_mobile_ads/android/src/test/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProviderTest.java index 980e2ff5a..e3d54c5fa 100644 --- a/packages/google_mobile_ads/android/src/test/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProviderTest.java +++ b/packages/google_mobile_ads/android/src/test/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProviderTest.java @@ -15,6 +15,7 @@ package io.flutter.plugins.googlemobileads; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -23,11 +24,13 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; +import android.os.Build; import android.os.Bundle; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; /** Tests {@link FlutterRequestAgentProvider}. */ @RunWith(RobolectricTestRunner.class) @@ -49,9 +52,17 @@ public void setUp() throws NameNotFoundException { doReturn(mockContext).when(mockContext).getApplicationContext(); doReturn(mockPackageManager).when(mockContext).getPackageManager(); doReturn(PACKAGE_NAME).when(mockContext).getPackageName(); - doReturn(mockApplicationInfo) - .when(mockPackageManager) - .getApplicationInfo(eq(PACKAGE_NAME), eq(PackageManager.GET_META_DATA)); + if (Build.VERSION.SDK_INT >= 33) { + doReturn(mockApplicationInfo) + .when(mockPackageManager) + .getApplicationInfo( + eq(PACKAGE_NAME), + eq(PackageManager.ApplicationInfoFlags.of(PackageManager.GET_META_DATA))); + } else { + doReturn(mockApplicationInfo) + .when(mockPackageManager) + .getApplicationInfo(eq(PACKAGE_NAME), eq(PackageManager.GET_META_DATA)); + } } @Test