chromium/extensions/browser/test_event_router.h

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

#ifndef EXTENSIONS_BROWSER_TEST_EVENT_ROUTER_H_
#define EXTENSIONS_BROWSER_TEST_EVENT_ROUTER_H_

#include <map>
#include <memory>
#include <string>
#include <type_traits>

#include "base/functional/bind.h"
#include "base/observer_list.h"
#include "base/scoped_observation_traits.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/event_router_factory.h"
#include "extensions/common/extension_id.h"

namespace extensions {

// An EventRouter that tests can use to observe, await, or verify events
// dispatched to an extension.
class TestEventRouter : public EventRouter {};

// Creates and enables a TestEventRouter for testing. Callers can override T to
// provide a derived event router.
template <typename T = TestEventRouter>
T* CreateAndUseTestEventRouter(content::BrowserContext* context) {}

}  // namespace extensions

namespace base {

template <>
struct ScopedObservationTraits<extensions::TestEventRouter,
                               extensions::TestEventRouter::EventObserver> {};

}  // namespace base

#endif  // EXTENSIONS_BROWSER_TEST_EVENT_ROUTER_H_