chromium/chrome/browser/accessibility/embedded_a11y_extension_loader_browsertest.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/accessibility/embedded_a11y_extension_loader.h"

#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile_test_util.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_system.h"

#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/embedded_a11y_manager_lacros.h"
#endif  // BUILDFLAG(IS_CHROMEOS_LACROS)

class EmbeddedA11yExtensionLoaderTest : public InProcessBrowserTest {};

#if !BUILDFLAG(IS_CHROMEOS_LACROS)
IN_PROC_BROWSER_TEST_F(EmbeddedA11yExtensionLoaderTest,
                       InstallsRemovesAndReinstallsExtension) {}

#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(EmbeddedA11yExtensionLoaderTest,
                       InstallsOnMultipleProfiles) {}
#endif  // !BUILDFLAG(IS_CHROMEOS_ASH)

IN_PROC_BROWSER_TEST_F(EmbeddedA11yExtensionLoaderTest,
                       InstallsOnIncognitoProfile) {}

#if !BUILDFLAG(IS_CHROMEOS_ASH)
// CreateGuestBrowser() is not supported for ChromeOS out of the box.
IN_PROC_BROWSER_TEST_F(EmbeddedA11yExtensionLoaderTest,
                       InstallsOnGuestProfile) {}
#endif  // !BUILDFLAG(IS_CHROMEOS_ASH)
#endif  // !BUILDFLAG(IS_CHROMEOS_LACROS)

#if BUILDFLAG(IS_CHROMEOS_LACROS)
IN_PROC_BROWSER_TEST_F(EmbeddedA11yExtensionLoaderTest,
                       InstallsExtensionOnLacros) {
  ProfileManager* profile_manager = g_browser_process->profile_manager();
  const auto& profiles = profile_manager->GetLoadedProfiles();
  ASSERT_GT(profiles.size(), 0u);
  Profile* profile = profiles[0];

  InstallAndWaitForExtensionLoaded(
      profile, extension_misc::kEmbeddedA11yHelperExtensionId,
      extension_misc::kEmbeddedA11yHelperExtensionPath,
      extension_misc::kEmbeddedA11yHelperManifestFilename,
      /*should_localize=*/true);
  RemoveAndWaitForExtensionUnloaded(
      profile, extension_misc::kEmbeddedA11yHelperExtensionId);
}
#endif  // BUILDFLAG(IS_CHROMEOS_LACROS)