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

Side by Side Diff: webrtc/api/rtcstatscollector_unittest.cc

Issue 2353033005: Refactoring: move ownership of RtcEventLog from Call to PeerConnection (Closed)
Patch Set: Make TSan happy Created 4 years, 2 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 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/rtcstatscollector.h" 11 #include "webrtc/api/rtcstatscollector.h"
12 12
13 #include <memory> 13 #include <memory>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/api/jsepsessiondescription.h" 17 #include "webrtc/api/jsepsessiondescription.h"
18 #include "webrtc/api/stats/rtcstats_objects.h" 18 #include "webrtc/api/stats/rtcstats_objects.h"
19 #include "webrtc/api/stats/rtcstatsreport.h" 19 #include "webrtc/api/stats/rtcstatsreport.h"
20 #include "webrtc/api/test/mock_datachannel.h" 20 #include "webrtc/api/test/mock_datachannel.h"
21 #include "webrtc/api/test/mock_peerconnection.h" 21 #include "webrtc/api/test/mock_peerconnection.h"
22 #include "webrtc/api/test/mock_webrtcsession.h" 22 #include "webrtc/api/test/mock_webrtcsession.h"
23 #include "webrtc/base/checks.h" 23 #include "webrtc/base/checks.h"
24 #include "webrtc/base/fakeclock.h" 24 #include "webrtc/base/fakeclock.h"
25 #include "webrtc/base/gunit.h" 25 #include "webrtc/base/gunit.h"
26 #include "webrtc/base/logging.h" 26 #include "webrtc/base/logging.h"
27 #include "webrtc/base/thread_checker.h" 27 #include "webrtc/base/thread_checker.h"
28 #include "webrtc/base/timedelta.h" 28 #include "webrtc/base/timedelta.h"
29 #include "webrtc/base/timeutils.h" 29 #include "webrtc/base/timeutils.h"
30 #include "webrtc/call/rtc_event_log.h"
30 #include "webrtc/media/base/fakemediaengine.h" 31 #include "webrtc/media/base/fakemediaengine.h"
32 #include "webrtc/system_wrappers/include/clock.h"
31 33
32 using testing::Return; 34 using testing::Return;
33 using testing::ReturnRef; 35 using testing::ReturnRef;
34 36
35 namespace webrtc { 37 namespace webrtc {
36 38
37 namespace { 39 namespace {
38 40
39 const int64_t kGetStatsReportTimeoutMs = 1000; 41 const int64_t kGetStatsReportTimeoutMs = 1000;
40 42
41 class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver { 43 class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver {
42 public: 44 public:
43 RTCStatsCollectorTestHelper() 45 RTCStatsCollectorTestHelper()
44 : worker_thread_(rtc::Thread::Current()), 46 : worker_thread_(rtc::Thread::Current()),
45 network_thread_(rtc::Thread::Current()), 47 network_thread_(rtc::Thread::Current()),
46 channel_manager_(new cricket::ChannelManager( 48 channel_manager_(
47 new cricket::FakeMediaEngine(), 49 new cricket::ChannelManager(new cricket::FakeMediaEngine(),
48 worker_thread_, 50 worker_thread_,
49 network_thread_)), 51 network_thread_)),
52 event_log_(RtcEventLog::Create(webrtc::Clock::GetRealTimeClock())),
50 media_controller_( 53 media_controller_(
51 MediaControllerInterface::Create(cricket::MediaConfig(), 54 MediaControllerInterface::Create(cricket::MediaConfig(),
52 worker_thread_, 55 worker_thread_,
53 channel_manager_.get())), 56 channel_manager_.get(),
57 event_log_.get())),
54 session_(media_controller_.get()), 58 session_(media_controller_.get()),
55 pc_() { 59 pc_() {
56 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_)); 60 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_));
57 EXPECT_CALL(pc_, sctp_data_channels()).WillRepeatedly( 61 EXPECT_CALL(pc_, sctp_data_channels()).WillRepeatedly(
58 ReturnRef(data_channels_)); 62 ReturnRef(data_channels_));
59 } 63 }
60 64
61 rtc::ScopedFakeClock& fake_clock() { return fake_clock_; } 65 rtc::ScopedFakeClock& fake_clock() { return fake_clock_; }
62 MockWebRtcSession& session() { return session_; } 66 MockWebRtcSession& session() { return session_; }
63 MockPeerConnection& pc() { return pc_; } 67 MockPeerConnection& pc() { return pc_; }
64 std::vector<rtc::scoped_refptr<DataChannel>>& data_channels() { 68 std::vector<rtc::scoped_refptr<DataChannel>>& data_channels() {
65 return data_channels_; 69 return data_channels_;
66 } 70 }
67 71
68 // SetSessionDescriptionObserver overrides. 72 // SetSessionDescriptionObserver overrides.
69 void OnSuccess() override {} 73 void OnSuccess() override {}
70 void OnFailure(const std::string& error) override { 74 void OnFailure(const std::string& error) override {
71 RTC_NOTREACHED() << error; 75 RTC_NOTREACHED() << error;
72 } 76 }
73 77
74 private: 78 private:
75 rtc::ScopedFakeClock fake_clock_; 79 rtc::ScopedFakeClock fake_clock_;
76 rtc::Thread* const worker_thread_; 80 rtc::Thread* const worker_thread_;
77 rtc::Thread* const network_thread_; 81 rtc::Thread* const network_thread_;
78 std::unique_ptr<cricket::ChannelManager> channel_manager_; 82 std::unique_ptr<cricket::ChannelManager> channel_manager_;
83 std::unique_ptr<webrtc::RtcEventLog> event_log_;
79 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; 84 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_;
80 MockWebRtcSession session_; 85 MockWebRtcSession session_;
81 MockPeerConnection pc_; 86 MockPeerConnection pc_;
82 87
83 std::vector<rtc::scoped_refptr<DataChannel>> data_channels_; 88 std::vector<rtc::scoped_refptr<DataChannel>> data_channels_;
84 }; 89 };
85 90
86 class RTCTestStats : public RTCStats { 91 class RTCTestStats : public RTCStats {
87 public: 92 public:
88 RTCTestStats(const std::string& id, int64_t timestamp_us) 93 RTCTestStats(const std::string& id, int64_t timestamp_us)
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; 376 rtc::scoped_refptr<FakeRTCStatsCollector> collector_;
372 }; 377 };
373 378
374 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { 379 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) {
375 collector_->VerifyThreadUsageAndResultsMerging(); 380 collector_->VerifyThreadUsageAndResultsMerging();
376 } 381 }
377 382
378 } // namespace 383 } // namespace
379 384
380 } // namespace webrtc 385 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698