tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

image_bundle_test.cc (1420B)


      1 // Copyright (c) the JPEG XL Project Authors. All rights reserved.
      2 //
      3 // Use of this source code is governed by a BSD-style
      4 // license that can be found in the LICENSE file.
      5 
      6 #include <jxl/memory_manager.h>
      7 
      8 #include <utility>
      9 
     10 #include "lib/jxl/base/status.h"
     11 #include "lib/jxl/dec_bit_reader.h"
     12 #include "lib/jxl/enc_aux_out.h"
     13 #include "lib/jxl/enc_bit_writer.h"
     14 #include "lib/jxl/image_metadata.h"
     15 #include "lib/jxl/test_memory_manager.h"
     16 #include "lib/jxl/test_utils.h"
     17 #include "lib/jxl/testing.h"
     18 
     19 namespace jxl {
     20 namespace {
     21 
     22 TEST(ImageBundleTest, ExtraChannelName) {
     23  JxlMemoryManager* memory_manager = jxl::test::MemoryManager();
     24  AuxOut aux_out;
     25  BitWriter writer{memory_manager};
     26  ASSERT_TRUE(
     27      writer.WithMaxBits(99, LayerType::Header, &aux_out, [&]() -> Status {
     28        ImageMetadata metadata;
     29        ExtraChannelInfo eci;
     30        eci.type = ExtraChannel::kBlack;
     31        eci.name = "testK";
     32        metadata.extra_channel_info.push_back(std::move(eci));
     33        JXL_RETURN_IF_ERROR(
     34            WriteImageMetadata(metadata, &writer, LayerType::Header, &aux_out));
     35        writer.ZeroPadToByte();
     36        return true;
     37      }));
     38 
     39  BitReader reader(writer.GetSpan());
     40  ImageMetadata metadata_out;
     41  ASSERT_TRUE(ReadImageMetadata(&reader, &metadata_out));
     42  EXPECT_TRUE(reader.Close());
     43  EXPECT_EQ("testK", metadata_out.Find(ExtraChannel::kBlack)->name);
     44 }
     45 
     46 }  // namespace
     47 }  // namespace jxl