summaryrefslogtreecommitdiff
path: root/src/ast_jpeg_decoder_test.cpp
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2018-09-05 18:30:59 +0300
committerEd Tanous <ed.tanous@intel.com>2018-09-05 18:44:12 +0300
commit1abe55ef9844afcddcab9d862ae06118f3a2390c (patch)
treed0b5fcfd0b1cd679a8995af3eb0b6d31b368380e /src/ast_jpeg_decoder_test.cpp
parenta38b0b206300c792979b900f506b85e535f5708a (diff)
downloadbmcweb-1abe55ef9844afcddcab9d862ae06118f3a2390c.tar.xz
Move to clang-format-6.0
This commit moves the codebase to the lastest clang-format file from upstream, as well as clang-format-6.0. Change-Id: Ice8313468097c0c42317fbb9e10ddf036e8cff4c Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'src/ast_jpeg_decoder_test.cpp')
-rw-r--r--src/ast_jpeg_decoder_test.cpp283
1 files changed, 147 insertions, 136 deletions
diff --git a/src/ast_jpeg_decoder_test.cpp b/src/ast_jpeg_decoder_test.cpp
index 277ba2cc8b..1552f46f76 100644
--- a/src/ast_jpeg_decoder_test.cpp
+++ b/src/ast_jpeg_decoder_test.cpp
@@ -1,4 +1,5 @@
#include "ast_jpeg_decoder.hpp"
+
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -10,150 +11,160 @@
using namespace testing;
MATCHER_P2(IsBetween, a, b,
std::string(negation ? "isn't" : "is") + " between " +
- PrintToString(a) + " and " + PrintToString(b)) {
- return a <= arg && arg <= b;
+ PrintToString(a) + " and " + PrintToString(b))
+{
+ return a <= arg && arg <= b;
};
-TEST(AstJpegDecoder, AllBlue) {
- ast_video::RawVideoBuffer out;
-
- // This binary blog was created on the aspeed hardware using a blue screen
- // consisting of the color 0x8EFFFA in a web browser window
- FILE *fp = fopen("test_resources/aspeedbluescreen.bin", "rb");
- EXPECT_NE(fp, nullptr);
- size_t bufferlen =
- fread(out.buffer.data(), sizeof(decltype(out.buffer)::value_type),
- out.buffer.size(), fp);
- fclose(fp);
-
- ASSERT_GT(bufferlen, 0);
-
- out.ySelector = 0;
- out.uvSelector = 0;
- out.mode = ast_video::YuvMode::YUV444;
- out.width = 800;
- out.height = 600;
-
- ast_video::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
- out.uvSelector);
-
- int tolerance = 16;
-
- // All pixels should be blue (0x8EFFFA) to within a tolerance (due to jpeg
- // compression artifacts and quanitization)
- for (int i = 0; i < out.width * out.height; i++) {
- ast_video::RGB &pixel = d.outBuffer[i];
- EXPECT_GT(pixel.r, 0x8E - tolerance);
- EXPECT_LT(pixel.r, 0x8E + tolerance);
- EXPECT_GT(pixel.g, 0xFF - tolerance);
- EXPECT_LT(pixel.g, 0xFF + tolerance);
- EXPECT_GT(pixel.b, 0xF1 - tolerance);
- EXPECT_LT(pixel.b, 0xF1 + tolerance);
- }
+TEST(AstJpegDecoder, AllBlue)
+{
+ ast_video::RawVideoBuffer out;
+
+ // This binary blog was created on the aspeed hardware using a blue screen
+ // consisting of the color 0x8EFFFA in a web browser window
+ FILE *fp = fopen("test_resources/aspeedbluescreen.bin", "rb");
+ EXPECT_NE(fp, nullptr);
+ size_t bufferlen =
+ fread(out.buffer.data(), sizeof(decltype(out.buffer)::value_type),
+ out.buffer.size(), fp);
+ fclose(fp);
+
+ ASSERT_GT(bufferlen, 0);
+
+ out.ySelector = 0;
+ out.uvSelector = 0;
+ out.mode = ast_video::YuvMode::YUV444;
+ out.width = 800;
+ out.height = 600;
+
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
+
+ int tolerance = 16;
+
+ // All pixels should be blue (0x8EFFFA) to within a tolerance (due to jpeg
+ // compression artifacts and quanitization)
+ for (int i = 0; i < out.width * out.height; i++)
+ {
+ ast_video::RGB &pixel = d.outBuffer[i];
+ EXPECT_GT(pixel.r, 0x8E - tolerance);
+ EXPECT_LT(pixel.r, 0x8E + tolerance);
+ EXPECT_GT(pixel.g, 0xFF - tolerance);
+ EXPECT_LT(pixel.g, 0xFF + tolerance);
+ EXPECT_GT(pixel.b, 0xF1 - tolerance);
+ EXPECT_LT(pixel.b, 0xF1 + tolerance);
+ }
}
-TEST(AstJpegDecoder, AllBlack) {
- ast_video::RawVideoBuffer out;
-
- // This binary blog was created on the aspeed hardware using a black screen
- FILE *fp = fopen("test_resources/aspeedblackscreen.bin", "rb");
- EXPECT_NE(fp, nullptr);
- size_t bufferlen = fread(out.buffer.data(), sizeof(char),
- out.buffer.size() * sizeof(long), fp);
- fclose(fp);
-
- ASSERT_GT(bufferlen, 0);
-
- out.ySelector = 0;
- out.uvSelector = 0;
- out.mode = ast_video::YuvMode::YUV444;
- out.width = 800;
- out.height = 600;
-
- ast_video::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
- out.uvSelector);
-
- // All pixels should be blue (0x8EFFFA) to within a tolerance (due to jpeg
- // compression artifacts and quanitization)
- for (int x = 0; x < out.width; x++) {
- for (int y = 0; y < out.height; y++) {
- ast_video::RGB pixel = d.outBuffer[x + (y * out.width)];
- ASSERT_EQ(pixel.r, 0x00) << "X:" << x << " Y: " << y;
- ASSERT_EQ(pixel.g, 0x00) << "X:" << x << " Y: " << y;
- ASSERT_EQ(pixel.b, 0x00) << "X:" << x << " Y: " << y;
+TEST(AstJpegDecoder, AllBlack)
+{
+ ast_video::RawVideoBuffer out;
+
+ // This binary blog was created on the aspeed hardware using a black screen
+ FILE *fp = fopen("test_resources/aspeedblackscreen.bin", "rb");
+ EXPECT_NE(fp, nullptr);
+ size_t bufferlen = fread(out.buffer.data(), sizeof(char),
+ out.buffer.size() * sizeof(long), fp);
+ fclose(fp);
+
+ ASSERT_GT(bufferlen, 0);
+
+ out.ySelector = 0;
+ out.uvSelector = 0;
+ out.mode = ast_video::YuvMode::YUV444;
+ out.width = 800;
+ out.height = 600;
+
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
+
+ // All pixels should be blue (0x8EFFFA) to within a tolerance (due to jpeg
+ // compression artifacts and quanitization)
+ for (int x = 0; x < out.width; x++)
+ {
+ for (int y = 0; y < out.height; y++)
+ {
+ ast_video::RGB pixel = d.outBuffer[x + (y * out.width)];
+ ASSERT_EQ(pixel.r, 0x00) << "X:" << x << " Y: " << y;
+ ASSERT_EQ(pixel.g, 0x00) << "X:" << x << " Y: " << y;
+ ASSERT_EQ(pixel.b, 0x00) << "X:" << x << " Y: " << y;
+ }
}
- }
}
-TEST(AstJpegDecoder, TestColors) {
- ast_video::RawVideoBuffer out;
-
- // This binary blog was created on the aspeed hardware using a blue screen
- // consisting of the color 0x8EFFFA in a web browser window
- FILE *fp = fopen("test_resources/ubuntu_444_800x600_0chrom_0lum.bin", "rb");
- EXPECT_NE(fp, nullptr);
- size_t bufferlen = fread(out.buffer.data(), sizeof(char),
- out.buffer.size() * sizeof(long), fp);
- fclose(fp);
-
- ASSERT_GT(bufferlen, 0);
-
- out.ySelector = 0;
- out.uvSelector = 0;
- out.mode = ast_video::YuvMode::YUV444;
- out.width = 800;
- out.height = 600;
-
- ast_video::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
- out.uvSelector);
-
- int tolerance = 16;
- /*
- for (int i = 0; i < out.width * out.height; i++) {
- ast_video::RGB &pixel = d.outBuffer[i];
- EXPECT_GT(pixel.r, 0x8E - tolerance);
- EXPECT_LT(pixel.r, 0x8E + tolerance);
- EXPECT_GT(pixel.g, 0xFF - tolerance);
- EXPECT_LT(pixel.g, 0xFF + tolerance);
- EXPECT_GT(pixel.b, 0xF1 - tolerance);
- EXPECT_LT(pixel.b, 0xF1 + tolerance);
- }
- */
+TEST(AstJpegDecoder, TestColors)
+{
+ ast_video::RawVideoBuffer out;
+
+ // This binary blog was created on the aspeed hardware using a blue screen
+ // consisting of the color 0x8EFFFA in a web browser window
+ FILE *fp = fopen("test_resources/ubuntu_444_800x600_0chrom_0lum.bin", "rb");
+ EXPECT_NE(fp, nullptr);
+ size_t bufferlen = fread(out.buffer.data(), sizeof(char),
+ out.buffer.size() * sizeof(long), fp);
+ fclose(fp);
+
+ ASSERT_GT(bufferlen, 0);
+
+ out.ySelector = 0;
+ out.uvSelector = 0;
+ out.mode = ast_video::YuvMode::YUV444;
+ out.width = 800;
+ out.height = 600;
+
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
+
+ int tolerance = 16;
+ /*
+ for (int i = 0; i < out.width * out.height; i++) {
+ ast_video::RGB &pixel = d.outBuffer[i];
+ EXPECT_GT(pixel.r, 0x8E - tolerance);
+ EXPECT_LT(pixel.r, 0x8E + tolerance);
+ EXPECT_GT(pixel.g, 0xFF - tolerance);
+ EXPECT_LT(pixel.g, 0xFF + tolerance);
+ EXPECT_GT(pixel.b, 0xF1 - tolerance);
+ EXPECT_LT(pixel.b, 0xF1 + tolerance);
+ }
+ */
}
// Tests the buffers around the screen aren't written to
-TEST(AstJpegDecoder, BufferLimits) {
- ast_video::RawVideoBuffer out;
-
- // This binary blog was created on the aspeed hardware using a black screen
- FILE *fp = fopen("test_resources/aspeedblackscreen.bin", "rb");
- EXPECT_NE(fp, nullptr);
- size_t bufferlen = fread(out.buffer.data(), sizeof(char),
- out.buffer.size() * sizeof(long), fp);
- fclose(fp);
-
- ASSERT_GT(bufferlen, 0);
-
- out.ySelector = 0;
- out.uvSelector = 0;
- out.mode = ast_video::YuvMode::YUV444;
- out.width = 800;
- out.height = 600;
-
- ast_video::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
- out.uvSelector);
- // reserved pixel should be default value
- for (auto &pixel : d.outBuffer) {
- EXPECT_EQ(pixel.reserved, 0xAA);
- }
- // All pixels beyond the buffer should be zero
- for (int i = out.width * out.height; i < d.outBuffer.size(); i++) {
- EXPECT_EQ(d.outBuffer[i].r, 0x00) << "index:" << i;
- EXPECT_EQ(d.outBuffer[i].b, 0x00) << "index:" << i;
- EXPECT_EQ(d.outBuffer[i].g, 0x00) << "index:" << i;
- }
+TEST(AstJpegDecoder, BufferLimits)
+{
+ ast_video::RawVideoBuffer out;
+
+ // This binary blog was created on the aspeed hardware using a black screen
+ FILE *fp = fopen("test_resources/aspeedblackscreen.bin", "rb");
+ EXPECT_NE(fp, nullptr);
+ size_t bufferlen = fread(out.buffer.data(), sizeof(char),
+ out.buffer.size() * sizeof(long), fp);
+ fclose(fp);
+
+ ASSERT_GT(bufferlen, 0);
+
+ out.ySelector = 0;
+ out.uvSelector = 0;
+ out.mode = ast_video::YuvMode::YUV444;
+ out.width = 800;
+ out.height = 600;
+
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
+ // reserved pixel should be default value
+ for (auto &pixel : d.outBuffer)
+ {
+ EXPECT_EQ(pixel.reserved, 0xAA);
+ }
+ // All pixels beyond the buffer should be zero
+ for (int i = out.width * out.height; i < d.outBuffer.size(); i++)
+ {
+ EXPECT_EQ(d.outBuffer[i].r, 0x00) << "index:" << i;
+ EXPECT_EQ(d.outBuffer[i].b, 0x00) << "index:" << i;
+ EXPECT_EQ(d.outBuffer[i].g, 0x00) << "index:" << i;
+ }
} \ No newline at end of file