Headless automation of XUser
For testing, games might want to automate the addition of users into their game. With the Microsoft Game Development Kit (GDK), users are only added when the game calls XUserAddAsync. With respect to automation, this function has the following two main limitations.
- If you call
XUserAddAsync
with theAddDefaultUserSilently
flag, you don't get UI (which helps with the automation). However, you can only get the user who launched the game. Calling the API repeatedly with this flag doesn't change the result. You'll just keep getting new handles to the same users. - If you call
XUserAddAsync
without theAddDefaultUserSilently
flag, the UI appears and waits for someone to push a button. This breaks automation.
To aid in the automation of adding users in test code, the Microsoft Game Development Kit (GDK) has support for turning on a headless option where you can add users without having UI show that requires user input. The following steps outline the basic approach.
- To add a signed-in user to the console, you can use the xbuser (NDA topic)Необходима авторизация
command-line tool with the
signin
option. Repeat this step for each user. - To suppress the UI that would usually show when adding a user in the game, you
can use the xbconfig (NDA topic)Необходима авторизация command-line tool with the
HeadlessXuser
option, shown as follows.xbconfig HeadlessXUser=true
- Launch the game.
- When in the game, each call to
XUserAddAsync
that doesn't have theAddDefaultUserSilently
flag returns the first user who signed in to the console and has no outstandingXUserHandle
objects associated to them by the game. - If the game keeps calling
XUserAddAsync
, it eventually exhausts the number of users who are signed in to the console. After this happens,XUserAddAsync
returnsE_ABORT
. This is the exact same error thatXUserAddAsync
would have returned if the user had canceled out of signing in to the console (or otherwise backed out of the UI). - For testing purposes, games might want to know the number of test accounts that are
signed in to the console. To facilitate this, games can call
CreateProcess
and launch thewduser
command-line tool with thelist
option.