use of com.google.testing.timing.FakeDirectExecutorService in project firebase-android-sdk by firebase.
the class FirebasePerformanceTest method setUp.
@Before
public void setUp() throws NameNotFoundException {
FirebaseOptions options = new FirebaseOptions.Builder().setApplicationId("1:149208680807:android:0000000000000000").setApiKey("AIzaSyBcE-OOIbhjyR83gm4r2MFCu4MJmprNXsw").setProjectId("fir-perftestapp").build();
FirebaseApp.clearInstancesForTest();
Context context = ApplicationProvider.getApplicationContext();
FirebaseApp.initializeApp(context, options);
for (int i = 0; i <= Constants.MAX_TRACE_CUSTOM_ATTRIBUTES; i++) {
FirebasePerformance.getInstance().removeAttribute("dim" + i);
}
FirebaseApp.getInstance().setDataCollectionDefaultEnabled(true);
SharedPreferences sharedPreferences = getSharedPreferences();
sharedPreferences.edit().clear().commit();
DeviceCacheManager.clearInstance();
shadowOf(context.getPackageManager()).getInternalMutablePackageInfo(context.getPackageName()).applicationInfo.metaData.clear();
spyRemoteConfigManager = spy(RemoteConfigManager.getInstance());
ConfigResolver.clearInstance();
spyConfigResolver = spy(ConfigResolver.getInstance());
spySessionManager = spy(SessionManager.getInstance());
fakeDirectExecutorService = new FakeDirectExecutorService();
}
use of com.google.testing.timing.FakeDirectExecutorService in project firebase-android-sdk by firebase.
the class AppStateMonitorTest method screenTrace_perfMonDeactivated_traceNotCreated.
@Test
public void screenTrace_perfMonDeactivated_traceNotCreated() {
AppStateMonitor monitor = new AppStateMonitor(transportManager, clock);
Activity activityWithNonHardwareAcceleratedView = createFakeActivity(/* isHardwareAccelerated =*/
true);
ConfigResolver configResolver = ConfigResolver.getInstance();
configResolver.setDeviceCacheManager(new DeviceCacheManager(new FakeDirectExecutorService()));
Bundle bundle = new Bundle();
bundle.putBoolean("firebase_performance_collection_deactivated", true);
configResolver.setMetadataBundle(new ImmutableBundle(bundle));
// Developer has enabled Performance Monitoring during runtime.
configResolver.setIsPerformanceCollectionEnabled(true);
// Assert that screen trace has not been created.
monitor.onActivityStarted(activityWithNonHardwareAcceleratedView);
assertThat(monitor.getActivity2ScreenTrace()).isEmpty();
// Confirm that this doesn't throw an exception.
monitor.onActivityStopped(activityWithNonHardwareAcceleratedView);
}
use of com.google.testing.timing.FakeDirectExecutorService in project firebase-android-sdk by firebase.
the class AppStateMonitorTest method setUp.
@Before
public void setUp() {
currentTime = 0;
initMocks(this);
doAnswer((Answer<Timer>) invocationOnMock -> new Timer(currentTime)).when(clock).getTime();
activity1 = createFakeActivity(/* isHardwareAccelerated= */
true);
activity2 = createFakeActivity(/* isHardwareAccelerated= */
true);
DeviceCacheManager.clearInstance();
ConfigResolver.clearInstance();
ConfigResolver configResolver = ConfigResolver.getInstance();
configResolver.setDeviceCacheManager(new DeviceCacheManager(new FakeDirectExecutorService()));
}
use of com.google.testing.timing.FakeDirectExecutorService in project firebase-android-sdk by firebase.
the class PerfSessionTest method setUp.
@Before
public void setUp() {
initMocks(this);
DeviceCacheManager.clearInstance();
ConfigResolver.clearInstance();
appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit().clear().commit();
ConfigResolver configResolver = ConfigResolver.getInstance();
configResolver.setApplicationContext(appContext);
configResolver.setDeviceCacheManager(new DeviceCacheManager(new FakeDirectExecutorService()));
}
use of com.google.testing.timing.FakeDirectExecutorService in project firebase-android-sdk by firebase.
the class TraceTest method setUp.
@Before
public void setUp() {
currentTime = 1;
initMocks(this);
doAnswer((Answer<Timer>) invocationOnMock -> new Timer(currentTime)).when(mockClock).getTime();
arguments = ArgumentCaptor.forClass(TraceMetric.class);
DeviceCacheManager.clearInstance();
ConfigResolver.clearInstance();
appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit().clear().commit();
ConfigResolver configResolver = ConfigResolver.getInstance();
configResolver.setDeviceCacheManager(new DeviceCacheManager(new FakeDirectExecutorService()));
configResolver.setApplicationContext(appContext);
}
Aggregations