chromium/chrome/browser/ui/views/permissions/embedded_permission_prompt_interactive_uitest.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 <queue>
#include <string>

#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/permissions/embedded_permission_prompt_ask_view.h"
#include "chrome/browser/ui/views/permissions/embedded_permission_prompt_base_view.h"
#include "chrome/browser/ui/views/permissions/embedded_permission_prompt_content_scrim_view.h"
#include "chrome/browser/ui/views/permissions/embedded_permission_prompt_previously_denied_view.h"
#include "chrome/browser/ui/views/permissions/embedded_permission_prompt_previously_granted_view.h"
#include "chrome/browser/ui/views/permissions/permission_prompt_bubble_base_view.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_request_manager.h"
#include "components/permissions/permission_uma_util.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/public/common/features_generated.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/label.h"
#include "ui/views/widget/any_widget_observer.h"
#include "url/origin.h"

namespace {
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
DEFINE_LOCAL_CUSTOM_ELEMENT_EVENT_TYPE();
DEFINE_LOCAL_CUSTOM_ELEMENT_EVENT_TYPE();

UkmEntry;
}  // namespace

class EmbeddedPermissionPromptInteractiveTest : public InteractiveBrowserTest {};

// Failing on Windows, though manual testing of the same flow does not reproduce
// the issue. TODO(andypaicu, crbug.com/1462930): Investigate and fix failure.
#if BUILDFLAG(IS_WIN)
#define MAYBE_BasicFlowMicrophone
#define MAYBE_BasicFlowGeolocation
#define MAYBE_BasicFlowCamera
#define MAYBE_BasicFlowCameraMicrophone
#define MAYBE_TestPartialPermissionsLabels
#define MAYBE_TestPermissionElementDialogPositioning
#define MAYBE_TestPepcHistograms
#define MAYBE_TestPepcUkm
#define MAYBE_TestButtonsLabel
#else
#define MAYBE_BasicFlowMicrophone
#define MAYBE_BasicFlowGeolocation
#define MAYBE_BasicFlowCamera
#define MAYBE_BasicFlowCameraMicrophone
#define MAYBE_TestPartialPermissionsLabels
#define MAYBE_TestPermissionElementDialogPositioning
#define MAYBE_TestPepcHistograms
#define MAYBE_TestPepcUkm
#define MAYBE_TestButtonsLabel
#endif
IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       MAYBE_BasicFlowMicrophone) {}

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       MAYBE_BasicFlowCamera) {}

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       MAYBE_BasicFlowGeolocation) {}

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       MAYBE_BasicFlowCameraMicrophone) {}

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       MAYBE_TestPartialPermissionsLabels) {}

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       MAYBE_TestButtonsLabel) {}

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       MAYBE_TestPepcHistograms) {}

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       FocusableViaTabKey) {}

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptInteractiveTest,
                       MAYBE_TestPepcUkm) {}

class EmbeddedPermissionPromptPositioningInteractiveTest
    : public EmbeddedPermissionPromptInteractiveTest {};

IN_PROC_BROWSER_TEST_F(EmbeddedPermissionPromptPositioningInteractiveTest,
                       MAYBE_TestPermissionElementDialogPositioning) {}