From 470c0887b334f1b859f2fd0055ab840370f5cc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1ri=20Tristan=20Helgason?= Date: Mon, 3 Oct 2016 13:13:29 +0200 Subject: [PATCH] Fix modules_unittests on iOS. Some of the module tests were failing on iOS, causing them to be ignored on the trybots. Specifically this CL: - Skips some tests that should not run on the simulator - Fixes iOS file system test helpers - Fixes failing nalu parser unittest BUG=webrtc:4752 R=henrika@webrtc.org, peah@webrtc.org, sprang@webrtc.org TBR=tkchin@webrtc.org Review URL: https://codereview.webrtc.org/2352063002 . Cr-Commit-Position: refs/heads/master@{#14472} --- webrtc/modules/BUILD.gn | 5 ++++- .../modules/audio_processing/audio_processing_unittest.cc | 7 ++++++- webrtc/modules/audio_processing/test/debug_dump_test.cc | 4 ++-- .../codecs/h264/h264_video_toolbox_nalu_unittest.cc | 4 ++-- webrtc/test/testsupport/fileutils.cc | 5 +++++ webrtc/test/testsupport/iosfileutils.mm | 7 +++++++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index 59a4b3ced8..daeb7e9d43 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -693,11 +693,14 @@ if (rtc_include_tests) { ] sources += [ - "audio_device/ios/audio_device_unittest_ios.cc", "audio_device/ios/objc/RTCAudioSessionTest.mm", "video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc", ] + if (target_cpu != "x64") { + sources += [ "audio_device/ios/audio_device_unittest_ios.cc" ] + } + ldflags = [ "-ObjC" ] } } diff --git a/webrtc/modules/audio_processing/audio_processing_unittest.cc b/webrtc/modules/audio_processing/audio_processing_unittest.cc index b0c652654b..6e0b175003 100644 --- a/webrtc/modules/audio_processing/audio_processing_unittest.cc +++ b/webrtc/modules/audio_processing/audio_processing_unittest.cc @@ -293,7 +293,7 @@ void ClearTempFiles() { remove(kv.second.c_str()); } -void OpenFileAndReadMessage(const std::string filename, +void OpenFileAndReadMessage(std::string filename, ::google::protobuf::MessageLite* msg) { FILE* file = fopen(filename.c_str(), "rb"); ASSERT_TRUE(file != NULL); @@ -404,7 +404,12 @@ class ApmTest : public ::testing::Test { ApmTest::ApmTest() : output_path_(test::OutputPath()), +#ifndef WEBRTC_IOS ref_path_(test::ProjectRootPath() + "data/audio_processing/"), +#else + // On iOS test data is flat in the project root dir + ref_path_(test::ProjectRootPath()), +#endif #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) ref_filename_(ref_path_ + "output_data_fixed.pb"), #elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) diff --git a/webrtc/modules/audio_processing/test/debug_dump_test.cc b/webrtc/modules/audio_processing/test/debug_dump_test.cc index b4e0ee7e3a..ffaf60984e 100644 --- a/webrtc/modules/audio_processing/test/debug_dump_test.cc +++ b/webrtc/modules/audio_processing/test/debug_dump_test.cc @@ -516,8 +516,8 @@ TEST_F(DebugDumpTest, ToggleAecLevel) { VerifyDebugDump(generator.dump_file_name()); } -#if defined(WEBRTC_ANDROID) -// AGC may not be supported on Android. +// AGC is not supported on Android or iOS. +#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) #define MAYBE_ToggleAgc DISABLED_ToggleAgc #else #define MAYBE_ToggleAgc ToggleAgc diff --git a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc index 1c6bd273e4..b5e3195cac 100644 --- a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc +++ b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc @@ -26,8 +26,8 @@ TEST(H264VideoToolboxNaluTest, TestHasVideoFormatDescription) { const uint8_t sps_buffer[] = {0x00, 0x00, 0x00, 0x01, 0x27}; EXPECT_TRUE(H264AnnexBBufferHasVideoFormatDescription(sps_buffer, arraysize(sps_buffer))); - const uint8_t aud_sps_buffer[] = {0x00, 0x00, 0x00, 0x01, 0x29, - 0x00, 0x00, 0x00, 0x01, 0x27}; + const uint8_t aud_sps_buffer[] = {0x00, 0x00, 0x00, 0x01, 0x29, 0x10, + 0x00, 0x00, 0x00, 0x01, 0x27, 0xFF}; EXPECT_TRUE(H264AnnexBBufferHasVideoFormatDescription( aud_sps_buffer, arraysize(aud_sps_buffer))); const uint8_t other_buffer[] = {0x00, 0x00, 0x00, 0x01, 0x28}; diff --git a/webrtc/test/testsupport/fileutils.cc b/webrtc/test/testsupport/fileutils.cc index ef8e5d5c8d..fb66a1a95d 100644 --- a/webrtc/test/testsupport/fileutils.cc +++ b/webrtc/test/testsupport/fileutils.cc @@ -45,6 +45,7 @@ namespace test { #if defined(WEBRTC_IOS) // Defined in iosfileutils.mm. No header file to discourage use elsewhere. std::string IOSOutputPath(); +std::string IOSRootPath(); std::string IOSResourcePath(std::string name, std::string extension); #endif @@ -119,6 +120,9 @@ std::string WorkingDir() { #else // WEBRTC_ANDROID std::string ProjectRootPath() { +#if defined(WEBRTC_IOS) + return IOSRootPath(); +#else std::string path = WorkingDir(); if (path == kFallbackPath) { return kCannotFindProjectRootDir; @@ -141,6 +145,7 @@ std::string ProjectRootPath() { } fprintf(stderr, "Cannot find project root directory!\n"); return kCannotFindProjectRootDir; +#endif } std::string OutputPath() { diff --git a/webrtc/test/testsupport/iosfileutils.mm b/webrtc/test/testsupport/iosfileutils.mm index 87b7397c79..6bbe082385 100644 --- a/webrtc/test/testsupport/iosfileutils.mm +++ b/webrtc/test/testsupport/iosfileutils.mm @@ -54,6 +54,13 @@ std::string IOSResourcePath(std::string name, std::string extension) { } } +std::string IOSRootPath() { + @autoreleasepool { + NSBundle* mainBundle = [NSBundle mainBundle]; + return StdStringFromNSString(mainBundle.bundlePath) + "/"; + } +} + // For iOS, we don't have access to the output directory. Return the path to the // temporary directory instead. This is mostly used by tests that need to write // output files to disk.