Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb28da9c authored by Ruslan Tkhakokhov's avatar Ruslan Tkhakokhov
Browse files

Fix Robolectric tests that use JobScheduler

In ag/88814052 registering JobScheduler with SystemRegistryService has moved int JobSchedulerFrameworkInitializer. Make sure that class is loaded before the tests are run.

Bug: 138840929
Test: atest RunBackupFrameworksServicesRoboTest
Change-Id: Idacab9f8597b57df5b61a5c6619090a242a76264
parent 0dd1be75
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.util.SparseArray;
import com.android.server.backup.testing.TransportData;
import com.android.server.testing.shadows.ShadowApplicationPackageManager;
import com.android.server.testing.shadows.ShadowBinder;
import com.android.server.testing.shadows.ShadowSystemServiceRegistry;

import org.junit.After;
import org.junit.Before;
@@ -73,7 +74,12 @@ import java.io.StringWriter;

/** Tests for the user-aware backup/restore system service {@link BackupManagerService}. */
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowApplicationPackageManager.class, ShadowBinder.class})
@Config(
        shadows = {
            ShadowApplicationPackageManager.class,
            ShadowBinder.class,
            ShadowSystemServiceRegistry.class
        })
@Presubmit
public class BackupManagerServiceTest {
    private static final String TEST_PACKAGE = "package";
+3 −1
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.os.Handler;
import android.os.UserHandle;
import android.platform.test.annotations.Presubmit;

import com.android.server.testing.shadows.ShadowSystemServiceRegistry;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -36,7 +38,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowJobScheduler;

@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowJobScheduler.class})
@Config(shadows = {ShadowJobScheduler.class, ShadowSystemServiceRegistry.class})
@Presubmit
public class FullBackupJobTest {
    private Context mContext;
+4 −0
Original line number Diff line number Diff line
@@ -24,14 +24,18 @@ import android.os.Handler;
import android.os.UserHandle;
import android.platform.test.annotations.Presubmit;

import com.android.server.testing.shadows.ShadowSystemServiceRegistry;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowSystemServiceRegistry.class})
@Presubmit
public class KeyValueBackupJobTest {
    private Context mContext;
+7 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.server.testing.shadows.ShadowApplicationPackageManager;
import com.android.server.testing.shadows.ShadowBinder;
import com.android.server.testing.shadows.ShadowKeyValueBackupJob;
import com.android.server.testing.shadows.ShadowKeyValueBackupTask;
import com.android.server.testing.shadows.ShadowSystemServiceRegistry;

import org.junit.After;
import org.junit.Before;
@@ -88,7 +89,12 @@ import java.util.List;
 * UserBackupManagerService} that performs operations for its target user.
 */
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowAppBackupUtils.class, ShadowApplicationPackageManager.class})
@Config(
        shadows = {
            ShadowAppBackupUtils.class,
            ShadowApplicationPackageManager.class,
            ShadowSystemServiceRegistry.class
        })
@Presubmit
public class UserBackupManagerServiceTest {
    private static final String TAG = "BMSTest";
+7 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.server.backup.TransportManager;
import com.android.server.backup.UserBackupManagerService;
import com.android.server.backup.testing.BackupManagerServiceTestUtils;
import com.android.server.testing.shadows.ShadowApplicationPackageManager;
import com.android.server.testing.shadows.ShadowSystemServiceRegistry;

import org.junit.Before;
import org.junit.Test;
@@ -51,7 +52,12 @@ import java.io.File;
 * UserBackupManagerService}.
 */
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowApplicationPackageManager.class, ShadowJobScheduler.class})
@Config(
        shadows = {
            ShadowApplicationPackageManager.class,
            ShadowJobScheduler.class,
            ShadowSystemServiceRegistry.class
        })
@Presubmit
public class SetupObserverTest {
    private static final String TAG = "SetupObserverTest";
Loading