chromium/net/base/backoff_entry_serializer_unittest.cc

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

#include "net/base/backoff_entry.h"

#include "base/containers/span.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/backoff_entry_serializer.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace net {

namespace {

Time;
TimeTicks;

const Time kParseTime =;  // May 2015 for realism

BackoffEntry::Policy base_policy =;

class TestTickClock : public base::TickClock {};

// This test exercises the code that computes the "backoff duration" and tests
// BackoffEntrySerializer::SerializeToList computes the backoff duration of a
// BackoffEntry by subtracting two base::TimeTicks values. Note that
// base::TimeTicks::operator- does not protect against overflow. Because
// SerializeToList never returns null, its resolution strategy is to default to
// a zero base::TimeDelta when the subtraction would overflow.
TEST(BackoffEntrySerializerTest, SpecialCasesOfBackoffDuration) {}

// This test verifies that BackoffEntrySerializer::SerializeToList will not
// serialize an infinite release time.
//
// In pseudocode, this is how absolute_release_time is computed:
//   backoff_duration = release_time - now;
//   absolute_release_time = backoff_duration + original_time;
//
// This test induces backoff_duration to be a nonzero duration and directly sets
// original_time as a large value, such that their addition will overflow.
TEST(BackoffEntrySerializerTest, SerializeFiniteReleaseTime) {}

TEST(BackoffEntrySerializerTest, SerializeNoFailures) {}

// Test that deserialization fails instead of producing an entry with an
// infinite release time. (Regression test for https://crbug.com/1293904)
TEST(BackoffEntrySerializerTest, DeserializeNeverInfiniteReleaseTime) {}

TEST(BackoffEntrySerializerTest, SerializeTimeOffsets) {}

TEST(BackoffEntrySerializerTest, DeserializeUnknownVersion) {}

TEST(BackoffEntrySerializerTest, DeserializeVersion1) {}

TEST(BackoffEntrySerializerTest, DeserializeVersion2) {}

TEST(BackoffEntrySerializerTest, DeserializeVersion2NegativeDuration) {}

TEST(BackoffEntrySerializerTest, DeserializeVersion1WrongDurationType) {}

TEST(BackoffEntrySerializerTest, DeserializeVersion2WrongDurationType) {}

}  // namespace

}  // namespace net