Skip to content

Commit

Permalink
[PCLF] introduce a Peer class which later will be used to perform in-…
Browse files Browse the repository at this point in the history
…call actions

Bug: b/198796179
Change-Id: Ic4ea2b8d03cbc524334d72ef5c8b3ad1ecd39359
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231182
Commit-Queue: Artem Titov <[email protected]>
Reviewed-by: Mirko Bonadei <[email protected]>
Cr-Commit-Position: refs/heads/main@{#34920}
  • Loading branch information
titov-artem authored and WebRTC LUCI CQ committed Sep 3, 2021
1 parent 463d69a commit 79f82c1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
15 changes: 14 additions & 1 deletion api/test/peerconnection_quality_test_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@ class PeerConnectionE2EQualityTestFixture {
virtual void StopAndReportResults() = 0;
};

// Represents single participant in call and can be used to perform different
// in-call actions. Might be extended in future.
class PeerHandle {
public:
virtual ~PeerHandle() = default;
};

virtual ~PeerConnectionE2EQualityTestFixture() = default;

// Add activity that will be executed on the best effort at least after
Expand Down Expand Up @@ -493,7 +500,13 @@ class PeerConnectionE2EQualityTestFixture {
// `configurer` function will be used to configure peer in the call.
virtual void AddPeer(rtc::Thread* network_thread,
rtc::NetworkManager* network_manager,
rtc::FunctionView<void(PeerConfigurer*)> configurer) = 0;
rtc::FunctionView<void(PeerConfigurer*)> configurer) {}
virtual PeerHandle* AddAndReturnPeer(
rtc::Thread* network_thread,
rtc::NetworkManager* network_manager,
rtc::FunctionView<void(PeerConfigurer*)> configurer) {
return nullptr;
}
// Runs the media quality test, which includes setting up the call with
// configured participants, running it according to provided `run_params` and
// terminating it properly at the end. During call duration media quality
Expand Down
12 changes: 11 additions & 1 deletion test/pc/e2e/peer_connection_quality_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,23 @@ void PeerConnectionE2EQualityTest::AddQualityMetricsReporter(
quality_metrics_reporters_.push_back(std::move(quality_metrics_reporter));
}

void PeerConnectionE2EQualityTest::AddPeer(
PeerConnectionE2EQualityTest::PeerHandle*
PeerConnectionE2EQualityTest::AddAndReturnPeer(
rtc::Thread* network_thread,
rtc::NetworkManager* network_manager,
rtc::FunctionView<void(PeerConfigurer*)> configurer) {
peer_configurations_.push_back(
std::make_unique<PeerConfigurerImpl>(network_thread, network_manager));
configurer(peer_configurations_.back().get());
peer_handles_.push_back(PeerHandleImpl());
return &peer_handles_.back();
}

void PeerConnectionE2EQualityTest::AddPeer(
rtc::Thread* network_thread,
rtc::NetworkManager* network_manager,
rtc::FunctionView<void(PeerConfigurer*)> configurer) {
AddAndReturnPeer(network_thread, network_manager, configurer);
}

void PeerConnectionE2EQualityTest::Run(RunParams run_params) {
Expand Down
10 changes: 10 additions & 0 deletions test/pc/e2e/peer_connection_quality_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class PeerConnectionE2EQualityTest
void AddPeer(rtc::Thread* network_thread,
rtc::NetworkManager* network_manager,
rtc::FunctionView<void(PeerConfigurer*)> configurer) override;
PeerHandle* AddAndReturnPeer(
rtc::Thread* network_thread,
rtc::NetworkManager* network_manager,
rtc::FunctionView<void(PeerConfigurer*)> configurer) override;
void Run(RunParams run_params) override;

TimeDelta GetRealTestDuration() const override {
Expand All @@ -80,6 +84,11 @@ class PeerConnectionE2EQualityTest
}

private:
class PeerHandleImpl : public PeerHandle {
public:
~PeerHandleImpl() override = default;
};

// For some functionality some field trials have to be enabled, they will be
// enabled in Run().
std::string GetFieldTrials(const RunParams& run_params);
Expand Down Expand Up @@ -114,6 +123,7 @@ class PeerConnectionE2EQualityTest
std::unique_ptr<TestActivitiesExecutor> executor_;

std::vector<std::unique_ptr<PeerConfigurerImpl>> peer_configurations_;
std::vector<PeerHandleImpl> peer_handles_;

std::unique_ptr<TestPeer> alice_;
std::unique_ptr<TestPeer> bob_;
Expand Down

0 comments on commit 79f82c1

Please sign in to comment.