chromium/chrome/browser/ui/views/supervised_user/parent_permission_extension_flow_view_browsertest.cc

// 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.

#include <memory>
#include <string>
#include <utility>

#include "base/files/file_path.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/path_service.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/scoped_test_mv2_enabler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_extensions_delegate_impl.h"
#include "chrome/browser/supervised_user/supervised_user_extensions_metrics_recorder.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/supervised_user/supervised_user_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/extension_enable_flow.h"
#include "chrome/browser/ui/extensions/extension_enable_flow_test_delegate.h"
#include "chrome/browser/ui/supervised_user/parent_permission_dialog.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/supervised_user/parent_permission_dialog_view.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/fake_gaia_mixin.h"
#include "chrome/test/base/mixin_based_in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/supervised_user/supervision_mixin.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/supervised_user/core/browser/supervised_user_service.h"
#include "components/supervised_user/core/common/features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_launcher.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
#include "extensions/common/extension_builder.h"
#include "extensions/test/result_catcher.h"
#include "google_apis/gaia/fake_gaia.h"
#include "google_apis/gaia/gaia_auth_consumer.h"

// End to end test of ExtensionEnableFlowTestSupervised that exercises the
// dialog's internal logic that orchestrates the parental permission process.
class ExtensionEnableFlowTestSupervised
    : public MixinBasedInProcessBrowserTest,
      public TestParentPermissionDialogViewObserver {};

// Tests launching an app that requires parent approval from the launcher.
IN_PROC_BROWSER_TEST_F(ExtensionEnableFlowTestSupervised,
                       ParentPermissionDialogAccept) {}

// Tests launching an app and canceling parent approval from the launcher.
IN_PROC_BROWSER_TEST_F(ExtensionEnableFlowTestSupervised,
                       ParentPermissionDialogCancel) {}

// Tests that the Parent Permission Dialog doesn't appear at all when the parent
// has disabled the "Permissions for sites, apps and extensions" toggle, and the
// supervised user sees the Extension Install Blocked By Parent error dialog
// instead.
IN_PROC_BROWSER_TEST_F(ExtensionEnableFlowTestSupervised,
                       ParentBlockedExtensionEnable) {}

class ExtensionManagementApiTestSupervised
    : public ExtensionEnableFlowTestSupervised {};

IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTestSupervised,
                       PRE_ParentPermissionGrantedForEnable) {}

// Tests launching the Parent Permission Dialog from the management api when the
// extension hasn't already been approved.
IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTestSupervised,
                       ParentPermissionGrantedForEnable) {}

IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTestSupervised,
                       PRE_ParentPermissionNotGrantedForEnable) {}

// Tests that extensions are not enabled after the parent permission dialog is
// cancelled.
IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTestSupervised,
                       ParentPermissionNotGrantedForEnable) {}

IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTestSupervised,
                       PRE_ParentBlockedExtensionEnable) {}

// Tests that the Parent Permission Dialog doesn't appear at all when the parent
// has disabled the "Permissions for sites, apps and extensions" toggle, and the
// supervised user sees the Extension Install Blocked By Parent error dialog
// instead.
IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTestSupervised,
                       ParentBlockedExtensionEnable) {}