chromium/components/invalidation/impl/invalidator_registrar_with_memory_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 "components/invalidation/impl/invalidator_registrar_with_memory.h"

#include <memory>

#include "base/json/json_reader.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/scoped_feature_list.h"
#include "components/invalidation/impl/fake_invalidation_handler.h"
#include "components/invalidation/public/invalidation.h"
#include "components/invalidation/public/invalidation_util.h"
#include "components/invalidation/public/invalidator_state.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"

IsEmpty;
Pair;
UnorderedElementsAre;

namespace invalidation {

namespace {

template <class... Inv>
void Dispatch(InvalidatorRegistrarWithMemory& registrar, Inv... inv) {}

template <class... Topic>
void DispatchSuccessfullySubscribed(InvalidatorRegistrarWithMemory& registrar,
                                    Topic... topics) {}

template <class... Inv>
std::map<Topic, Invalidation> ExpectedInvalidations(Inv... inv) {}

constexpr char kTopicsToHandler[] =;

class InvalidatorRegistrarWithMemoryTest : public testing::Test {};

// Initialize the invalidator, register a handler, register some topics for that
// handler, and then unregister the handler, dispatching invalidations in
// between. The handler should only see invalidations when it's registered and
// its topics are registered.
TEST_F(InvalidatorRegistrarWithMemoryTest, Basic) {}

// Register handlers and some topics for those handlers, register a handler with
// no topics, and register a handler with some topics but unregister it. Then,
// dispatch some invalidations. Handlers that are not registered should not get
// invalidations, and the ones that have registered topics should receive
// invalidations for those topics.
TEST_F(InvalidatorRegistrarWithMemoryTest, MultipleHandlers) {}

// Multiple registrations by different handlers on the same topic should
// return false.
TEST_F(InvalidatorRegistrarWithMemoryTest, MultipleRegistrations) {}

// Make sure that passing an empty set to UpdateRegisteredTopics clears the
// corresponding entries for the handler.
TEST_F(InvalidatorRegistrarWithMemoryTest, EmptySetUnregisters) {}

TEST_F(InvalidatorRegistrarWithMemoryTest, RestoresInterestingTopics) {}

// This test verifies that topics are not unsubscribed after browser restart
// even if it's not registered using UpdateRegisteredTopics() method. This is
// useful for Sync invalidations to prevent unsubscribing from some data types
// which require more time to initialize and which are added later in following
// UpdateRegisteredTopics() calls.
//
// TODO(crbug.com/40674001): make the unsubscription behaviour consistent
// regardless of browser restart in between.
TEST_F(InvalidatorRegistrarWithMemoryTest,
       ShouldKeepSubscriptionsAfterRestart) {}

}  // namespace

}  // namespace invalidation