#include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"
#include <stdint.h>
#include <memory>
#include "base/compiler_specific.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "base/test/test_simple_task_runner.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler_observer.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_service.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_store.h"
#include "mock_user_cloud_policy_store.h"
#include "services/network/test/test_network_connection_tracker.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
em;
_;
Invoke;
Mock;
namespace policy {
namespace {
const int64_t kPolicyRefreshRate = …;
const int64_t kInitialCacheAgeMinutes = …;
constexpr auto kTestReason = …;
class MockObserver : public CloudPolicyRefreshSchedulerObserver { … };
}
class CloudPolicyRefreshSchedulerTest : public testing::Test { … };
TEST_F(CloudPolicyRefreshSchedulerTest, InitialRefreshNoPolicy) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, InitialRefreshUnmanaged) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, InitialRefreshManagedNotYetFetched) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, InitialRefreshManagedAlreadyFetched) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, Unregistered) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, RefreshSoon) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, RefreshSoonOverriding) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, InvalidationsAvailable) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, InvalidationsNotAvailable) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, InvalidationsOffAndOn) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, InvalidationsDisconnected) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, OnConnectionChangedUnregistered) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, OnConnectionChangedAfterSleep) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, FetchAttemptCallback) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, DestructionCallback) { … }
TEST_F(CloudPolicyRefreshSchedulerTest, DestructionCallbackBeforeFetchAttempt) { … }
class CloudPolicyRefreshSchedulerSteadyStateTest
: public CloudPolicyRefreshSchedulerTest { … };
TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnPolicyFetched) { … }
TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnRegistrationStateChanged) { … }
TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnStoreLoaded) { … }
TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnStoreError) { … }
TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, RefreshDelayChange) { … }
TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnConnectionChanged) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest,
SignatureValidationFailedAndRetry) { … }
#endif
struct ClientErrorTestParam { … };
constexpr PolicyFetchReason kUnspecified = …;
static const ClientErrorTestParam kClientErrorTestCases[] = …;
class CloudPolicyRefreshSchedulerClientErrorTest
: public CloudPolicyRefreshSchedulerSteadyStateTest,
public testing::WithParamInterface<ClientErrorTestParam> { … };
TEST_P(CloudPolicyRefreshSchedulerClientErrorTest, OnClientError) { … }
INSTANTIATE_TEST_SUITE_P(…);
}