// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_WEB_APPLICATIONS_TEST_OS_INTEGRATION_TEST_OVERRIDE_IMPL_H_ #define CHROME_BROWSER_WEB_APPLICATIONS_TEST_OS_INTEGRATION_TEST_OVERRIDE_IMPL_H_ #include <map> #include <memory> #include <optional> #include <string> #include <tuple> #include <vector> #include "base/containers/flat_set.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/functional/callback_helpers.h" #include "base/memory/ref_counted.h" #include "base/test/scoped_path_override.h" #include "base/types/expected.h" #include "build/build_config.h" #include "chrome/browser/web_applications/os_integration/os_integration_test_override.h" #include "chrome/browser/web_applications/test/fake_environment.h" #include "chrome/browser/web_applications/web_app_icon_generator.h" #include "chrome/browser/web_applications/web_app_install_info.h" #include "components/webapps/common/web_app_id.h" #include "third_party/skia/include/core/SkColor.h" #if BUILDFLAG(IS_WIN) #include "base/containers/flat_map.h" #include "base/test/test_reg_util_win.h" #endif class Profile; #if BUILDFLAG(IS_WIN) class ShellLinkItem; #endif namespace web_app { #if BUILDFLAG(IS_LINUX) struct LinuxFileRegistration { … }; #endif class OsIntegrationTestOverrideImpl; // Multiple of these classes can be created to ensure that OS integration is // faked during their lifetime. When the last one is destroyed, this blocks the // thread until all users of OsIntegrationTestOverride::Get() have destroyed any // saved `scoped_refptr<OsIntegrationTestOverride>`. This ensures that all os // integration (disk folders, windows registry changes, etc) have been removed. // // `test_override()` can be used to view or modify the OS state. // // Note: This override does not apply if there is a // OsIntegrationManager::ScopedSuppressForTesting is created. This often happens // in unit tests, which use a FakeWebAppProvider by default. To reset that // object held by the FakeOsIntegrationManager, call // FakeWebAppProvider::UseRealOsIntegrationManager() on test setup. class OsIntegrationTestOverrideBlockingRegistration { … }; // See the `OsIntegrationTestOverride` base class documentation for more // information about the purpose of this class. This is the implementation, and // being test-only can include test-only code. // // Other than inheriting the base class & providing implementations of those // getters & setters, this class is also responsible for providing common ways // of checking the OS integration state in a test. The class methods are // organized per-os-integration. class OsIntegrationTestOverrideImpl : public OsIntegrationTestOverride { … }; } // namespace web_app #endif // CHROME_BROWSER_WEB_APPLICATIONS_TEST_OS_INTEGRATION_TEST_OVERRIDE_IMPL_H_