chromium/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc

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

#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 {};

}  // namespace

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) {}

// TODO(igorcov): Before sleep in normal flow there's a task pending. When the
// device wakes up, OnConnectionChanged is called which should cancel the
// pending task and queue a new task to run earlier. It is desirable to
// simulate that flow here.
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  // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)

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();

}  // namespace policy