From 0dc8efe6e6f5bcdd5c7af27e5bc78ba013675c67 Mon Sep 17 00:00:00 2001 From: "leozwang@webrtc.org" Date: Tue, 3 Apr 2012 15:11:01 +0000 Subject: [PATCH] Fix wrong data type in ReadWavHeader BUG=409 TEST=media file unit test Review URL: https://webrtc-codereview.appspot.com/474001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1980 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../media_file/source/media_file_unittest.cc | 41 ++++++++++++++++--- .../media_file/source/media_file_utility.cc | 2 +- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/modules/media_file/source/media_file_unittest.cc b/src/modules/media_file/source/media_file_unittest.cc index 86f37f3f1..d1f74c026 100644 --- a/src/modules/media_file/source/media_file_unittest.cc +++ b/src/modules/media_file/source/media_file_unittest.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -8,10 +8,39 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * Empty test just to get code coverage metrics for this dir. - */ -#include "media_file.h" #include "gtest/gtest.h" +#include "modules/media_file/interface/media_file.h" +#include "testsupport/fileutils.h" +#include "voice_engine/main/source/voice_engine_defines.h" // defines SLEEP -TEST(MediaFileTest, EmptyTestToGetCodeCoverage) {} +class MediaFileTest : public testing::Test { + protected: + void SetUp() { + // Use number 0 as the the identifier and pass to CreateMediaFile. + media_file_ = webrtc::MediaFile::CreateMediaFile(0); + ASSERT_TRUE(media_file_ != NULL); + } + void TearDown() { + webrtc::MediaFile::DestroyMediaFile(media_file_); + media_file_ = NULL; + } + webrtc::MediaFile* media_file_; +}; + +TEST_F(MediaFileTest, StartPlayingAudioFileWithoutError) { + // TODO(leozwang): Use hard coded filename here, we want to + // loop through all audio files in future + const std::string audio_file = webrtc::test::ProjectRootPath() + + "test/data/voice_engine/audio_tiny48.wav"; + ASSERT_EQ(0, media_file_->StartPlayingAudioFile( + audio_file.c_str(), + 0, + false, + webrtc::kFileFormatWavFile)); + + ASSERT_EQ(true, media_file_->IsPlaying()); + + SLEEP(1); + + ASSERT_EQ(0, media_file_->StopPlaying()); +} diff --git a/src/modules/media_file/source/media_file_utility.cc b/src/modules/media_file/source/media_file_utility.cc index da723e1d5..8d06a88e6 100644 --- a/src/modules/media_file/source/media_file_utility.cc +++ b/src/modules/media_file/source/media_file_utility.cc @@ -446,7 +446,7 @@ WebRtc_Word32 ModuleFileUtility::ReadWavHeader(InStream& wav) WAVE_CHUNK_header CHUNKheaderObj; // TODO (hellner): tmpStr and tmpStr2 seems unnecessary here. char tmpStr[6] = "FOUR"; - char tmpStr2[4]; + unsigned char tmpStr2[4]; WebRtc_Word32 i, len; bool dataFound = false; bool fmtFound = false;