Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: content/renderer/media/peer_connection_tracker_unittest.cc

Issue 2263373003: Android: move peerconnection out of power observer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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(new PeerConnectionTracker_OnSuspend());
98 tracker.OnControlMessageReceived(*message.get());
99 }
100
80 // TODO(hta): Write tests for the other tracking functions. 101 // TODO(hta): Write tests for the other tracking functions.
81 102
82 } // namespace 103 } // namespace
OLDNEW
« no previous file with comments | « content/renderer/media/peer_connection_tracker.cc ('k') | content/renderer/media/rtc_peer_connection_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698