Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/peer_connection_tracker.h" | 5 #include "content/renderer/media/peer_connection_tracker.h" |
| 6 | 6 |
| 7 #include "content/common/media/peer_connection_tracker_messages.h" | 7 #include "content/common/media/peer_connection_tracker_messages.h" |
| 8 #include "content/public/test/mock_render_thread.h" | 8 #include "content/public/test/mock_render_thread.h" |
| 9 #include "content/renderer/media/mock_web_rtc_peer_connection_handler_client.h" | 9 #include "content/renderer/media/mock_web_rtc_peer_connection_handler_client.h" |
| 10 #include "content/renderer/media/rtc_peer_connection_handler.h" | 10 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, | 37 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, |
| 38 OnAddPeerConnection) | 38 OnAddPeerConnection) |
| 39 IPC_MESSAGE_UNHANDLED(handled = false) | 39 IPC_MESSAGE_UNHANDLED(handled = false) |
| 40 IPC_END_MESSAGE_MAP() | 40 IPC_END_MESSAGE_MAP() |
| 41 return handled; | 41 return handled; |
| 42 } | 42 } |
| 43 | 43 |
| 44 class MockPeerConnectionHandler : public RTCPeerConnectionHandler { | 44 class MockPeerConnectionHandler : public RTCPeerConnectionHandler { |
| 45 public: | 45 public: |
| 46 MockPeerConnectionHandler() : RTCPeerConnectionHandler(&client_, nullptr) {} | 46 MockPeerConnectionHandler() : RTCPeerConnectionHandler(&client_, nullptr) {} |
| 47 MOCK_METHOD0(CloseClientPeerConnection, void()); | |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 MockWebRTCPeerConnectionHandlerClient client_; | 50 MockWebRTCPeerConnectionHandlerClient client_; |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 } // namespace | 53 } // namespace |
| 53 | 54 |
| 54 TEST(PeerConnectionTrackerTest, CreatingObject) { | 55 TEST(PeerConnectionTrackerTest, CreatingObject) { |
| 55 PeerConnectionTracker tracker; | 56 PeerConnectionTracker tracker; |
| 56 } | 57 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 70 tracker.RegisterPeerConnection(&pc_handler, config, constraints, nullptr); | 71 tracker.RegisterPeerConnection(&pc_handler, config, constraints, nullptr); |
| 71 // Back to the test. | 72 // Back to the test. |
| 72 EXPECT_CALL(target_thread, | 73 EXPECT_CALL(target_thread, |
| 73 OnUpdatePeerConnection( | 74 OnUpdatePeerConnection( |
| 74 _, "createOffer", | 75 _, "createOffer", |
| 75 "options: {offerToReceiveVideo: 0, offerToReceiveAudio: 0, " | 76 "options: {offerToReceiveVideo: 0, offerToReceiveAudio: 0, " |
| 76 "voiceActivityDetection: false, iceRestart: false}")); | 77 "voiceActivityDetection: false, iceRestart: false}")); |
| 77 tracker.TrackCreateOffer(&pc_handler, options); | 78 tracker.TrackCreateOffer(&pc_handler, options); |
| 78 } | 79 } |
| 79 | 80 |
| 81 TEST(PeerConnectionTrackerTest, OnSuspend) { | |
| 82 PeerConnectionTracker tracker; | |
| 83 // Initialization stuff. | |
| 84 MockPeerConnectionHandler pc_handler; | |
| 85 MockSendTargetThread target_thread; | |
| 86 webrtc::PeerConnectionInterface::RTCConfiguration config; | |
| 87 blink::WebMediaConstraints constraints; | |
| 88 tracker.OverrideSendTargetForTesting(&target_thread); | |
| 89 EXPECT_CALL(target_thread, OnAddPeerConnection(_)); | |
| 90 tracker.RegisterPeerConnection(&pc_handler, config, constraints, nullptr); | |
| 91 // Back to the test. | |
| 92 #if defined(OS_ANDROID) | |
| 93 EXPECT_CALL(pc_handler, CloseClientPeerConnection()).Times(0); | |
| 94 #else | |
| 95 EXPECT_CALL(pc_handler, CloseClientPeerConnection()); | |
| 96 #endif | |
| 97 std::unique_ptr<IPC::Message> message( | |
|
hta - Chromium
2016/08/29 15:07:13
These 3 lines are indented oddly. Time for git cl
| |
| 98 new PeerConnectionTracker_OnSuspend()); | |
| 99 tracker.OnControlMessageReceived(*message.get()); | |
| 100 } | |
| 101 | |
| 80 // TODO(hta): Write tests for the other tracking functions. | 102 // TODO(hta): Write tests for the other tracking functions. |
| 81 | 103 |
| 82 } // namespace | 104 } // namespace |
| OLD | NEW |