chromium/chrome/browser/permissions/contextual_notification_permission_ui_selector_unittest.cc

// Copyright 2019 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/permissions/contextual_notification_permission_ui_selector.h"

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

#include "base/memory/scoped_refptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/permissions/crowd_deny.pb.h"
#include "chrome/browser/permissions/crowd_deny_fake_safe_browsing_database_manager.h"
#include "chrome/browser/permissions/crowd_deny_preload_data.h"
#include "chrome/browser/permissions/quiet_notification_permission_ui_config.h"
#include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/permissions/request_type.h"
#include "components/permissions/test/mock_permission_request.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace {

QuietUiReason;
WarningReason;
Decision;

constexpr char kTestDomainUnknown[] =;
constexpr char kTestDomainAcceptable[] =;
constexpr char kTestDomainSpammy[] =;
constexpr char kTestDomainSpammyWarn[] =;
constexpr char kTestDomainAbusivePrompts[] =;
constexpr char kTestDomainAbusivePromptsWarn[] =;

constexpr char kTestOriginNoData[] =;
constexpr char kTestOriginUnknown[] =;
constexpr char kTestOriginAcceptable[] =;
constexpr char kTestOriginSpammy[] =;
constexpr char kTestOriginSpammyWarn[] =;
constexpr char kTestOriginAbusivePrompts[] =;
constexpr char kTestOriginSubDomainOfAbusivePrompts[] =;
constexpr char kTestOriginAbusivePromptsWarn[] =;
constexpr char kTestOriginAbusiveContent[] =;
constexpr char kTestOriginAbusiveContentWarn[] =;
constexpr char kTestOriginDisruptive[] =;

constexpr const char* kAllTestingOrigins[] =;

}  // namespace

class ContextualNotificationPermissionUiSelectorTest : public testing::Test {};

// With all the field trials enabled, test all combinations of:
//   (a) quiet UI being enabled/disabled in prefs, and
//   (b) positive/negative Safe Browsing verdicts.
// The ContextualNotificationPermissionUiSelector should only take into account
// the Safe Browsing verdict and ignore the user pref.
TEST_F(ContextualNotificationPermissionUiSelectorTest,
       PrefAndSafeBrowsingCombinations) {}

TEST_F(ContextualNotificationPermissionUiSelectorTest, FeatureDisabled) {}

// The feature is enabled but no triggers are enabled.
TEST_F(ContextualNotificationPermissionUiSelectorTest, AllTriggersDisabled) {}

// The feature is enabled but only the `crowd deny` trigger is enabled.
TEST_F(ContextualNotificationPermissionUiSelectorTest, OnlyCrowdDenyEnabled) {}

// The feature is enabled but only the `abusive content` trigger is enabled.
TEST_F(ContextualNotificationPermissionUiSelectorTest,
       OnlyAbusiveContentBlockingEnabled) {}

// The feature is enabled but only the `abusive content` warning is enabled.
TEST_F(ContextualNotificationPermissionUiSelectorTest,
       OnlyAbusiveContentWarningsEnabled) {}

// The feature is enabled but only the `abusive prompts` trigger is enabled.
TEST_F(ContextualNotificationPermissionUiSelectorTest,
       OnlyAbusivePromptBlockingEnabled) {}

// The feature is enabled but only the `abusive prompts` warning is enabled.
TEST_F(ContextualNotificationPermissionUiSelectorTest,
       OnlyAbusivePromptWarningsEnabled) {}

// The feature is enabled but only the `disruptive behavior` trigger is enabled.
TEST_F(ContextualNotificationPermissionUiSelectorTest,
       OnlyDisruptiveBehaviorRequestBlockingEnabled) {}

TEST_F(ContextualNotificationPermissionUiSelectorTest,
       CrowdDenyHoldbackChance) {}