#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "gtest-utils.h"
#include <gtest/gtest.h>
#include <string>
extern "C" int jpegtran(int argc, char *argv[]);
TEST(JPEGTranTest, ICC) { … }
TEST(JPEGTranTest, Crop) { … }
#ifdef C_ARITH_CODING_SUPPORTED
TEST(JPEGTranTest, ISlow420Ari) {
base::FilePath input_image_path;
GetTestFilePath(&input_image_path, "testimgint.jpg");
base::FilePath output_path(GetTargetDirectory());
output_path = output_path.AppendASCII("testout_420_islow_ari2.jpg");
std::string prog_name = "jpegtran";
std::string arg1 = "-arithmetic";
std::string arg2 = "-outfile";
std::string arg3 = output_path.MaybeAsASCII();
std::string arg4 = input_image_path.MaybeAsASCII();
char *command_line[] = { &prog_name[0],
&arg1[0], &arg2[0], &arg3[0], &arg4[0]
};
EXPECT_EQ(jpegtran(5, command_line), 0);
const std::string EXPECTED_MD5 = "e986fb0a637a8d833d96e8a6d6d84ea1";
EXPECT_TRUE(CompareFileAndMD5(output_path, EXPECTED_MD5));
}
TEST(JPEGTranTest, ISlow420) {
base::FilePath input_image_path;
GetTestFilePath(&input_image_path, "testimgari.jpg");
base::FilePath output_path(GetTargetDirectory());
output_path = output_path.AppendASCII("testout_420_islow.jpg");
std::string prog_name = "jpegtran";
std::string arg1 = "-outfile";
std::string arg2 = output_path.MaybeAsASCII();
std::string arg3 = input_image_path.MaybeAsASCII();
char *command_line[] = { &prog_name[0],
&arg1[0], &arg2[0], &arg3[0]
};
EXPECT_EQ(jpegtran(4, command_line), 0);
const std::string EXPECTED_MD5 = "9a68f56bc76e466aa7e52f415d0f4a5f";
EXPECT_TRUE(CompareFileAndMD5(output_path, EXPECTED_MD5));
}
#endif