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

Side by Side Diff: components/test_runner/mock_webrtc_peer_connection_handler.h

Issue 2707183003: Move //components/test_runner back into //content/shell (Closed)
Patch Set: Trim DEPS Created 3 years, 10 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
(Empty)
1 // Copyright 2014 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 COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_PEER_CONNECTION_HANDLER_H_
6 #define COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_PEER_CONNECTION_HANDLER_H_
7
8 #include <map>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "third_party/WebKit/public/platform/WebRTCError.h"
13 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h"
14 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h"
15 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h"
16 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h"
17
18 namespace blink {
19 class WebRTCPeerConnectionHandlerClient;
20 };
21
22 namespace test_runner {
23
24 class TestInterfaces;
25
26 class MockWebRTCPeerConnectionHandler
27 : public blink::WebRTCPeerConnectionHandler {
28 public:
29 MockWebRTCPeerConnectionHandler(
30 blink::WebRTCPeerConnectionHandlerClient* client,
31 TestInterfaces* interfaces);
32 ~MockWebRTCPeerConnectionHandler() override;
33
34 // WebRTCPeerConnectionHandler related methods
35 bool initialize(const blink::WebRTCConfiguration& configuration,
36 const blink::WebMediaConstraints& constraints) override;
37
38 void createOffer(const blink::WebRTCSessionDescriptionRequest& request,
39 const blink::WebMediaConstraints& constraints) override;
40 void createOffer(const blink::WebRTCSessionDescriptionRequest& request,
41 const blink::WebRTCOfferOptions& options) override;
42 void createAnswer(const blink::WebRTCSessionDescriptionRequest& request,
43 const blink::WebMediaConstraints& constraints) override;
44 void createAnswer(const blink::WebRTCSessionDescriptionRequest& request,
45 const blink::WebRTCAnswerOptions& options) override;
46 void setLocalDescription(
47 const blink::WebRTCVoidRequest& request,
48 const blink::WebRTCSessionDescription& local_description) override;
49 void setRemoteDescription(
50 const blink::WebRTCVoidRequest& request,
51 const blink::WebRTCSessionDescription& remote_description) override;
52 blink::WebRTCSessionDescription localDescription() override;
53 blink::WebRTCSessionDescription remoteDescription() override;
54 blink::WebRTCErrorType setConfiguration(
55 const blink::WebRTCConfiguration& configuration) override;
56 bool addICECandidate(const blink::WebRTCICECandidate& ice_candidate) override;
57 bool addICECandidate(const blink::WebRTCVoidRequest& request,
58 const blink::WebRTCICECandidate& ice_candidate) override;
59 bool addStream(const blink::WebMediaStream& stream,
60 const blink::WebMediaConstraints& constraints) override;
61 void removeStream(const blink::WebMediaStream& stream) override;
62 void getStats(const blink::WebRTCStatsRequest& request) override;
63 void getStats(std::unique_ptr<blink::WebRTCStatsReportCallback>) override;
64 blink::WebRTCDataChannelHandler* createDataChannel(
65 const blink::WebString& label,
66 const blink::WebRTCDataChannelInit& init) override;
67 blink::WebRTCDTMFSenderHandler* createDTMFSender(
68 const blink::WebMediaStreamTrack& track) override;
69 void stop() override;
70
71 private:
72 MockWebRTCPeerConnectionHandler();
73
74 // UpdateRemoteStreams uses the collection of |local_streams_| to create
75 // remote MediaStreams with the same number of tracks and notifies |client_|
76 // about added and removed streams. It's triggered when setRemoteDescription
77 // is called.
78 void UpdateRemoteStreams();
79
80 void ReportInitializeCompleted();
81 void ReportCreationOfDataChannel();
82
83 void PostRequestResult(
84 const blink::WebRTCSessionDescriptionRequest& request,
85 const blink::WebRTCSessionDescription& session_description);
86 void PostRequestFailure(
87 const blink::WebRTCSessionDescriptionRequest& request);
88 void PostRequestResult(const blink::WebRTCVoidRequest& request);
89 void PostRequestFailure(const blink::WebRTCVoidRequest& request);
90
91 blink::WebRTCPeerConnectionHandlerClient* client_;
92 bool stopped_;
93 blink::WebRTCSessionDescription local_description_;
94 blink::WebRTCSessionDescription remote_description_;
95 int stream_count_;
96 TestInterfaces* interfaces_;
97 typedef std::map<std::string, blink::WebMediaStream> StreamMap;
98 StreamMap local_streams_;
99 StreamMap remote_streams_;
100
101 base::WeakPtrFactory<MockWebRTCPeerConnectionHandler> weak_factory_;
102
103 DISALLOW_COPY_AND_ASSIGN(MockWebRTCPeerConnectionHandler);
104 };
105
106 } // namespace test_runner
107
108 #endif // COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_PEER_CONNECTION_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698