author | Ralph Giles <giles@mozilla.com> |
Tue, 16 Jun 2015 15:52:00 -0700 | |
changeset 249206 | 5988e0ef6cef730019c7e6649865c031879b50da |
parent 249205 | 758e4197540257606a0d817855a1d294d53316a0 |
child 249207 | df1354cdd7fb80f0d014e27bfa026057a2855375 |
push id | 61172 |
push user | rgiles@mozilla.com |
push date | Tue, 16 Jun 2015 23:24:38 +0000 |
treeherder | mozilla-inbound@5988e0ef6cef [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | k17e |
bugs | 1175322 |
milestone | 41.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
|
media/libstagefright/gtest/TestMP4Rust.cpp | file | annotate | diff | comparison | revisions | |
media/libstagefright/gtest/moz.build | file | annotate | diff | comparison | revisions |
new file mode 100644 --- /dev/null +++ b/media/libstagefright/gtest/TestMP4Rust.cpp @@ -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. +}
--- a/media/libstagefright/gtest/moz.build +++ b/media/libstagefright/gtest/moz.build @@ -5,11 +5,17 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. Library('stagefright_gtest') 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