| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 private: | 111 private: |
| 112 bool can_insert_ = false; | 112 bool can_insert_ = false; |
| 113 std::vector<DtmfInfo> dtmf_info_queue_; | 113 std::vector<DtmfInfo> dtmf_info_queue_; |
| 114 int64_t last_insert_dtmf_call_; | 114 int64_t last_insert_dtmf_call_; |
| 115 sigslot::signal0<> SignalDestroyed; | 115 sigslot::signal0<> SignalDestroyed; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 class DtmfSenderTest : public testing::Test { | 118 class DtmfSenderTest : public testing::Test { |
| 119 protected: | 119 protected: |
| 120 DtmfSenderTest() | 120 DtmfSenderTest() |
| 121 : track_(AudioTrack::Create(kTestAudioLabel, NULL)), | 121 : track_(AudioTrack::Create(kTestAudioLabel, nullptr)), |
| 122 observer_(new rtc::RefCountedObject<FakeDtmfObserver>()), | 122 observer_(new rtc::RefCountedObject<FakeDtmfObserver>()), |
| 123 provider_(new FakeDtmfProvider()) { | 123 provider_(new FakeDtmfProvider()) { |
| 124 provider_->SetCanInsertDtmf(true); | 124 provider_->SetCanInsertDtmf(true); |
| 125 dtmf_ = DtmfSender::Create(track_, rtc::Thread::Current(), | 125 dtmf_ = DtmfSender::Create(track_, rtc::Thread::Current(), |
| 126 provider_.get()); | 126 provider_.get()); |
| 127 dtmf_->RegisterObserver(observer_.get()); | 127 dtmf_->RegisterObserver(observer_.get()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 ~DtmfSenderTest() { | 130 ~DtmfSenderTest() { |
| 131 if (dtmf_.get()) { | 131 if (dtmf_.get()) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 TEST_F(DtmfSenderTest, InsertDtmfWhileSenderIsDeleted) { | 277 TEST_F(DtmfSenderTest, InsertDtmfWhileSenderIsDeleted) { |
| 278 std::string tones = "@1%a&*$"; | 278 std::string tones = "@1%a&*$"; |
| 279 int duration = 100; | 279 int duration = 100; |
| 280 int inter_tone_gap = 50; | 280 int inter_tone_gap = 50; |
| 281 EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap)); | 281 EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap)); |
| 282 // Wait until the first tone got sent. | 282 // Wait until the first tone got sent. |
| 283 EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs, | 283 EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs, |
| 284 fake_clock_); | 284 fake_clock_); |
| 285 // Delete the sender. | 285 // Delete the sender. |
| 286 dtmf_ = NULL; | 286 dtmf_ = nullptr; |
| 287 // The queue should be discontinued so no more tone callbacks. | 287 // The queue should be discontinued so no more tone callbacks. |
| 288 SIMULATED_WAIT(false, 200, fake_clock_); | 288 SIMULATED_WAIT(false, 200, fake_clock_); |
| 289 EXPECT_EQ(1U, observer_->tones().size()); | 289 EXPECT_EQ(1U, observer_->tones().size()); |
| 290 } | 290 } |
| 291 | 291 |
| 292 TEST_F(DtmfSenderTest, InsertEmptyTonesToCancelPreviousTask) { | 292 TEST_F(DtmfSenderTest, InsertEmptyTonesToCancelPreviousTask) { |
| 293 std::string tones1 = "12"; | 293 std::string tones1 = "12"; |
| 294 std::string tones2 = ""; | 294 std::string tones2 = ""; |
| 295 int duration = 100; | 295 int duration = 100; |
| 296 int inter_tone_gap = 50; | 296 int inter_tone_gap = 50; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 std::string tones = "3,4"; | 332 std::string tones = "3,4"; |
| 333 int duration = 100; | 333 int duration = 100; |
| 334 int inter_tone_gap = 50; | 334 int inter_tone_gap = 50; |
| 335 | 335 |
| 336 EXPECT_FALSE(dtmf_->InsertDtmf(tones, 6001, inter_tone_gap)); | 336 EXPECT_FALSE(dtmf_->InsertDtmf(tones, 6001, inter_tone_gap)); |
| 337 EXPECT_FALSE(dtmf_->InsertDtmf(tones, 69, inter_tone_gap)); | 337 EXPECT_FALSE(dtmf_->InsertDtmf(tones, 69, inter_tone_gap)); |
| 338 EXPECT_FALSE(dtmf_->InsertDtmf(tones, duration, 49)); | 338 EXPECT_FALSE(dtmf_->InsertDtmf(tones, duration, 49)); |
| 339 | 339 |
| 340 EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap)); | 340 EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap)); |
| 341 } | 341 } |
| OLD | NEW |