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

Side by Side Diff: remoting/protocol/connection_unittest.cc

Issue 2711053005: Deflake ConnectionTest.Audio test (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | remoting/protocol/webrtc_transport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 int right = 0; 227 int right = 0;
228 for (int i = skipped_samples + 1; i < num_samples; ++i) { 228 for (int i = skipped_samples + 1; i < num_samples; ++i) {
229 if (data[(i - 1) * kAudioChannels] < 0 && data[i * kAudioChannels] >= 0) { 229 if (data[(i - 1) * kAudioChannels] < 0 && data[i * kAudioChannels] >= 0) {
230 ++left; 230 ++left;
231 } 231 }
232 if (data[(i - 1) * kAudioChannels + 1] < 0 && 232 if (data[(i - 1) * kAudioChannels + 1] < 0 &&
233 data[i * kAudioChannels + 1] >= 0) { 233 data[i * kAudioChannels + 1] >= 0) {
234 ++right; 234 ++right;
235 } 235 }
236 } 236 }
237
238 const int kMaxErrorHz = 50;
237 int left_hz = (left * kAudioSampleRate / (num_samples - skipped_samples)); 239 int left_hz = (left * kAudioSampleRate / (num_samples - skipped_samples));
238 EXPECT_LE(kTestAudioSignalFrequencyLeftHz - 50, left_hz); 240 EXPECT_LE(kTestAudioSignalFrequencyLeftHz - kMaxErrorHz, left_hz);
239 EXPECT_GE(kTestAudioSignalFrequencyLeftHz + 50, left_hz); 241 EXPECT_GE(kTestAudioSignalFrequencyLeftHz + kMaxErrorHz, left_hz);
240 int right_hz = (right * kAudioSampleRate / (num_samples - skipped_samples)); 242 int right_hz = (right * kAudioSampleRate / (num_samples - skipped_samples));
241 EXPECT_LE(kTestAudioSignalFrequencyRightHz - 50, right_hz); 243 EXPECT_LE(kTestAudioSignalFrequencyRightHz - kMaxErrorHz, right_hz);
242 EXPECT_GE(kTestAudioSignalFrequencyRightHz + 50, right_hz); 244 EXPECT_GE(kTestAudioSignalFrequencyRightHz + kMaxErrorHz, right_hz);
243 } 245 }
244 246
245 base::WeakPtr<AudioStub> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } 247 base::WeakPtr<AudioStub> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
246 248
247 private: 249 private:
248 base::ThreadChecker thread_checker_; 250 base::ThreadChecker thread_checker_;
249 std::vector<char> data_; 251 std::vector<char> data_;
250 base::RunLoop* run_loop_ = nullptr; 252 base::RunLoop* run_loop_ = nullptr;
251 size_t samples_expected_ = 0; 253 size_t samples_expected_ = 0;
252 254
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 stats.host_stats.capture_delay + 617 stats.host_stats.capture_delay +
616 stats.host_stats.capture_overhead_delay + 618 stats.host_stats.capture_overhead_delay +
617 stats.host_stats.encode_delay + 619 stats.host_stats.encode_delay +
618 stats.host_stats.send_pending_delay, 620 stats.host_stats.send_pending_delay,
619 stats.client_stats.time_received); 621 stats.client_stats.time_received);
620 EXPECT_LE(stats.client_stats.time_received, stats.client_stats.time_decoded); 622 EXPECT_LE(stats.client_stats.time_received, stats.client_stats.time_decoded);
621 EXPECT_LE(stats.client_stats.time_decoded, stats.client_stats.time_rendered); 623 EXPECT_LE(stats.client_stats.time_decoded, stats.client_stats.time_rendered);
622 EXPECT_LE(stats.client_stats.time_rendered, finish_time); 624 EXPECT_LE(stats.client_stats.time_rendered, finish_time);
623 } 625 }
624 626
625 // Flaky on Linux/ChromeOS, crbug.com/685910.
626 // Note: Apparently it's not possible to use the common MAYBE_ prefix with
627 // TEST_P, so ifdef it out completely.
628 #if !defined(OS_LINUX) && !defined(OS_CHROMEOS)
629 TEST_P(ConnectionTest, Audio) { 627 TEST_P(ConnectionTest, Audio) {
630 Connect(); 628 Connect();
631 629
632 std::unique_ptr<AudioStream> audio_stream = 630 std::unique_ptr<AudioStream> audio_stream =
633 host_connection_->StartAudioStream(base::MakeUnique<TestAudioSource>()); 631 host_connection_->StartAudioStream(base::MakeUnique<TestAudioSource>());
634 632
635 // Wait for 1 second worth of audio samples. 633 // Wait for 1 second worth of audio samples.
636 client_audio_player_.WaitForSamples(kAudioSampleRate * 2); 634 client_audio_player_.WaitForSamples(kAudioSampleRate * 2);
637 client_audio_player_.Verify(); 635 client_audio_player_.Verify();
638 } 636 }
639 #endif
640 637
641 TEST_P(ConnectionTest, FirstCaptureFailed) { 638 TEST_P(ConnectionTest, FirstCaptureFailed) {
642 Connect(); 639 Connect();
643 640
644 base::TimeTicks event_timestamp = base::TimeTicks::FromInternalValue(42); 641 base::TimeTicks event_timestamp = base::TimeTicks::FromInternalValue(42);
645 642
646 scoped_refptr<InputEventTimestampsSourceImpl> input_event_timestamps_source = 643 scoped_refptr<InputEventTimestampsSourceImpl> input_event_timestamps_source =
647 new InputEventTimestampsSourceImpl(); 644 new InputEventTimestampsSourceImpl();
648 input_event_timestamps_source->OnEventReceived( 645 input_event_timestamps_source->OnEventReceived(
649 InputEventTimestamps{event_timestamp, base::TimeTicks::Now()}); 646 InputEventTimestamps{event_timestamp, base::TimeTicks::Now()});
(...skipping 27 matching lines...) Expand all
677 auto capturer = base::MakeUnique<TestScreenCapturer>(); 674 auto capturer = base::MakeUnique<TestScreenCapturer>();
678 capturer->FailNthFrame(1); 675 capturer->FailNthFrame(1);
679 auto video_stream = host_connection_->StartVideoStream(std::move(capturer)); 676 auto video_stream = host_connection_->StartVideoStream(std::move(capturer));
680 677
681 WaitNextVideoFrame(); 678 WaitNextVideoFrame();
682 WaitNextVideoFrame(); 679 WaitNextVideoFrame();
683 } 680 }
684 681
685 } // namespace protocol 682 } // namespace protocol
686 } // namespace remoting 683 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/protocol/webrtc_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698