1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2020, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <string>
13*77c1e3ccSAndroid Build Coastguard Worker #include "common/webmenc.h"
14*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
15*77c1e3ccSAndroid Build Coastguard Worker
16*77c1e3ccSAndroid Build Coastguard Worker namespace {
17*77c1e3ccSAndroid Build Coastguard Worker
18*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_WEBM_IO
19*77c1e3ccSAndroid Build Coastguard Worker
20*77c1e3ccSAndroid Build Coastguard Worker class WebmencTest : public ::testing::Test {};
21*77c1e3ccSAndroid Build Coastguard Worker
22*77c1e3ccSAndroid Build Coastguard Worker // All of these variations on output should be identical.
TEST(WebmencTest,ExtractEncoderSettingsOutput1)23*77c1e3ccSAndroid Build Coastguard Worker TEST(WebmencTest, ExtractEncoderSettingsOutput1) {
24*77c1e3ccSAndroid Build Coastguard Worker const char *argv[] = { "aomenc", "-o", "output", "input",
25*77c1e3ccSAndroid Build Coastguard Worker "--target-bitrate=300" };
26*77c1e3ccSAndroid Build Coastguard Worker int argc = 5;
27*77c1e3ccSAndroid Build Coastguard Worker const std::string expected("version:1.2.3 --target-bitrate=300");
28*77c1e3ccSAndroid Build Coastguard Worker char *result = extract_encoder_settings("1.2.3", argv, argc, "input");
29*77c1e3ccSAndroid Build Coastguard Worker ASSERT_EQ(expected, std::string(result));
30*77c1e3ccSAndroid Build Coastguard Worker free(result);
31*77c1e3ccSAndroid Build Coastguard Worker }
32*77c1e3ccSAndroid Build Coastguard Worker
TEST(WebmencTest,ExtractEncoderSettingsOutput2)33*77c1e3ccSAndroid Build Coastguard Worker TEST(WebmencTest, ExtractEncoderSettingsOutput2) {
34*77c1e3ccSAndroid Build Coastguard Worker const char *argv[] = { "aomenc", "--output", "bar", "foo", "--cpu-used=3" };
35*77c1e3ccSAndroid Build Coastguard Worker int argc = 5;
36*77c1e3ccSAndroid Build Coastguard Worker const std::string expected("version:abc --cpu-used=3");
37*77c1e3ccSAndroid Build Coastguard Worker char *result = extract_encoder_settings("abc", argv, argc, "foo");
38*77c1e3ccSAndroid Build Coastguard Worker ASSERT_EQ(expected, std::string(result));
39*77c1e3ccSAndroid Build Coastguard Worker free(result);
40*77c1e3ccSAndroid Build Coastguard Worker }
41*77c1e3ccSAndroid Build Coastguard Worker
TEST(WebmencTest,ExtractEncoderSettingsOutput3)42*77c1e3ccSAndroid Build Coastguard Worker TEST(WebmencTest, ExtractEncoderSettingsOutput3) {
43*77c1e3ccSAndroid Build Coastguard Worker const char *argv[] = { "aomenc", "--cq-level=63", "--end-usage=q",
44*77c1e3ccSAndroid Build Coastguard Worker "--output=foo", "baz" };
45*77c1e3ccSAndroid Build Coastguard Worker int argc = 5;
46*77c1e3ccSAndroid Build Coastguard Worker const std::string expected("version:23 --cq-level=63 --end-usage=q");
47*77c1e3ccSAndroid Build Coastguard Worker char *result = extract_encoder_settings("23", argv, argc, "baz");
48*77c1e3ccSAndroid Build Coastguard Worker ASSERT_EQ(expected, std::string(result));
49*77c1e3ccSAndroid Build Coastguard Worker free(result);
50*77c1e3ccSAndroid Build Coastguard Worker }
51*77c1e3ccSAndroid Build Coastguard Worker
TEST(WebmencTest,ExtractEncoderSettingsInput)52*77c1e3ccSAndroid Build Coastguard Worker TEST(WebmencTest, ExtractEncoderSettingsInput) {
53*77c1e3ccSAndroid Build Coastguard Worker // Check that input filename is filtered regardless of position.
54*77c1e3ccSAndroid Build Coastguard Worker const char *argv[] = { "aomenc", "-o", "out", "input", "-p", "2" };
55*77c1e3ccSAndroid Build Coastguard Worker int argc = 6;
56*77c1e3ccSAndroid Build Coastguard Worker const char version[] = "1.0.0";
57*77c1e3ccSAndroid Build Coastguard Worker const std::string expected("version:1.0.0 -p 2");
58*77c1e3ccSAndroid Build Coastguard Worker char *result = extract_encoder_settings(version, argv, argc, "input");
59*77c1e3ccSAndroid Build Coastguard Worker ASSERT_EQ(expected, std::string(result));
60*77c1e3ccSAndroid Build Coastguard Worker free(result);
61*77c1e3ccSAndroid Build Coastguard Worker
62*77c1e3ccSAndroid Build Coastguard Worker const char *argv2[] = { "aomenc", "input", "-o", "out", "-p", "2" };
63*77c1e3ccSAndroid Build Coastguard Worker result = extract_encoder_settings(version, argv2, argc, "input");
64*77c1e3ccSAndroid Build Coastguard Worker ASSERT_EQ(expected, std::string(result));
65*77c1e3ccSAndroid Build Coastguard Worker free(result);
66*77c1e3ccSAndroid Build Coastguard Worker }
67*77c1e3ccSAndroid Build Coastguard Worker
68*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_WEBM_IO
69*77c1e3ccSAndroid Build Coastguard Worker } // namespace
70