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

Side by Side Diff: talk/session/media/channel_unittest.cc

Issue 1327033002: Remove unused TypingMonitor class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 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
« no previous file with comments | « talk/session/media/channel.cc ('k') | talk/session/media/typingmonitor.h » ('j') | 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 * libjingle 2 * libjingle
3 * Copyright 2009 Google Inc. 3 * Copyright 2009 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 17 matching lines...) Expand all
28 #include "talk/media/base/fakemediaengine.h" 28 #include "talk/media/base/fakemediaengine.h"
29 #include "talk/media/base/fakertp.h" 29 #include "talk/media/base/fakertp.h"
30 #include "talk/media/base/fakescreencapturerfactory.h" 30 #include "talk/media/base/fakescreencapturerfactory.h"
31 #include "talk/media/base/fakevideocapturer.h" 31 #include "talk/media/base/fakevideocapturer.h"
32 #include "talk/media/base/mediachannel.h" 32 #include "talk/media/base/mediachannel.h"
33 #include "talk/media/base/rtpdump.h" 33 #include "talk/media/base/rtpdump.h"
34 #include "talk/media/base/screencastid.h" 34 #include "talk/media/base/screencastid.h"
35 #include "talk/media/base/testutils.h" 35 #include "talk/media/base/testutils.h"
36 #include "webrtc/p2p/base/fakesession.h" 36 #include "webrtc/p2p/base/fakesession.h"
37 #include "talk/session/media/channel.h" 37 #include "talk/session/media/channel.h"
38 #include "talk/session/media/typingmonitor.h"
39 #include "webrtc/base/fileutils.h" 38 #include "webrtc/base/fileutils.h"
40 #include "webrtc/base/gunit.h" 39 #include "webrtc/base/gunit.h"
41 #include "webrtc/base/helpers.h" 40 #include "webrtc/base/helpers.h"
42 #include "webrtc/base/logging.h" 41 #include "webrtc/base/logging.h"
43 #include "webrtc/base/pathutils.h" 42 #include "webrtc/base/pathutils.h"
44 #include "webrtc/base/signalthread.h" 43 #include "webrtc/base/signalthread.h"
45 #include "webrtc/base/ssladapter.h" 44 #include "webrtc/base/ssladapter.h"
46 #include "webrtc/base/sslidentity.h" 45 #include "webrtc/base/sslidentity.h"
47 #include "webrtc/base/window.h" 46 #include "webrtc/base/window.h"
48 47
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ChannelTest(const uint8* rtp_data, int rtp_len, 128 ChannelTest(const uint8* rtp_data, int rtp_len,
130 const uint8* rtcp_data, int rtcp_len) 129 const uint8* rtcp_data, int rtcp_len)
131 : session1_(true), 130 : session1_(true),
132 session2_(false), 131 session2_(false),
133 media_channel1_(NULL), 132 media_channel1_(NULL),
134 media_channel2_(NULL), 133 media_channel2_(NULL),
135 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len), 134 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len),
136 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len), 135 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len),
137 media_info_callbacks1_(), 136 media_info_callbacks1_(),
138 media_info_callbacks2_(), 137 media_info_callbacks2_(),
139 mute_callback_recved_(false),
140 mute_callback_value_(false),
141 ssrc_(0), 138 ssrc_(0),
142 error_(T::MediaChannel::ERROR_NONE) { 139 error_(T::MediaChannel::ERROR_NONE) {
143 } 140 }
144 141
145 void CreateChannels(int flags1, int flags2) { 142 void CreateChannels(int flags1, int flags2) {
146 CreateChannels(new typename T::MediaChannel(NULL), 143 CreateChannels(new typename T::MediaChannel(NULL),
147 new typename T::MediaChannel(NULL), 144 new typename T::MediaChannel(NULL),
148 flags1, flags2, rtc::Thread::Current()); 145 flags1, flags2, rtc::Thread::Current());
149 } 146 }
150 void CreateChannels(int flags) { 147 void CreateChannels(int flags) {
(...skipping 23 matching lines...) Expand all
174 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session2_, 171 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session2_,
175 (flags2 & RTCP) != 0)); 172 (flags2 & RTCP) != 0));
176 channel1_->SignalMediaMonitor.connect( 173 channel1_->SignalMediaMonitor.connect(
177 this, &ChannelTest<T>::OnMediaMonitor); 174 this, &ChannelTest<T>::OnMediaMonitor);
178 channel2_->SignalMediaMonitor.connect( 175 channel2_->SignalMediaMonitor.connect(
179 this, &ChannelTest<T>::OnMediaMonitor); 176 this, &ChannelTest<T>::OnMediaMonitor);
180 channel1_->SignalMediaError.connect( 177 channel1_->SignalMediaError.connect(
181 this, &ChannelTest<T>::OnMediaChannelError); 178 this, &ChannelTest<T>::OnMediaChannelError);
182 channel2_->SignalMediaError.connect( 179 channel2_->SignalMediaError.connect(
183 this, &ChannelTest<T>::OnMediaChannelError); 180 this, &ChannelTest<T>::OnMediaChannelError);
184 channel1_->SignalAutoMuted.connect(
185 this, &ChannelTest<T>::OnMediaMuted);
186 if ((flags1 & DTLS) && (flags2 & DTLS)) { 181 if ((flags1 & DTLS) && (flags2 & DTLS)) {
187 flags1 = (flags1 & ~SECURE); 182 flags1 = (flags1 & ~SECURE);
188 flags2 = (flags2 & ~SECURE); 183 flags2 = (flags2 & ~SECURE);
189 } 184 }
190 CreateContent(flags1, kPcmuCodec, kH264Codec, 185 CreateContent(flags1, kPcmuCodec, kH264Codec,
191 &local_media_content1_); 186 &local_media_content1_);
192 CreateContent(flags2, kPcmuCodec, kH264Codec, 187 CreateContent(flags2, kPcmuCodec, kH264Codec,
193 &local_media_content2_); 188 &local_media_content2_);
194 CopyContent(local_media_content1_, &remote_media_content1_); 189 CopyContent(local_media_content1_, &remote_media_content1_);
195 CopyContent(local_media_content2_, &remote_media_content2_); 190 CopyContent(local_media_content2_, &remote_media_content2_);
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 515 }
521 } 516 }
522 517
523 void OnMediaChannelError(typename T::Channel* channel, 518 void OnMediaChannelError(typename T::Channel* channel,
524 uint32 ssrc, 519 uint32 ssrc,
525 typename T::MediaChannel::Error error) { 520 typename T::MediaChannel::Error error) {
526 ssrc_ = ssrc; 521 ssrc_ = ssrc;
527 error_ = error; 522 error_ = error;
528 } 523 }
529 524
530 void OnMediaMuted(cricket::BaseChannel* channel, bool muted) {
531 mute_callback_recved_ = true;
532 mute_callback_value_ = muted;
533 }
534
535 void AddLegacyStreamInContent(uint32 ssrc, int flags, 525 void AddLegacyStreamInContent(uint32 ssrc, int flags,
536 typename T::Content* content) { 526 typename T::Content* content) {
537 // Base implementation. 527 // Base implementation.
538 } 528 }
539 529
540 // Tests that can be used by derived classes. 530 // Tests that can be used by derived classes.
541 531
542 // Basic sanity check. 532 // Basic sanity check.
543 void TestInit() { 533 void TestInit() {
544 CreateChannels(0, 0); 534 CreateChannels(0, 0);
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 rtc::scoped_ptr<typename T::Channel> channel2_; 1781 rtc::scoped_ptr<typename T::Channel> channel2_;
1792 typename T::Content local_media_content1_; 1782 typename T::Content local_media_content1_;
1793 typename T::Content local_media_content2_; 1783 typename T::Content local_media_content2_;
1794 typename T::Content remote_media_content1_; 1784 typename T::Content remote_media_content1_;
1795 typename T::Content remote_media_content2_; 1785 typename T::Content remote_media_content2_;
1796 // The RTP and RTCP packets to send in the tests. 1786 // The RTP and RTCP packets to send in the tests.
1797 std::string rtp_packet_; 1787 std::string rtp_packet_;
1798 std::string rtcp_packet_; 1788 std::string rtcp_packet_;
1799 int media_info_callbacks1_; 1789 int media_info_callbacks1_;
1800 int media_info_callbacks2_; 1790 int media_info_callbacks2_;
1801 bool mute_callback_recved_;
1802 bool mute_callback_value_;
1803 1791
1804 uint32 ssrc_; 1792 uint32 ssrc_;
1805 typename T::MediaChannel::Error error_; 1793 typename T::MediaChannel::Error error_;
1806 }; 1794 };
1807 1795
1808 1796
1809 template<> 1797 template<>
1810 void ChannelTest<VoiceTraits>::CreateContent( 1798 void ChannelTest<VoiceTraits>::CreateContent(
1811 int flags, 1799 int flags,
1812 const cricket::AudioCodec& audio_codec, 1800 const cricket::AudioCodec& audio_codec,
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 2113
2126 TEST_F(VoiceChannelTest, TestMediaMonitor) { 2114 TEST_F(VoiceChannelTest, TestMediaMonitor) {
2127 Base::TestMediaMonitor(); 2115 Base::TestMediaMonitor();
2128 } 2116 }
2129 2117
2130 // Test that MuteStream properly forwards to the media channel and does 2118 // Test that MuteStream properly forwards to the media channel and does
2131 // not signal. 2119 // not signal.
2132 TEST_F(VoiceChannelTest, TestVoiceSpecificMuteStream) { 2120 TEST_F(VoiceChannelTest, TestVoiceSpecificMuteStream) {
2133 CreateChannels(0, 0); 2121 CreateChannels(0, 0);
2134 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); 2122 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2135 EXPECT_FALSE(mute_callback_recved_);
2136 EXPECT_TRUE(channel1_->MuteStream(0, true)); 2123 EXPECT_TRUE(channel1_->MuteStream(0, true));
2137 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); 2124 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2138 EXPECT_FALSE(mute_callback_recved_);
2139 EXPECT_TRUE(channel1_->MuteStream(0, false)); 2125 EXPECT_TRUE(channel1_->MuteStream(0, false));
2140 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); 2126 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2141 EXPECT_FALSE(mute_callback_recved_);
2142 }
2143
2144 // Test that keyboard automute works correctly and signals upwards.
2145 TEST_F(VoiceChannelTest, DISABLED_TestKeyboardMute) {
2146 CreateChannels(0, 0);
2147 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2148 EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_NONE, error_);
2149
2150 cricket::VoiceMediaChannel::Error e =
2151 cricket::VoiceMediaChannel::ERROR_REC_TYPING_NOISE_DETECTED;
2152
2153 // Typing doesn't mute automatically unless typing monitor has been installed
2154 media_channel1_->TriggerError(0, e);
2155 rtc::Thread::Current()->ProcessMessages(0);
2156 EXPECT_EQ(e, error_);
2157 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2158 EXPECT_FALSE(mute_callback_recved_);
2159
2160 cricket::TypingMonitorOptions o = {0};
2161 o.mute_period = 1500;
2162 channel1_->StartTypingMonitor(o);
2163 media_channel1_->TriggerError(0, e);
2164 rtc::Thread::Current()->ProcessMessages(0);
2165 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2166 EXPECT_TRUE(mute_callback_recved_);
2167 } 2127 }
2168 2128
2169 // Test that PressDTMF properly forwards to the media channel. 2129 // Test that PressDTMF properly forwards to the media channel.
2170 TEST_F(VoiceChannelTest, TestDtmf) { 2130 TEST_F(VoiceChannelTest, TestDtmf) {
2171 CreateChannels(0, 0); 2131 CreateChannels(0, 0);
2172 EXPECT_TRUE(SendInitiate()); 2132 EXPECT_TRUE(SendInitiate());
2173 EXPECT_TRUE(SendAccept()); 2133 EXPECT_TRUE(SendAccept());
2174 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size()); 2134 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size());
2175 2135
2176 EXPECT_TRUE(channel1_->PressDTMF(1, true)); 2136 EXPECT_TRUE(channel1_->PressDTMF(1, true));
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 }; 2836 };
2877 rtc::Buffer payload(data, 3); 2837 rtc::Buffer payload(data, 3);
2878 cricket::SendDataResult result; 2838 cricket::SendDataResult result;
2879 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2839 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2880 EXPECT_EQ(params.ssrc, 2840 EXPECT_EQ(params.ssrc,
2881 media_channel1_->last_sent_data_params().ssrc); 2841 media_channel1_->last_sent_data_params().ssrc);
2882 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2842 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2883 } 2843 }
2884 2844
2885 // TODO(pthatcher): TestSetReceiver? 2845 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« no previous file with comments | « talk/session/media/channel.cc ('k') | talk/session/media/typingmonitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698