chromium/chrome/browser/extensions/api/management/management_apitest.cc

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

#include <map>

#include "base/auto_reset.h"
#include "base/strings/stringprintf.h"
#include "base/test/gtest_tags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/web_app_dialogs.h"
#include "chrome/browser/web_applications/extension_status_utils.h"
#include "chrome/browser/web_applications/os_integration/os_integration_manager.h"
#include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
#include "chrome/browser/web_applications/test/fake_web_app_ui_manager.h"
#include "chrome/browser/web_applications/test/os_integration_test_override_impl.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/api/management/management_api.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/test_management_policy.h"
#include "extensions/common/manifest.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#include "testing/gtest/include/gtest/gtest.h"

Extension;
Manifest;
ManifestLocation;

namespace {

#if !BUILDFLAG(IS_CHROMEOS_LACROS)
// Find a browser other than |browser|.
Browser* FindOtherBrowser(Browser* browser) {}

bool ExpectChromeAppsDefaultEnabled() {}
#endif  // !BUILDFLAG(IS_CHROMEOS_LACROS)

}  // namespace

ContextType;

class ExtensionManagementApiTest
    : public extensions::ExtensionApiTest,
      public testing::WithParamInterface<ContextType> {};

INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, Basics) {}

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, NoPermission) {}

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, Uninstall) {}

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, CreateAppShortcut) {}

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, GenerateAppForLink) {}

class InstallReplacementWebAppApiTest : public ExtensionManagementApiTest {};

INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

const char InstallReplacementWebAppApiTest::kManifest[] =;

const char InstallReplacementWebAppApiTest::kAppManifest[] =;

IN_PROC_BROWSER_TEST_P(InstallReplacementWebAppApiTest, NotWebstore) {}

IN_PROC_BROWSER_TEST_P(InstallReplacementWebAppApiTest, NoGesture) {}

IN_PROC_BROWSER_TEST_P(InstallReplacementWebAppApiTest, NotInstallableWebApp) {}

#if !BUILDFLAG(IS_CHROMEOS_LACROS)
// TODO(crbug.com/40211465): Run these tests on Chrome OS with both Ash and
// Lacros processes active.
IN_PROC_BROWSER_TEST_P(InstallReplacementWebAppApiTest, InstallableWebApp) {}
#endif

#if !BUILDFLAG(IS_CHROMEOS_LACROS)
// TODO(crbug.com/40211465): Run these tests on Chrome OS with both Ash and
// Lacros processes active.

// Check that web app still installs and launches correctly when start_url does
// not match replacement_web_app_url.
IN_PROC_BROWSER_TEST_P(InstallReplacementWebAppApiTest,
                       InstallableWebAppWithStartUrl) {}

IN_PROC_BROWSER_TEST_P(InstallReplacementWebAppApiTest,
                       InstallableWebAppInPlatformApp) {}
#endif

// Tests actions on extensions when no management policy is in place.
IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, ManagementPolicyAllowed) {}

// Tests actions on extensions when management policy prohibits those actions.
IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, ManagementPolicyProhibited) {}

#if !BUILDFLAG(IS_CHROMEOS_LACROS)
// TODO(crbug.com/40211465): Run these tests on Chrome OS with both Ash and
// Lacros processes active.

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, LaunchPanelApp) {}

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, LaunchTabApp) {}

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest,
                       NoLaunchPanelAppsDeprecated) {}

IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, NoLaunchTabAppDeprecated) {}
#endif  // !BUILDFLAG(IS_CHROMEOS_LACROS)

// Flaky on MacOS: crbug.com/915339
#if BUILDFLAG(IS_MAC)
#define MAYBE_LaunchType
#else
#define MAYBE_LaunchType
#endif
IN_PROC_BROWSER_TEST_P(ExtensionManagementApiTest, MAYBE_LaunchType) {}