Bug 1175322 - Add gtests for rust mp4 metadata parser. r=k17e

Add a null buffer test.
Add a street.mp4 test.

We have trouble parsing gizmo.mp4, and the dom/media/gtest
already exposes the file, which is confusing since we apparently
can't have duplicates in TEST_HARNESS_FILES.

The street.mp4 test always fails because we don't catch
the eof in the rust code.
This commit is contained in:
Ralph Giles 2015-06-16 15:52:00 -07:00
parent dbec6e99b1
commit 074f872aa1
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,48 @@
/* -*- 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 <cstdint>
#include <fstream>
#include <vector>
extern "C" bool read_box_from_buffer(uint8_t *buffer, size_t size);
using namespace mp4_demuxer;
using namespace mozilla;
TEST(rust, MP4MetadataEmpty)
{
bool rv;
rv = read_box_from_buffer(nullptr, 0);
EXPECT_EQ(rv, false);
size_t len = 4097;
rv = read_box_from_buffer(nullptr, len);
EXPECT_EQ(rv, false);
std::vector<uint8_t> buf;
rv = read_box_from_buffer(buf.data(), buf.size());
EXPECT_EQ(rv, false);
buf.reserve(len);
rv = read_box_from_buffer(buf.data(), buf.size());
EXPECT_EQ(rv, false);
}
TEST(rust, MP4Metadata)
{
std::ifstream f("street.mp4");
ASSERT_TRUE(f.is_open());
size_t len = 4096;
std::vector<uint8_t> buf;
buf.reserve(len);
f.read(reinterpret_cast<char*>(buf.data()), buf.size());
bool rv = read_box_from_buffer(buf.data(), buf.size());
ASSERT_FALSE(rv); // Expected fail: need to trap eof.
}

View File

@ -10,6 +10,12 @@ SOURCES += [
'TestInterval.cpp',
]
if CONFIG['MOZ_RUST']:
UNIFIED_SOURCES += ['TestMP4Rust.cpp',]
TEST_HARNESS_FILES.gtest += [
'../../../dom/media/test/street.mp4',
]
FINAL_LIBRARY = 'xul-gtest'
FAIL_ON_WARNINGS = True