webrtc_m130/test/network/emulated_network_manager.h
Sebastian Jansson f1173f46e5 Revert "Using simulated rtc::Thread for peer connection scenario tests."
This reverts commit b70c5c5ce97e7dcf2e1d8453f5ea0639d4b60453.

Reason for revert: Interferes with other tests in same binary.

Original change's description:
> Using simulated rtc::Thread for peer connection scenario tests.
> 
> Bug: webrtc:11255
> Change-Id: I5d29e997a7209ffc64595082358cca9b2115d07a
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165689
> Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> Reviewed-by: Steve Anton <steveanton@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#30258}

TBR=steveanton@webrtc.org,srte@webrtc.org

Change-Id: If2e60edae264a4bb0dee3abf66ba2078fd85f493
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:11255
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166045
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30259}
2020-01-15 10:10:07 +00:00

71 lines
2.4 KiB
C++

/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef TEST_NETWORK_EMULATED_NETWORK_MANAGER_H_
#define TEST_NETWORK_EMULATED_NETWORK_MANAGER_H_
#include <memory>
#include <vector>
#include "api/test/network_emulation_manager.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/network.h"
#include "rtc_base/socket_server.h"
#include "rtc_base/thread.h"
#include "rtc_base/thread_checker.h"
#include "test/network/network_emulation.h"
namespace webrtc {
namespace test {
// Framework assumes that rtc::NetworkManager is called from network thread.
class EmulatedNetworkManager : public rtc::NetworkManagerBase,
public sigslot::has_slots<>,
public EmulatedNetworkManagerInterface {
public:
EmulatedNetworkManager(Clock* clock,
TaskQueueForTest* task_queue,
EndpointsContainer* endpoints_container);
void EnableEndpoint(EmulatedEndpointImpl* endpoint);
void DisableEndpoint(EmulatedEndpointImpl* endpoint);
// NetworkManager interface. All these methods are supposed to be called from
// the same thread.
void StartUpdating() override;
void StopUpdating() override;
// We don't support any address interfaces in the network emulation framework.
void GetAnyAddressNetworks(NetworkList* networks) override {}
// EmulatedNetworkManagerInterface API
rtc::Thread* network_thread() override { return network_thread_.get(); }
rtc::NetworkManager* network_manager() override { return this; }
void GetStats(
std::function<void(EmulatedNetworkStats)> stats_callback) const override;
private:
void UpdateNetworksOnce();
void MaybeSignalNetworksChanged();
TaskQueueForTest* const task_queue_;
EndpointsContainer* const endpoints_container_;
std::unique_ptr<rtc::Thread> network_thread_;
bool sent_first_update_ RTC_GUARDED_BY(network_thread_);
int start_count_ RTC_GUARDED_BY(network_thread_);
};
} // namespace test
} // namespace webrtc
#endif // TEST_NETWORK_EMULATED_NETWORK_MANAGER_H_