Bug 1217261 - Update mp4parse_rust gtest for api changes. r=kinetik.
authorRalph Giles <giles@mozilla.com>
Wed, 21 Oct 2015 18:16:28 -0700
changeset 268876 2d19d26df5128c2694ce34ac1b6a86681a64da15
parent 268875 2ca3997df07f3f46dd97fe15bbfdec8e51913693
child 268877 ec846e6a01343d45bdec8f220344509050e99262
push id66957
push userrgiles@mozilla.com
push dateThu, 22 Oct 2015 01:54:26 +0000
treeherdermozilla-inbound@ec846e6a0134 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1217261
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1217261 - Update mp4parse_rust gtest for api changes. r=kinetik. Allocate an mp4parse_state struct and pass it through.
media/libstagefright/gtest/TestMP4Rust.cpp
media/libstagefright/gtest/moz.build
--- a/media/libstagefright/gtest/TestMP4Rust.cpp
+++ b/media/libstagefright/gtest/TestMP4Rust.cpp
@@ -1,50 +1,68 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gtest/gtest.h"
 #include "mp4_demuxer/MP4Metadata.h"
+#include "mp4parse.h"
 
 #include <stdint.h>
 #include <stdio.h>
 #include <vector>
 
-extern "C" int32_t read_box_from_buffer(uint8_t *buffer, size_t size);
-
 using namespace mp4_demuxer;
 using namespace mozilla;
 
 TEST(rust, MP4MetadataEmpty)
 {
   int32_t rv;
-  rv = read_box_from_buffer(nullptr, 0);
+
+  mp4parse_state* context = mp4parse_new();
+  ASSERT_NE(context, nullptr);
+
+  rv = mp4parse_read(nullptr, nullptr, 0);
+  EXPECT_EQ(rv, -1);
+  rv = mp4parse_read(context, nullptr, 0);
   EXPECT_EQ(rv, -1);
 
   size_t len = 4097;
-  rv = read_box_from_buffer(nullptr, len);
+  rv = mp4parse_read(nullptr, nullptr, len);
+  EXPECT_EQ(rv, -1);
+  rv = mp4parse_read(context, nullptr, len);
   EXPECT_EQ(rv, -1);
 
   std::vector<uint8_t> buf;
-  rv = read_box_from_buffer(buf.data(), buf.size());
+  rv = mp4parse_read(nullptr, buf.data(), buf.size());
+  EXPECT_EQ(rv, -1);
+  rv = mp4parse_read(context, buf.data(), buf.size());
   EXPECT_EQ(rv, -1);
 
   buf.reserve(len);
-  rv = read_box_from_buffer(buf.data(), buf.size());
+  rv = mp4parse_read(nullptr, buf.data(), buf.size());
   EXPECT_EQ(rv, -1);
+  rv = mp4parse_read(context, buf.data(), buf.size());
+  EXPECT_EQ(rv, -1);
+
+  mp4parse_free(context);
 }
 
 TEST(rust, MP4Metadata)
 {
   FILE* f = fopen("street.mp4", "rb");
   ASSERT_TRUE(f != nullptr);
 
   size_t len = 4096;
   std::vector<uint8_t> buf(len);
   size_t read = fread(buf.data(), sizeof(decltype(buf)::value_type), buf.size(), f);
   buf.resize(read);
   fclose(f);
 
-  int32_t rv = read_box_from_buffer(buf.data(), buf.size());
+  mp4parse_state* context = mp4parse_new();
+  ASSERT_NE(context, nullptr);
+
+  int32_t rv = mp4parse_read(context, buf.data(), buf.size());
   EXPECT_EQ(rv, 2);
+
+  mp4parse_free(context);
 }
--- a/media/libstagefright/gtest/moz.build
+++ b/media/libstagefright/gtest/moz.build
@@ -18,13 +18,16 @@ TEST_HARNESS_FILES.gtest += [
     'test_case_1204580.mp4',
 ]
 
 if CONFIG['MOZ_RUST']:
     UNIFIED_SOURCES += ['TestMP4Rust.cpp',]
     TEST_HARNESS_FILES.gtest += [
         '../../../dom/media/test/street.mp4',
     ]
+    LOCAL_INCLUDES += [
+        '../binding/include',
+    ]
 
 FINAL_LIBRARY = 'xul-gtest'
 
 if CONFIG['GNU_CXX']:
     CXXFLAGS += ['-Wshadow']