-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Andrid.Build.Tests] Add MultiUser unit tests #5311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
009305c to
44a7afe
Compare
jonpryor
reviewed
Dec 3, 2020
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs
Outdated
Show resolved
Hide resolved
This commit adds support for running multi user tests on device.
It makes use of various adb commands to create test users and
remove them.
`shell pm create-user --guest {name}` will create a guest user of a
specific name.
`shell pm remove-user --guest {userId}` will remove a userId.
The userId can be retrieved via `shell pm list users`. This command
will return results as follows
Users:
UserInfo{0:Owner:c13} running
UserInfo{10:guest1:414}
We can then use a RegEx to pull out the required `userId` for a specific
user.
Finally `shell am switch-user {userId}` can be used to switch between
users on the device.
Emulators seem to create the main user with the name "Owner" so that should
be the default name we use for the main user. In the unit tests if we
cannot find a user named "Owner" when looking for "Owner" we will default
to a `userId` of `0`. This always means the default user. This is to handle
the case where we are testing locally on devices where the main user is
not called "Owner".
5595049 to
79995b0
Compare
jonathanpeppers
approved these changes
Dec 9, 2020
Member
jonathanpeppers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, if we are OK with the CI results.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds support for running multi user tests on device.
It makes use of various adb commands to create test users and
remove them.
shell pm create-user --guest {name}will create a guest user of aspecific name.
shell pm remove-user --guest {userId}will remove a userId.The userId can be retrieved via
shell pm list users. This commandwill return results as follows
We can then use a RegEx to pull out the required
userIdfor a specificuser.
Finally
shell am switch-user {userId}can be used to switch betweenusers on the device.
Emulators seem to create the main user with the name "Owner" so that should
be the default name we use for the main user. In the unit tests if we
cannot find a user named "Owner" when looking for "Owner" we will default
to a
userIdof0. This always means the default user. This is to handlethe case where we are testing locally on devices where the main user is
not called "Owner".