#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/web_applications/web_app_icon_generator.h"
#include <string>
#include <vector>
#include "base/containers/contains.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image_skia_rep.h"
namespace web_app {
namespace {
const int kIconSizeSmallBetweenMediumAndLarge = …;
const int kIconSizeLargeBetweenMediumAndLarge = …;
std::set<int> TestSizesToGenerate() { … }
void ValidateAllIconsWithURLsArePresent(
const std::vector<SkBitmap>& bitmaps_to_check,
const SizeToBitmap& size_map) { … }
std::vector<SkBitmap>::const_iterator FindLargestSkBitmapVector(
const std::vector<SkBitmap>& bitmap_vector) { … }
std::vector<SkBitmap>::const_iterator FindMatchingSkBitmapVector(
const std::vector<SkBitmap>& bitmap_vector,
int size) { … }
std::vector<SkBitmap>::const_iterator FindEqualOrLargerSkBitmapVector(
const std::vector<SkBitmap>& bitmap_vector,
int size) { … }
void ValidateIconsGeneratedAndResizedCorrectly(
const std::vector<SkBitmap>& downloaded,
const SizeToBitmap& size_map,
const std::set<int>& sizes_to_generate,
int expected_generated,
int expected_resized) { … }
void ValidateBitmapSizeAndColor(const SkBitmap& bitmap,
int size,
SkColor color) { … }
void TestIconGeneration(int icon_size,
int expected_generated,
int expected_resized) { … }
}
class WebAppIconGeneratorTest : public testing::Test { … };
TEST_F(WebAppIconGeneratorTest, ConstrainBitmapsToSizes) { … }
TEST_F(WebAppIconGeneratorTest, LinkedAppIconsAreNotChanged) { … }
TEST_F(WebAppIconGeneratorTest, IconsResizedFromOddSizes) { … }
TEST_F(WebAppIconGeneratorTest, IconsResizedFromLarger) { … }
TEST_F(WebAppIconGeneratorTest, AllIconsGeneratedWhenNotDownloaded) { … }
TEST_F(WebAppIconGeneratorTest, IconResizedFromLargerAndSmaller) { … }
TEST_F(WebAppIconGeneratorTest, IconsResizedWhenOnlyATinyOneIsProvided) { … }
TEST_F(WebAppIconGeneratorTest, IconsResizedWhenOnlyAGigantorOneIsProvided) { … }
TEST_F(WebAppIconGeneratorTest, GenerateIcons) { … }
TEST_F(WebAppIconGeneratorTest, ConvertImageToSolidFillMonochrome) { … }
TEST_F(WebAppIconGeneratorTest, ConvertImageToSolidFillMonochrome_Empty) { … }
}