
org.robolectric.android.controller.BackupAgentController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shadows-framework Show documentation
Show all versions of shadows-framework Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.android.controller;
import android.app.backup.BackupAgent;
import android.content.Context;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
public class BackupAgentController
extends ComponentController, T> {
private BackupAgentController(T backupAgent) {
super(backupAgent);
}
public static BackupAgentController of(T backupAgent) {
return new BackupAgentController<>(backupAgent).attach();
}
private BackupAgentController attach() {
if (attached) {
return this;
}
Context baseContext = RuntimeEnvironment.getApplication().getBaseContext();
ReflectionHelpers.callInstanceMethod(
BackupAgent.class,
component,
"attach",
ReflectionHelpers.ClassParameter.from(Context.class, baseContext));
return this;
}
@Override
public BackupAgentController create() {
invokeWhilePaused("onCreate");
return this;
}
@Override
public BackupAgentController destroy() {
invokeWhilePaused("onDestroy");
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy