[Android] Add support for overriding user data dir in Java browsertests
On Android, the user data dir in Chrome and WebLayer by default is ANDROID_APP_DATA_DIR. In the context of Java browsertests, this directory is set to the isolated test root, which is problematic as it can't be cleared between runs (see linked bug). This bleedthrough of state can result in cryptic test failures. //chrome's android_browsertests handles this issue by overriding the user data directory in C++ at the //chrome level (https://chromium-review.googlesource.com/c/chromium/src/+/1677591). However, we are now facing this issue for weblayer_browsertests. This CL introduces a general solution for this problem at the level of NativeBrowserTestsActivity.java by allowing subclasses of this class to specify the command-line switch for the user data directory. Doing this specification will result in the user data directory getting overridden to the embedder-specified private data directory, which *is* cleared between each run by NativeBrowserTestsActivity. We do this specification for //weblayer as well as Content Shell-based browsertests. The latter solves the problem for the existing content_browsertests and components_browsertests suites, which are run on Android. //chrome's ChromeBrowserTestActivity.java does not subclass NativeBrowserTestsActivity as it subclasses ChromeTabbedActivity. Changing //chrome's android_browsertests to use this mechanism rather than its current one is left as future work. Finally, we note that this solution is a stopgap, as it leaves open the possibility that the C++ and Java sides have different views of the conceptual "user data dir". The proper solution for this problem would be for ANDROID_APP_DATA_DIR to *not* be set to the isolated test root but rather to a directory that is cleared between each run (e.g., a temp directory). That solution is however not easily accessible for reasons detailed in the bug. In the meantime, the stopgap solution of changing the user data dir on the C++ side only has been working in the context of android_browsertests for ~18 months. Bug: 617734 Change-Id: I8dd2fe25595f01a540af9a6c6c4787bb6570b62b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504262Reviewed-by:John Abd-El-Malek <jam@chromium.org> Reviewed-by:
Andrew Grieve <agrieve@chromium.org> Commit-Queue: Colin Blundell <blundell@chromium.org> Cr-Commit-Position: refs/heads/master@{#822575}
Showing
Please register or sign in to comment