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

Side by Side Diff: webrtc/modules/media_file/source/media_file_unittest.cc

Issue 1435093002: Remove include dirs from modules/{media_file,pacing} (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase fix Created 5 years, 1 month 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
(Empty)
1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "webrtc/modules/media_file/include/media_file.h"
13 #include "webrtc/system_wrappers/include/sleep.h"
14 #include "webrtc/test/testsupport/fileutils.h"
15 #include "webrtc/test/testsupport/gtest_disable.h"
16
17 class MediaFileTest : public testing::Test {
18 protected:
19 void SetUp() {
20 // Use number 0 as the the identifier and pass to CreateMediaFile.
21 media_file_ = webrtc::MediaFile::CreateMediaFile(0);
22 ASSERT_TRUE(media_file_ != NULL);
23 }
24 void TearDown() {
25 webrtc::MediaFile::DestroyMediaFile(media_file_);
26 media_file_ = NULL;
27 }
28 webrtc::MediaFile* media_file_;
29 };
30
31 TEST_F(MediaFileTest, DISABLED_ON_IOS(
32 DISABLED_ON_ANDROID(StartPlayingAudioFileWithoutError))) {
33 // TODO(leozwang): Use hard coded filename here, we want to
34 // loop through all audio files in future
35 const std::string audio_file = webrtc::test::ProjectRootPath() +
36 "data/voice_engine/audio_tiny48.wav";
37 ASSERT_EQ(0, media_file_->StartPlayingAudioFile(
38 audio_file.c_str(),
39 0,
40 false,
41 webrtc::kFileFormatWavFile));
42
43 ASSERT_EQ(true, media_file_->IsPlaying());
44
45 webrtc::SleepMs(1);
46
47 ASSERT_EQ(0, media_file_->StopPlaying());
48 }
49
50 TEST_F(MediaFileTest, DISABLED_ON_IOS(WriteWavFile)) {
51 // Write file.
52 static const size_t kHeaderSize = 44;
53 static const size_t kPayloadSize = 320;
54 webrtc::CodecInst codec = {
55 0, "L16", 16000, static_cast<int>(kPayloadSize), 1
56 };
57 std::string outfile = webrtc::test::OutputPath() + "wavtest.wav";
58 ASSERT_EQ(0,
59 media_file_->StartRecordingAudioFile(
60 outfile.c_str(), webrtc::kFileFormatWavFile, codec));
61 static const int8_t kFakeData[kPayloadSize] = {0};
62 ASSERT_EQ(0, media_file_->IncomingAudioData(kFakeData, kPayloadSize));
63 ASSERT_EQ(0, media_file_->StopRecording());
64
65 // Check the file we just wrote.
66 static const uint8_t kExpectedHeader[] = {
67 'R', 'I', 'F', 'F',
68 0x64, 0x1, 0, 0, // size of whole file - 8: 320 + 44 - 8
69 'W', 'A', 'V', 'E',
70 'f', 'm', 't', ' ',
71 0x10, 0, 0, 0, // size of fmt block - 8: 24 - 8
72 0x1, 0, // format: PCM (1)
73 0x1, 0, // channels: 1
74 0x80, 0x3e, 0, 0, // sample rate: 16000
75 0, 0x7d, 0, 0, // byte rate: 2 * 16000
76 0x2, 0, // block align: NumChannels * BytesPerSample
77 0x10, 0, // bits per sample: 2 * 8
78 'd', 'a', 't', 'a',
79 0x40, 0x1, 0, 0, // size of payload: 320
80 };
81 static_assert(sizeof(kExpectedHeader) == kHeaderSize, "header size");
82
83 EXPECT_EQ(kHeaderSize + kPayloadSize, webrtc::test::GetFileSize(outfile));
84 FILE* f = fopen(outfile.c_str(), "rb");
85 ASSERT_TRUE(f);
86
87 uint8_t header[kHeaderSize];
88 ASSERT_EQ(1u, fread(header, kHeaderSize, 1, f));
89 EXPECT_EQ(0, memcmp(kExpectedHeader, header, kHeaderSize));
90
91 uint8_t payload[kPayloadSize];
92 ASSERT_EQ(1u, fread(payload, kPayloadSize, 1, f));
93 EXPECT_EQ(0, memcmp(kFakeData, payload, kPayloadSize));
94
95 EXPECT_EQ(0, fclose(f));
96 }
OLDNEW
« no previous file with comments | « webrtc/modules/media_file/source/media_file_impl.cc ('k') | webrtc/modules/media_file/source/media_file_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698