mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 916187. Part 2. Using the test stun server, write some tests to exercise the checking logic written in 908740. r=abr
This commit is contained in:
parent
baa0c1e9c7
commit
18a2f387e5
@ -11,6 +11,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <mozilla/Scoped.h>
|
#include <mozilla/Scoped.h>
|
||||||
#include <m_cpp_utils.h>
|
#include <m_cpp_utils.h>
|
||||||
|
#include <nsISupportsImpl.h>
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
@ -602,6 +602,28 @@ class IceGatherTest : public ::testing::Test {
|
|||||||
|
|
||||||
ASSERT_TRUE_WAIT(peer_->gathering_complete(), 10000);
|
ASSERT_TRUE_WAIT(peer_->gathering_complete(), 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UseFakeStunServerWithResponse(const std::string& fake_addr,
|
||||||
|
uint16_t fake_port) {
|
||||||
|
TestStunServer::GetInstance()->SetResponseAddr(fake_addr, fake_port);
|
||||||
|
// Sets an additional stun server
|
||||||
|
peer_->SetStunServer(TestStunServer::GetInstance()->addr(),
|
||||||
|
TestStunServer::GetInstance()->port());
|
||||||
|
}
|
||||||
|
|
||||||
|
// NB: Only does substring matching, watch out for stuff like "1.2.3.4"
|
||||||
|
// matching "21.2.3.47". " 1.2.3.4 " should not have false positives.
|
||||||
|
bool StreamHasMatchingCandidate(unsigned int stream,
|
||||||
|
const std::string& match) {
|
||||||
|
std::vector<std::string> candidates = peer_->GetCandidates(stream);
|
||||||
|
for (size_t c = 0; c < candidates.size(); ++c) {
|
||||||
|
if (std::string::npos != candidates[c].find(match)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mozilla::ScopedDeletePtr<IceTestPeer> peer_;
|
mozilla::ScopedDeletePtr<IceTestPeer> peer_;
|
||||||
};
|
};
|
||||||
@ -876,6 +898,30 @@ TEST_F(IceGatherTest, TestBogusCandidate) {
|
|||||||
peer_->ParseCandidate(0, kBogusIceCandidate);
|
peer_->ParseCandidate(0, kBogusIceCandidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(IceGatherTest, VerifyTestStunServer) {
|
||||||
|
UseFakeStunServerWithResponse("192.0.2.133", 3333);
|
||||||
|
Gather();
|
||||||
|
ASSERT_TRUE(StreamHasMatchingCandidate(0, " 192.0.2.133 3333 "));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(IceGatherTest, TestStunServerReturnsWildcardAddr) {
|
||||||
|
UseFakeStunServerWithResponse("0.0.0.0", 3333);
|
||||||
|
Gather();
|
||||||
|
ASSERT_FALSE(StreamHasMatchingCandidate(0, " 0.0.0.0 "));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(IceGatherTest, TestStunServerReturnsPort0) {
|
||||||
|
UseFakeStunServerWithResponse("192.0.2.133", 0);
|
||||||
|
Gather();
|
||||||
|
ASSERT_FALSE(StreamHasMatchingCandidate(0, " 192.0.2.133 0 "));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(IceGatherTest, TestStunServerReturnsLoopbackAddr) {
|
||||||
|
UseFakeStunServerWithResponse("127.0.0.133", 3333);
|
||||||
|
Gather();
|
||||||
|
ASSERT_FALSE(StreamHasMatchingCandidate(0, " 127.0.0.133 "));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(IceConnectTest, TestGather) {
|
TEST_F(IceConnectTest, TestGather) {
|
||||||
AddStream("first", 1);
|
AddStream("first", 1);
|
||||||
ASSERT_TRUE(Gather(true));
|
ASSERT_TRUE(Gather(true));
|
||||||
|
Loading…
Reference in New Issue
Block a user