Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Malandruccolo committed May 13, 2024
1 parent e670fae commit 8ae53c7
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 8ae53c7

Please # to comment.