• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 3-Clause Clear License
5  * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
6  * License was not distributed with this source code in the LICENSE file, you
7  * can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the
8  * Alliance for Open Media Patent License 1.0 was not distributed with this
9  * source code in the PATENTS file, you can obtain it at
10  * www.aomedia.org/license/patent.
11  */
12 
13 #include "iamf/cli/iamf_components.h"
14 
15 #include "gtest/gtest.h"
16 #include "iamf/cli/proto/test_vector_metadata.pb.h"
17 #include "iamf/cli/proto/user_metadata.pb.h"
18 #include "iamf/cli/tests/cli_test_utils.h"
19 #include "src/google/protobuf/text_format.h"
20 
21 namespace iamf_tools {
22 namespace {
23 
TEST(IamfComponentsTest,CreateRendererFactoryReturnsNull)24 TEST(IamfComponentsTest, CreateRendererFactoryReturnsNull) {
25   EXPECT_EQ(CreateRendererFactory(), nullptr);
26 }
27 
TEST(IamfComponentsTest,CreatreLoudnessCalculatorFactoryReturnsNull)28 TEST(IamfComponentsTest, CreatreLoudnessCalculatorFactoryReturnsNull) {
29   EXPECT_EQ(CreateLoudnessCalculatorFactory(), nullptr);
30 }
31 
TEST(IamfComponentsTest,CreateObuSequencersReturnsNonNullAndNonZeroObuSequencers)32 TEST(IamfComponentsTest,
33      CreateObuSequencersReturnsNonNullAndNonZeroObuSequencers) {
34   auto obu_sequencers = CreateObuSequencers(
35       {}, GetAndCreateOutputDirectory("iamf_directory"), false);
36 
37   EXPECT_FALSE(obu_sequencers.empty());
38   for (auto& obu_sequencer : obu_sequencers) {
39     EXPECT_NE(obu_sequencer, nullptr);
40   }
41 }
42 
TEST(IamfComponentsTest,CanBeConfiguredWithFixedSizeLebGenerator)43 TEST(IamfComponentsTest, CanBeConfiguredWithFixedSizeLebGenerator) {
44   iamf_tools_cli_proto::UserMetadata user_metadata;
45 
46   ASSERT_EQ(google::protobuf::TextFormat::ParseFromString(
47                 R"pb(
48                   mode: GENERATE_LEB_FIXED_SIZE fixed_size: 5
49                 )pb",
50                 user_metadata.mutable_test_vector_metadata()
51                     ->mutable_leb_generator()),
52             true);
53 
54   auto obu_sequencers = CreateObuSequencers(
55       user_metadata, GetAndCreateOutputDirectory("iamf_directory"), false);
56 
57   EXPECT_FALSE(obu_sequencers.empty());
58   for (auto& obu_sequencer : obu_sequencers) {
59     EXPECT_NE(obu_sequencer, nullptr);
60   }
61 }
62 
TEST(IamfComponentsTest,ReturnsEmptyListWhenLebGeneratorIsInvalid)63 TEST(IamfComponentsTest, ReturnsEmptyListWhenLebGeneratorIsInvalid) {
64   iamf_tools_cli_proto::UserMetadata user_metadata;
65 
66   ASSERT_EQ(google::protobuf::TextFormat::ParseFromString(
67                 R"pb(
68                   mode: GENERATE_LEB_FIXED_SIZE fixed_size: 0
69                 )pb",
70                 user_metadata.mutable_test_vector_metadata()
71                     ->mutable_leb_generator()),
72             true);
73 
74   auto obu_sequencers = CreateObuSequencers(
75       user_metadata, GetAndCreateOutputDirectory("iamf_directory"), false);
76 
77   EXPECT_TRUE(obu_sequencers.empty());
78 }
79 
80 }  // namespace
81 }  // namespace iamf_tools
82