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-Original-Commit-Position: refs/heads/master@{#14472}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 470c0887b334f1b859f2fd0055ab840370f5cc7e
diff --git a/modules/BUILD.gn b/modules/BUILD.gn
index 59a4b3c..daeb7e9 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -693,11 +693,14 @@
       ]
 
       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/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc
index b0c6526..6e0b175 100644
--- a/modules/audio_processing/audio_processing_unittest.cc
+++ b/modules/audio_processing/audio_processing_unittest.cc
@@ -293,7 +293,7 @@
     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 @@
 
 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/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc
index b4e0ee7..ffaf609 100644
--- a/modules/audio_processing/test/debug_dump_test.cc
+++ b/modules/audio_processing/test/debug_dump_test.cc
@@ -516,8 +516,8 @@
   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/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc b/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc
index 1c6bd27..b5e3195 100644
--- a/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc
+++ b/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc
@@ -26,8 +26,8 @@
   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/test/testsupport/fileutils.cc b/test/testsupport/fileutils.cc
index ef8e5d5..fb66a1a 100644
--- a/test/testsupport/fileutils.cc
+++ b/test/testsupport/fileutils.cc
@@ -45,6 +45,7 @@
 #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 @@
 #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 @@
   }
   fprintf(stderr, "Cannot find project root directory!\n");
   return kCannotFindProjectRootDir;
+#endif
 }
 
 std::string OutputPath() {
diff --git a/test/testsupport/iosfileutils.mm b/test/testsupport/iosfileutils.mm
index 87b7397..6bbe082 100644
--- a/test/testsupport/iosfileutils.mm
+++ b/test/testsupport/iosfileutils.mm
@@ -54,6 +54,13 @@
   }
 }
 
+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.