Add a switch to disable web-app-internals logging in PWA browser tests
The default behavior is not changed, but now developers have the option to disable the chrome://web-app-internals logging on PWA browser tests using the new flag. Change-Id: I861450c60bed342eff2c3b6107b027c46fd1b73f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4781796 Commit-Queue: Zelin Liu <zelin@chromium.org> Reviewed-by: Dibyajyoti Pal <dibyapal@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184238}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
c151a0e866
commit
fc9a90d28d
@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
#include "chrome/browser/web_applications/test/debug_info_printer.h"
|
#include "chrome/browser/web_applications/test/debug_info_printer.h"
|
||||||
|
|
||||||
|
#include "base/command_line.h"
|
||||||
#include "base/run_loop.h"
|
#include "base/run_loop.h"
|
||||||
|
#include "base/strings/string_piece_forward.h"
|
||||||
#include "base/test/bind.h"
|
#include "base/test/bind.h"
|
||||||
#include "base/time/time.h"
|
#include "base/time/time.h"
|
||||||
#include "chrome/browser/profiles/profile.h"
|
#include "chrome/browser/profiles/profile.h"
|
||||||
@ -21,9 +23,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace web_app::test {
|
namespace web_app::test {
|
||||||
|
namespace {
|
||||||
|
constexpr base::StringPiece kDisableLogDebugInfoToConsole =
|
||||||
|
"disable-web-app-internals-log";
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void LogDebugInfoToConsole(const std::vector<Profile*>& profiles,
|
void LogDebugInfoToConsole(const std::vector<Profile*>& profiles,
|
||||||
base::TimeDelta time_ago_for_system_log_capture) {
|
base::TimeDelta time_ago_for_system_log_capture) {
|
||||||
|
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
|
kDisableLogDebugInfoToConsole)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (Profile* profile : profiles) {
|
for (Profile* profile : profiles) {
|
||||||
if (!AreWebAppsEnabled(profile) ||
|
if (!AreWebAppsEnabled(profile) ||
|
||||||
!WebAppProviderFactory::IsServiceCreatedForProfile(profile)) {
|
!WebAppProviderFactory::IsServiceCreatedForProfile(profile)) {
|
||||||
|
@ -32,6 +32,7 @@ Notes
|
|||||||
- UI elements do not work in unit tests, and the appropriate fakes must be used (see [External Dependencies][3]).
|
- UI elements do not work in unit tests, and the appropriate fakes must be used (see [External Dependencies][3]).
|
||||||
- If one of the external dependencies of the system cannot be faked out yet or the feature is tightly coupled to this, then it might make sense to use a browser test instead (or make that dependency fake-able).
|
- If one of the external dependencies of the system cannot be faked out yet or the feature is tightly coupled to this, then it might make sense to use a browser test instead (or make that dependency fake-able).
|
||||||
- Please use the [`WebAppTest`][4] base class if possible.
|
- Please use the [`WebAppTest`][4] base class if possible.
|
||||||
|
- Unit tests based on `WebAppTest` print a snapshot of chrome://web-app-internals to console on test failures. This can be a powerful debugging tool. The command line flag `--disable-web-app-internals-log` can be used to disable this feature.
|
||||||
|
|
||||||
## Browser tests
|
## Browser tests
|
||||||
|
|
||||||
@ -46,12 +47,20 @@ Browser tests are much more expensive to run, as they run a fully functional bro
|
|||||||
|
|
||||||
An example set of browser tests are in [`web_app_browsertest.cc`][6]. Please use the [`WebAppControllerBrowserTest`][5] base class.
|
An example set of browser tests are in [`web_app_browsertest.cc`][6]. Please use the [`WebAppControllerBrowserTest`][5] base class.
|
||||||
|
|
||||||
|
Notes
|
||||||
|
|
||||||
|
- Browser tests based on `WebAppControllerBrowserTest` print a snapshot of chrome://web-app-internals to console on test failures. This can be a powerful debugging tool. The command line flag `--disable-web-app-internals-log` can be used to disable this feature.
|
||||||
|
|
||||||
## Integration tests
|
## Integration tests
|
||||||
|
|
||||||
We have a custom integration testing framework that we use due to the complexity of our use-cases. See [integration-testing-framework.md][7] for more information.
|
We have a custom integration testing framework that we use due to the complexity of our use-cases. See [integration-testing-framework.md][7] for more information.
|
||||||
|
|
||||||
**It is a good idea to think about your integration tests early & figure out your CUJs with the team. Having your CUJs and integration tests working early greatly speeds up development & launch time.**
|
**It is a good idea to think about your integration tests early & figure out your CUJs with the team. Having your CUJs and integration tests working early greatly speeds up development & launch time.**
|
||||||
|
|
||||||
|
Notes
|
||||||
|
|
||||||
|
- Integration tests using `WebAppIntegrationTestDriver` print a snapshot of chrome://web-app-internals to console on test failures. This can be a powerful debugging tool. The command line flag `--disable-web-app-internals-log` can be used to disable this feature.
|
||||||
|
|
||||||
## Testing OS integration
|
## Testing OS integration
|
||||||
|
|
||||||
It is very common to test OS integration. By default, OS integration is suppressed if the test extends [`WebAppTest`][4] or [`WebAppControllerBrowserTest`][5].
|
It is very common to test OS integration. By default, OS integration is suppressed if the test extends [`WebAppTest`][4] or [`WebAppControllerBrowserTest`][5].
|
||||||
|
Reference in New Issue
Block a user