chromium/chrome/browser/ui/views/site_data/page_specific_site_data_dialog_interactive_uitest.cc

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

#include <string>

#include "base/functional/callback_helpers.h"
#include "base/test/bind.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_run_loop_timeout.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/frame/app_menu_button.h"
#include "chrome/browser/ui/views/page_info/page_info_cookies_content_view.h"
#include "chrome/browser/ui/views/page_info/page_info_main_view.h"
#include "chrome/browser/ui/views/page_info/page_info_view_factory.h"
#include "chrome/browser/ui/views/site_data/page_specific_site_data_dialog.h"
#include "chrome/browser/ui/views/site_data/page_specific_site_data_dialog_controller.h"
#include "chrome/browser/ui/views/site_data/site_data_row_view.h"
#include "chrome/browser/ui/views/toolbar/app_menu.h"
#include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.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/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/scoped_privacy_sandbox_attestations.h"
#include "components/privacy_sandbox/privacy_sandbox_settings.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "third_party/blink/public/common/features.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/expect_call_in_scope.h"
#include "ui/base/interaction/interaction_sequence.h"
#include "ui/base/interaction/interaction_test_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/tree/tree_view.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/interaction/interaction_test_util_views.h"
#include "ui/views/view_utils.h"

namespace {
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
DEFINE_LOCAL_CUSTOM_ELEMENT_EVENT_TYPE();
const char kFirstPartyAllowedRow[] =;
const char kThirdPartyBlockedRow[] =;
const char kOnlyPartitionedRow[] =;
const char kMixedPartitionedRow[] =;
const char kCookiesDialogOpenedActionName[] =;
const char kCookiesDialogRemoveButtonClickedActionName[] =;

class CookieChangeObserver : public content::WebContentsObserver {};

}  // namespace

class PageSpecificSiteDataDialogInteractiveUiTest
    : public InteractiveBrowserTest {};

// Flaky on ChromeOS: crbug.com/1429381
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_FirstPartyAllowed
#else
#define MAYBE_FirstPartyAllowed
#endif
IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogInteractiveUiTest,
                       MAYBE_FirstPartyAllowed) {}

// Flaky on ChromeOS: crbug.com/1429381
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_ThirdPartyBlocked
#else
#define MAYBE_ThirdPartyBlocked
#endif
IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogInteractiveUiTest,
                       MAYBE_ThirdPartyBlocked) {}

// Flaky on ChromeOS: crbug.com/1429381
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_OnlyPartitionedBlockedThirdPartyCookies
#else
#define MAYBE_OnlyPartitionedBlockedThirdPartyCookies
#endif
IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogInteractiveUiTest,
                       MAYBE_OnlyPartitionedBlockedThirdPartyCookies) {}
// Flaky on ChromeOS: crbug.com/1429381
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_MixedPartitionedBlockedThirdPartyCookies
#else
#define MAYBE_MixedPartitionedBlockedThirdPartyCookies
#endif
IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogInteractiveUiTest,
                       MAYBE_MixedPartitionedBlockedThirdPartyCookies) {}

class PageSpecificSiteDataDialogIsolatedWebAppInteractiveUiTest
    : public PageSpecificSiteDataDialogInteractiveUiTest {};

// TODO(crbug.com/40776475): This test fails to pass on Mac with real app shims
// working.
#if BUILDFLAG(IS_MAC)
#define MAYBE_AppNameIsDisplayedInsteadOfHostname
#else
#define MAYBE_AppNameIsDisplayedInsteadOfHostname
#endif  // BUILDFLAG(IS_MAC)
IN_PROC_BROWSER_TEST_F(
    PageSpecificSiteDataDialogIsolatedWebAppInteractiveUiTest,
    MAYBE_AppNameIsDisplayedInsteadOfHostname) {}

class PageSpecificSiteDataDialogPrivacySandboxInteractiveUiTest
    : public PageSpecificSiteDataDialogInteractiveUiTest {};

IN_PROC_BROWSER_TEST_F(
    PageSpecificSiteDataDialogPrivacySandboxInteractiveUiTest,
    FirstPartyAllowed) {}