#include "components/device_signals/core/browser/user_permission_service_impl.h"
#include <optional>
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/device_signals/core/browser/mock_user_delegate.h"
#include "components/device_signals/core/browser/pref_names.h"
#include "components/device_signals/core/browser/user_context.h"
#include "components/device_signals/core/browser/user_delegate.h"
#include "components/device_signals/core/common/signals_features.h"
#include "components/policy/core/common/management/management_service.h"
#include "components/policy/core/common/management/scoped_management_service_override_for_testing.h"
#include "components/prefs/pref_registry.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
EnterpriseManagementAuthority;
ScopedManagementServiceOverrideForTesting;
_;
AnyNumber;
Return;
namespace device_signals {
namespace {
class TestManagementService : public policy::ManagementService { … };
}
class UserPermissionServiceImplTest : public testing::Test,
public testing::WithParamInterface<bool> { … };
TEST_P(UserPermissionServiceImplTest, ShouldCollectConsent_ConsentGiven) { … }
TEST_P(UserPermissionServiceImplTest,
ShouldCollectConsent_PermanentConsentGiven) { … }
struct DeviceManagedSpecificPolicyTestCase { … };
TEST_P(UserPermissionServiceImplTest, ShouldCollectConsent_DeviceCloudManaged) { … }
TEST_P(UserPermissionServiceImplTest,
ShouldCollectConsent_NoEnableConsentFlowPolicy) { … }
TEST_P(UserPermissionServiceImplTest,
ShouldCollectConsent_SpecificPolicy_ManagedUser) { … }
struct DeviceManagedDependentPolicyTestCase { … };
TEST_P(UserPermissionServiceImplTest,
ShouldCollectConsent_ManagedDevice_DependentPolicy) { … }
TEST_P(UserPermissionServiceImplTest,
ShouldCollectConsent_UnmanagedDevice_DependentPolicy) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
namespace {
constexpr char kUserGaiaId[] = …;
}
TEST_P(UserPermissionServiceImplTest, CanUserCollectSignals_EmptyUserId) { … }
TEST_P(UserPermissionServiceImplTest,
CanUserCollectSignals_UserId_NotSameUser) { … }
TEST_P(UserPermissionServiceImplTest, CanUserCollectSignals_User_NotManaged) { … }
TEST_P(UserPermissionServiceImplTest,
CanUserCollectSignals_BrowserNotManaged_NoConsent) { … }
TEST_P(UserPermissionServiceImplTest,
CanUserCollectSignals_BrowserNotManaged_WithConsent) { … }
TEST_P(UserPermissionServiceImplTest,
CanUserCollectSignals_BrowserManaged_ProfileUser_Unaffiliated) { … }
TEST_P(UserPermissionServiceImplTest,
CanUserCollectSignals_BrowserManaged_ProfileUser_Affiliated) { … }
#endif
TEST_P(UserPermissionServiceImplTest, CanCollectSignals_AlreadyConsented) { … }
TEST_P(UserPermissionServiceImplTest, CanCollectSignals_PermanentConsent) { … }
TEST_P(UserPermissionServiceImplTest, CanCollectSignals_BrowserNotManaged) { … }
TEST_P(UserPermissionServiceImplTest,
CanCollectSignals_BrowserManaged_UnmanagedUser) { … }
TEST_P(UserPermissionServiceImplTest,
CanCollectSignals_BrowserManaged_AffiliatedUser) { … }
struct UnaffiliatedUserTestCase { … };
TEST_P(UserPermissionServiceImplTest,
CanCollectSignals_BrowserManaged_UnaffiliatedUser) { … }
INSTANTIATE_TEST_SUITE_P(…);
}