1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CAST_STREAMING_MOCK_ENVIRONMENT_H_ 6 #define CAST_STREAMING_MOCK_ENVIRONMENT_H_ 7 8 #include "cast/streaming/environment.h" 9 #include "gmock/gmock.h" 10 11 namespace openscreen { 12 namespace cast { 13 14 // An Environment that can intercept all packet sends, for unit testing. 15 class MockEnvironment : public Environment { 16 public: 17 MockEnvironment(ClockNowFunctionPtr now_function, TaskRunner* task_runner); 18 ~MockEnvironment() override; 19 20 // Used to return fake values, to simulate a bound socket for testing. 21 MOCK_METHOD(IPEndpoint, GetBoundLocalEndpoint, (), (const, override)); 22 23 // Used for intercepting packet sends from the implementation under test. 24 MOCK_METHOD(void, SendPacket, (absl::Span<const uint8_t> packet), (override)); 25 }; 26 27 } // namespace cast 28 } // namespace openscreen 29 30 #endif // CAST_STREAMING_MOCK_ENVIRONMENT_H_ 31