1 // Copyright 2023 Google LLC
2 // SPDX-License-Identifier: BSD-2-Clause
3 
4 #include "avif/avif.h"
5 #include "aviftest_helpers.h"
6 #include "gtest/gtest.h"
7 
8 namespace avif {
9 namespace {
10 
11 // Used to pass the data folder path to the GoogleTest suites.
12 const char* data_path = nullptr;
13 
TEST(AvifDecodeTest,ColorGridAlphaNoGrid)14 TEST(AvifDecodeTest, ColorGridAlphaNoGrid) {
15   if (!testutil::Av1DecoderAvailable()) {
16     GTEST_SKIP() << "AV1 Codec unavailable, skip test.";
17   }
18   // Test case from https://github.com/AOMediaCodec/libavif/issues/1203.
19   const char* file_name = "color_grid_alpha_nogrid.avif";
20   DecoderPtr decoder(avifDecoderCreate());
21   ASSERT_NE(decoder, nullptr);
22   ASSERT_EQ(avifDecoderSetIOFile(decoder.get(),
23                                  (std::string(data_path) + file_name).c_str()),
24             AVIF_RESULT_OK);
25   ASSERT_EQ(avifDecoderParse(decoder.get()), AVIF_RESULT_OK);
26   EXPECT_EQ(decoder->compressionFormat, COMPRESSION_FORMAT_AVIF);
27   EXPECT_EQ(decoder->alphaPresent, AVIF_TRUE);
28   EXPECT_EQ(decoder->imageSequenceTrackPresent, AVIF_FALSE);
29   EXPECT_EQ(avifDecoderNextImage(decoder.get()), AVIF_RESULT_OK);
30   EXPECT_NE(decoder->image->alphaPlane, nullptr);
31   EXPECT_GT(decoder->image->alphaRowBytes, 0u);
32 }
33 
34 }  // namespace
35 }  // namespace avif
36 
main(int argc,char ** argv)37 int main(int argc, char** argv) {
38   ::testing::InitGoogleTest(&argc, argv);
39   if (argc != 2) {
40     std::cerr << "There must be exactly one argument containing the path to "
41                  "the test data folder"
42               << std::endl;
43     return 1;
44   }
45   avif::data_path = argv[1];
46   return RUN_ALL_TESTS();
47 }
48