Commit 4afda6fc authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Fix CanDecodeType test failure if AVIF is disabled

Fix the ImageDecoderTest.CanDecodeType test failure when the AVIF
feature is disabled.

The ImageDecoderExternal::canDecodeType() method ultimately depends on
what is added to image_types_ in the MimeUtil constructor:

  MimeUtil::MimeUtil() {
    ...
    for (const char* type : kSupportedImageTypes)
      image_types_.insert(type);
  #if BUILDFLAG(ENABLE_AV1_DECODER)
    ...
    if (base::FeatureList::IsEnabled(features::kAVIF))
      image_types_.insert("image/avif");
  #endif

So the return value of ImageDecoderExternal::canDecodeType("image/avif")
should match base::FeatureList::IsEnabled(features::kAVIF).

Test:
blink_unittests --enable-features=AVIF \
    --gtest_filter=ImageDecoderTest.CanDecodeType
blink_unittests --disable-features=AVIF \
    --gtest_filter=ImageDecoderTest.CanDecodeType

Bug: 1116502
Change-Id: Idb5a13f5cc4e78c0d9671b7460601a412936bec9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2357961Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarThomas Guilbert <tguilbert@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Cr-Commit-Position: refs/heads/master@{#798361}
parent c99b5179
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
#include "third_party/blink/renderer/modules/webcodecs/image_decoder_external.h" #include "third_party/blink/renderer/modules/webcodecs/image_decoder_external.h"
#include "base/feature_list.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_tester.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_tester.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_image_decoder_init.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_image_decoder_init.h"
...@@ -71,7 +73,8 @@ TEST_F(ImageDecoderTest, CanDecodeType) { ...@@ -71,7 +73,8 @@ TEST_F(ImageDecoderTest, CanDecodeType) {
EXPECT_TRUE(ImageDecoderExternal::canDecodeType("image/x-xbitmap")); EXPECT_TRUE(ImageDecoderExternal::canDecodeType("image/x-xbitmap"));
#if BUILDFLAG(ENABLE_AV1_DECODER) #if BUILDFLAG(ENABLE_AV1_DECODER)
EXPECT_TRUE(ImageDecoderExternal::canDecodeType("image/avif")); EXPECT_EQ(ImageDecoderExternal::canDecodeType("image/avif"),
base::FeatureList::IsEnabled(features::kAVIF));
#else #else
EXPECT_FALSE(ImageDecoderExternal::canDecodeType("image/avif")); EXPECT_FALSE(ImageDecoderExternal::canDecodeType("image/avif"));
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment