Ruslan Tkhakokhov 6712b72a48 [Multi-user] Verfiy full backup/restore flow
Bug: 121198030
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases
4) atest CtsBackupHostTestCases
5) atest GtsBackupTestCases
6) atest GtsBackupHostTestCases

Manual testing:
1. Start secondary user -> verify fb-schedule file is created, full backup queue initialised
2. Verify fullbackup of 1 package for system/secondary users, [package] only exists for current user:
  * bmgr --user [user-id] fullbackup [package]
  * Verify in logs that backup is successful
  * Uninstall/install [package]
  * Verify data is restored
3. Verify fullbackup of 1 package for secondary user, [package] eixtst for user 0:
  * bmgr fullbackup [package]
  * bmgr --user [user-id] fullbackup [package]
  * Verify in logs that backup is successful
  * Uninstall/install [package] for secondary user
  * bmgr --user [user-id] restore [token] [package]
  * Verify the data restored is different from system user data and belongs to [user-id]
3. Verify backup of all packages for system/secondary users:
  * bmgr --user [user-id] backupnow --all
  * Verify system packages (android, settings, wallpaper) are skipped for secondary user
  * Verify in logs that backup is successful
  * Uninstall/install [package]
  * Verify data is restored

Base -> Patchset 2: Update method calls to use asUser versions
Patchset 2 -> Patchset 3: Update opComplete callback to accept userId
Patchset 3 -> Patchset 4: Gate system packages from backup/restore for non-system users

Change-Id: Ic3986709ba4d46c0af9da45bb4dd682ee2aef3ce
2019-01-23 15:57:11 +00:00
..
2018-11-13 11:26:43 -08:00
2018-08-10 12:41:19 +00:00

This folder is for Robolectric tests inside the platform.

To add a test class annotate it as follows:

@RunWith(FrameworkRobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 26)
@SystemLoaderClasses({ClassUnderTest.class, DependencyClasses.class})
@SystemLoaderPackages({"com.android.server.yourmodule"})

Robolectric loads some classes that it decides from versioned jars of the framework. Since we are
part of the framework some of our classes get loaded from these jars. This is NOT what we want, we
want to test against what we wrote in the tree. Because of this we use a custom test runner,
FrameworkRobolectricTestRunner, that bypasses these jars and loads certain classes from the system
class loader.

To specify which classes to load use either @SystemLoaderClasses or @SystemLoaderPackages. In
practice:
* You MUST put the class under test here.
* If you encounter any exceptions that might be caused by a different version of the class being
loaded, such as NoSuchMethodException, put the class involved in the exception in this annotation
and try again.

Check Android.mk file for more info.