chromium/components/performance_manager/test_support/voting.h

// 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.

#ifndef COMPONENTS_PERFORMANCE_MANAGER_TEST_SUPPORT_VOTING_H_
#define COMPONENTS_PERFORMANCE_MANAGER_TEST_SUPPORT_VOTING_H_

#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/not_fatal_until.h"
#include "components/performance_manager/public/voting/voting.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace performance_manager {
namespace voting {
namespace test {

// A dummy observer that simply maintains a list of all submitted votes.
template <class VoteImpl>
class DummyVoteObserver : public VoteObserver<VoteImpl> {};

template <class VoteImpl>
DummyVoteObserver<VoteImpl>::DummyVoteObserver() = default;

template <class VoteImpl>
DummyVoteObserver<VoteImpl>::~DummyVoteObserver() = default;

template <class VoteImpl>
VotingChannel<VoteImpl> DummyVoteObserver<VoteImpl>::BuildVotingChannel() {}

template <class VoteImpl>
size_t DummyVoteObserver<VoteImpl>::GetVoteCount() const {}

template <class VoteImpl>
size_t DummyVoteObserver<VoteImpl>::GetVoteCountForVoterId(
    voting::VoterId<VoteImpl> voter_id) const {}

template <class VoteImpl>
size_t DummyVoteObserver<VoteImpl>::GetVoteCountForContext(
    const typename VoteImpl::ContextType* context) const {}

template <class VoteImpl>
bool DummyVoteObserver<VoteImpl>::HasVote(
    voting::VoterId<VoteImpl> voter_id,
    const typename VoteImpl::ContextType* context) const {}

template <class VoteImpl>
bool DummyVoteObserver<VoteImpl>::HasVote(
    voting::VoterId<VoteImpl> voter_id,
    const typename VoteImpl::ContextType* context,
    const VoteImpl& vote) const {}

template <class VoteImpl>
bool DummyVoteObserver<VoteImpl>::HasVote(
    voting::VoterId<VoteImpl> voter_id,
    const typename VoteImpl::ContextType* context,
    typename VoteImpl::VoteType vote_value,
    const char* reason) const {}

template <class VoteImpl>
void DummyVoteObserver<VoteImpl>::OnVoteSubmitted(VoterId<VoteImpl> voter_id,
                                                  const ContextType* context,
                                                  const VoteImpl& vote) {}

template <class VoteImpl>
void DummyVoteObserver<VoteImpl>::OnVoteChanged(VoterId<VoteImpl> voter_id,
                                                const ContextType* context,
                                                const VoteImpl& new_vote) {}

template <class VoteImpl>
void DummyVoteObserver<VoteImpl>::OnVoteInvalidated(
    VoterId<VoteImpl> voter_id,
    const ContextType* context) {}

}  // namespace test
}  // namespace voting
}  // namespace performance_manager

#endif  // COMPONENTS_PERFORMANCE_MANAGER_TEST_SUPPORT_VOTING_H_