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

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

Issue 2583193002: Removed RTCStatsCollector::ProducePartialResultsOnWorkerThread. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « webrtc/api/rtcstatscollector.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 GetStatsReport(rtc::scoped_refptr<RTCStatsCollectorCallback>(this)); 389 GetStatsReport(rtc::scoped_refptr<RTCStatsCollectorCallback>(this));
390 EXPECT_TRUE_WAIT(HasVerifiedResults(), kGetStatsReportTimeoutMs); 390 EXPECT_TRUE_WAIT(HasVerifiedResults(), kGetStatsReportTimeoutMs);
391 } 391 }
392 392
393 bool HasVerifiedResults() { 393 bool HasVerifiedResults() {
394 EXPECT_TRUE(signaling_thread_->IsCurrent()); 394 EXPECT_TRUE(signaling_thread_->IsCurrent());
395 rtc::CritScope cs(&lock_); 395 rtc::CritScope cs(&lock_);
396 if (!delivered_report_) 396 if (!delivered_report_)
397 return false; 397 return false;
398 EXPECT_EQ(produced_on_signaling_thread_, 1); 398 EXPECT_EQ(produced_on_signaling_thread_, 1);
399 EXPECT_EQ(produced_on_worker_thread_, 1);
400 EXPECT_EQ(produced_on_network_thread_, 1); 399 EXPECT_EQ(produced_on_network_thread_, 1);
401 400
402 EXPECT_TRUE(delivered_report_->Get("SignalingThreadStats")); 401 EXPECT_TRUE(delivered_report_->Get("SignalingThreadStats"));
403 EXPECT_TRUE(delivered_report_->Get("WorkerThreadStats"));
404 EXPECT_TRUE(delivered_report_->Get("NetworkThreadStats")); 402 EXPECT_TRUE(delivered_report_->Get("NetworkThreadStats"));
405 403
406 produced_on_signaling_thread_ = 0; 404 produced_on_signaling_thread_ = 0;
407 produced_on_worker_thread_ = 0;
408 produced_on_network_thread_ = 0; 405 produced_on_network_thread_ = 0;
409 delivered_report_ = nullptr; 406 delivered_report_ = nullptr;
410 return true; 407 return true;
411 } 408 }
412 409
413 protected: 410 protected:
414 FakeRTCStatsCollector( 411 FakeRTCStatsCollector(
415 PeerConnection* pc, 412 PeerConnection* pc,
416 int64_t cache_lifetime) 413 int64_t cache_lifetime)
417 : RTCStatsCollector(pc, cache_lifetime), 414 : RTCStatsCollector(pc, cache_lifetime),
418 signaling_thread_(pc->session()->signaling_thread()), 415 signaling_thread_(pc->session()->signaling_thread()),
419 worker_thread_(pc->session()->worker_thread()), 416 worker_thread_(pc->session()->worker_thread()),
420 network_thread_(pc->session()->network_thread()) { 417 network_thread_(pc->session()->network_thread()) {
421 } 418 }
422 419
423 void ProducePartialResultsOnSignalingThread(int64_t timestamp_us) override { 420 void ProducePartialResultsOnSignalingThread(int64_t timestamp_us) override {
424 EXPECT_TRUE(signaling_thread_->IsCurrent()); 421 EXPECT_TRUE(signaling_thread_->IsCurrent());
425 { 422 {
426 rtc::CritScope cs(&lock_); 423 rtc::CritScope cs(&lock_);
427 EXPECT_FALSE(delivered_report_); 424 EXPECT_FALSE(delivered_report_);
428 ++produced_on_signaling_thread_; 425 ++produced_on_signaling_thread_;
429 } 426 }
430 427
431 rtc::scoped_refptr<RTCStatsReport> signaling_report = 428 rtc::scoped_refptr<RTCStatsReport> signaling_report =
432 RTCStatsReport::Create(0); 429 RTCStatsReport::Create(0);
433 signaling_report->AddStats(std::unique_ptr<const RTCStats>( 430 signaling_report->AddStats(std::unique_ptr<const RTCStats>(
434 new RTCTestStats("SignalingThreadStats", timestamp_us))); 431 new RTCTestStats("SignalingThreadStats", timestamp_us)));
435 AddPartialResults(signaling_report); 432 AddPartialResults(signaling_report);
436 } 433 }
437 void ProducePartialResultsOnWorkerThread(int64_t timestamp_us) override {
438 EXPECT_TRUE(worker_thread_->IsCurrent());
439 {
440 rtc::CritScope cs(&lock_);
441 EXPECT_FALSE(delivered_report_);
442 ++produced_on_worker_thread_;
443 }
444
445 rtc::scoped_refptr<RTCStatsReport> worker_report =
446 RTCStatsReport::Create(0);
447 worker_report->AddStats(std::unique_ptr<const RTCStats>(
448 new RTCTestStats("WorkerThreadStats", timestamp_us)));
449 AddPartialResults(worker_report);
450 }
451 void ProducePartialResultsOnNetworkThread(int64_t timestamp_us) override { 434 void ProducePartialResultsOnNetworkThread(int64_t timestamp_us) override {
452 EXPECT_TRUE(network_thread_->IsCurrent()); 435 EXPECT_TRUE(network_thread_->IsCurrent());
453 { 436 {
454 rtc::CritScope cs(&lock_); 437 rtc::CritScope cs(&lock_);
455 EXPECT_FALSE(delivered_report_); 438 EXPECT_FALSE(delivered_report_);
456 ++produced_on_network_thread_; 439 ++produced_on_network_thread_;
457 } 440 }
458 441
459 rtc::scoped_refptr<RTCStatsReport> network_report = 442 rtc::scoped_refptr<RTCStatsReport> network_report =
460 RTCStatsReport::Create(0); 443 RTCStatsReport::Create(0);
461 network_report->AddStats(std::unique_ptr<const RTCStats>( 444 network_report->AddStats(std::unique_ptr<const RTCStats>(
462 new RTCTestStats("NetworkThreadStats", timestamp_us))); 445 new RTCTestStats("NetworkThreadStats", timestamp_us)));
463 AddPartialResults(network_report); 446 AddPartialResults(network_report);
464 } 447 }
465 448
466 private: 449 private:
467 rtc::Thread* const signaling_thread_; 450 rtc::Thread* const signaling_thread_;
468 rtc::Thread* const worker_thread_; 451 rtc::Thread* const worker_thread_;
469 rtc::Thread* const network_thread_; 452 rtc::Thread* const network_thread_;
470 453
471 rtc::CriticalSection lock_; 454 rtc::CriticalSection lock_;
472 rtc::scoped_refptr<const RTCStatsReport> delivered_report_; 455 rtc::scoped_refptr<const RTCStatsReport> delivered_report_;
473 int produced_on_signaling_thread_ = 0; 456 int produced_on_signaling_thread_ = 0;
474 int produced_on_worker_thread_ = 0;
475 int produced_on_network_thread_ = 0; 457 int produced_on_network_thread_ = 0;
476 }; 458 };
477 459
478 class RTCStatsCollectorTest : public testing::Test { 460 class RTCStatsCollectorTest : public testing::Test {
479 public: 461 public:
480 RTCStatsCollectorTest() 462 RTCStatsCollectorTest()
481 : test_(new rtc::RefCountedObject<RTCStatsCollectorTestHelper>()), 463 : test_(new rtc::RefCountedObject<RTCStatsCollectorTestHelper>()),
482 collector_(RTCStatsCollector::Create( 464 collector_(RTCStatsCollector::Create(
483 &test_->pc(), 50 * rtc::kNumMicrosecsPerMillisec)) { 465 &test_->pc(), 50 * rtc::kNumMicrosecsPerMillisec)) {
484 } 466 }
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; 1889 rtc::scoped_refptr<FakeRTCStatsCollector> collector_;
1908 }; 1890 };
1909 1891
1910 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { 1892 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) {
1911 collector_->VerifyThreadUsageAndResultsMerging(); 1893 collector_->VerifyThreadUsageAndResultsMerging();
1912 } 1894 }
1913 1895
1914 } // namespace 1896 } // namespace
1915 1897
1916 } // namespace webrtc 1898 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/rtcstatscollector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698