aboutsummaryrefslogtreecommitdiff
path: root/cast/streaming/environment.h
diff options
context:
space:
mode:
authorYuri Wiitala <miu@chromium.org>2020-02-11 17:09:31 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-12 23:31:24 +0000
commitb0b4bb3063d8b1d161167f183fdeb538acba48b7 (patch)
tree79b7a3040913866c1bfd9ec1da52ef78f1e85d30 /cast/streaming/environment.h
parent56606fd06540122a05c4cb8f231921d09de734b4 (diff)
downloadopenscreen-b0b4bb3063d8b1d161167f183fdeb538acba48b7.tar.gz
Crash fix: Prevent a unit test from using a real UDP socket.
The code in receiver_session_unittest.cc was creating an Environment instance that was binding a real UDP socket. Also, when the test was running in a Chrome embedder build of the openscreen_unittests, the result was a segfault because a full browser environment was not present. To fix this, a MockEnvironment class (subclass of Environment) is used to intercept socket calls and provide a fake local address/port for the tests to work with. Change-Id: I59a06ed12b58a1ba14d228cad7cd8dfffafc9bb2 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2051319 Reviewed-by: Jordan Bayles <jophba@chromium.org> Commit-Queue: Yuri Wiitala <miu@chromium.org>
Diffstat (limited to 'cast/streaming/environment.h')
-rw-r--r--cast/streaming/environment.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/cast/streaming/environment.h b/cast/streaming/environment.h
index 681715dd..278604b0 100644
--- a/cast/streaming/environment.h
+++ b/cast/streaming/environment.h
@@ -47,7 +47,10 @@ class Environment : public UdpSocket::Client {
// Returns the local endpoint the socket is bound to, or the zero IPEndpoint
// if socket creation/binding failed.
- IPEndpoint GetBoundLocalEndpoint() const;
+ //
+ // Note: This method is virtual to allow unit tests to fake that there really
+ // is a bound socket.
+ virtual IPEndpoint GetBoundLocalEndpoint() const;
// Set a handler function to run whenever non-recoverable socket errors occur.
// If never set, the default is to emit log messages at error priority.