diff options
author | U. Artie Eoff <ullysses.a.eoff@intel.com> | 2016-09-28 13:36:05 -0700 |
---|---|---|
committer | Sean V Kelley <seanvk@posteo.de> | 2016-10-03 11:30:43 -0700 |
commit | b3a8049d5cd9e44daa255173f9783cd4f4b2fa55 (patch) | |
tree | df26e7b389a3338df20f852c8e25b442f72e95a1 /test | |
parent | 034440cd4cee59f76ad211cb80108c1566561d10 (diff) |
test: jpeg/enc: move input creators to data file
Move the ::JPEG::Encode::TestInputCreator's to the
i965_jpeg_test_data[.h|.cpp] files.
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Reviewed-by: Sean V Kelley <seanvk@posteo.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/i965_jpeg_encode_test.cpp | 81 | ||||
-rw-r--r-- | test/i965_jpeg_test_data.cpp | 64 | ||||
-rw-r--r-- | test/i965_jpeg_test_data.h | 45 |
3 files changed, 110 insertions, 80 deletions
diff --git a/test/i965_jpeg_encode_test.cpp b/test/i965_jpeg_encode_test.cpp index c587643..c794bf9 100644 --- a/test/i965_jpeg_encode_test.cpp +++ b/test/i965_jpeg_encode_test.cpp @@ -25,9 +25,8 @@ #include "i965_jpeg_test_data.h" #include "i965_streamable.h" #include "i965_test_fixture.h" -#include "test_utils.h" -#include <algorithm> +#include <numeric> #include <cstring> #include <memory> #include <tuple> @@ -83,51 +82,6 @@ TEST_F(JPEGEncodeTest, Entrypoint) } } -class TestInputCreator -{ -public: - typedef std::shared_ptr<TestInputCreator> Shared; - typedef std::shared_ptr<const TestInputCreator> SharedConst; - - TestInput::Shared create(const unsigned fourcc) const - { - const std::array<unsigned, 2> res = getResolution(); - - TestInput::Shared input(new TestInput(fourcc, res[0], res[1])); - ByteData& bytes = input->bytes; - - RandomValueGenerator<uint8_t> rg(0x00, 0xff); - for (size_t i(0); i < input->planes; ++i) - std::generate_n( - std::back_inserter(bytes), input->sizes[i], - [&rg]{ return rg(); }); - return input; - } - - friend ::std::ostream& operator<<( - ::std::ostream& os, const TestInputCreator& t) - { - t.repr(os); - return os; - } - - friend ::std::ostream& operator<<( - ::std::ostream& os, const TestInputCreator::Shared& t) - { - return os << *t; - } - - friend ::std::ostream& operator<<( - ::std::ostream& os, const TestInputCreator::SharedConst& t) - { - return os << *t; - } - -protected: - virtual std::array<unsigned, 2> getResolution() const = 0; - virtual void repr(std::ostream& os) const = 0; -}; - const TestInput::Shared NV12toI420(const TestInput::SharedConst& nv12) { TestInput::Shared i420( @@ -541,18 +495,6 @@ TEST_P(JPEGEncodeInputTest, Full) VerifyOutput(); } -class RandomSizeCreator - : public TestInputCreator -{ -protected: - std::array<unsigned, 2> getResolution() const - { - static RandomValueGenerator<unsigned> rg(1, 769); - return {rg(), rg()}; - } - void repr(std::ostream& os) const { os << "Random Size"; } -}; - INSTANTIATE_TEST_CASE_P( Random, JPEGEncodeInputTest, ::testing::Combine( @@ -563,27 +505,6 @@ INSTANTIATE_TEST_CASE_P( ) ); -class FixedSizeCreator - : public TestInputCreator -{ -public: - FixedSizeCreator(const std::array<unsigned, 2>& resolution) - : res(resolution) - { } - -protected: - std::array<unsigned, 2> getResolution() const { return res; } - void repr(std::ostream& os) const - { - os << "Fixed Size " << res[0] << "x" << res[1]; - } - -private: - const std::array<unsigned, 2> res; -}; - -typedef std::vector<TestInputCreator::SharedConst> InputCreators; - InputCreators generateCommonInputs() { return { diff --git a/test/i965_jpeg_test_data.cpp b/test/i965_jpeg_test_data.cpp index 84316a8..0c1f0d3 100644 --- a/test/i965_jpeg_test_data.cpp +++ b/test/i965_jpeg_test_data.cpp @@ -25,6 +25,9 @@ #include "i965_jpeg_test_data.h" #include "i965_drv_video.h" #include "i965_streamable.h" +#include "test_utils.h" + +#include <algorithm> namespace JPEG { namespace Decode { @@ -851,5 +854,66 @@ namespace Encode { return os << *t; } + TestInput::Shared TestInputCreator::create(const unsigned fourcc) const + { + const std::array<unsigned, 2> res = getResolution(); + + TestInput::Shared input(new TestInput(fourcc, res[0], res[1])); + ByteData& bytes = input->bytes; + + RandomValueGenerator<uint8_t> rg(0x00, 0xff); + for (size_t i(0); i < input->planes; ++i) + std::generate_n( + std::back_inserter(bytes), input->sizes[i], + [&rg]{ return rg(); }); + return input; + } + + ::std::ostream& operator<<(::std::ostream& os, const TestInputCreator& t) + { + t.repr(os); + return os; + } + + ::std::ostream& operator<<( + ::std::ostream& os, const TestInputCreator::Shared& t) + { + return os << *t; + } + + ::std::ostream& operator<<( + ::std::ostream& os, const TestInputCreator::SharedConst& t) + { + return os << *t; + } + + std::array<unsigned, 2> RandomSizeCreator::getResolution() const + { + static RandomValueGenerator<unsigned> rg(1, 769); + return {rg(), rg()}; + } + + void RandomSizeCreator::repr(::std::ostream& os) const + { + os << "Random Size"; + } + + FixedSizeCreator::FixedSizeCreator( + const std::array<unsigned, 2>& resolution) + : res(resolution) + { + return; + } + + std::array<unsigned, 2> FixedSizeCreator::getResolution() const + { + return res; + } + + void FixedSizeCreator::repr(::std::ostream& os) const + { + os << "Fixed Size " << res[0] << "x" << res[1]; + } + } // namespace Encode } // namespace JPEG diff --git a/test/i965_jpeg_test_data.h b/test/i965_jpeg_test_data.h index 5f4802e..cde0cfe 100644 --- a/test/i965_jpeg_test_data.h +++ b/test/i965_jpeg_test_data.h @@ -421,6 +421,51 @@ namespace Encode { std::array<size_t, 3> offsets; std::array<size_t, 3> sizes; }; + + class TestInputCreator + { + public: + typedef std::shared_ptr<TestInputCreator> Shared; + typedef std::shared_ptr<const TestInputCreator> SharedConst; + + TestInput::Shared create(const unsigned) const; + + friend ::std::ostream& operator<<( + ::std::ostream&, const TestInputCreator&); + friend ::std::ostream& operator<<( + ::std::ostream&, const TestInputCreator::Shared&); + friend ::std::ostream& operator<<( + ::std::ostream&, const TestInputCreator::SharedConst&); + + protected: + virtual std::array<unsigned, 2> getResolution() const = 0; + virtual void repr(::std::ostream& os) const = 0; + }; + + class RandomSizeCreator + : public TestInputCreator + { + protected: + std::array<unsigned, 2> getResolution() const; + void repr(::std::ostream&) const; + }; + + class FixedSizeCreator + : public TestInputCreator + { + public: + FixedSizeCreator(const std::array<unsigned, 2>&); + + protected: + std::array<unsigned, 2> getResolution() const; + void repr(::std::ostream& os) const; + + private: + const std::array<unsigned, 2> res; + }; + + typedef std::vector<TestInputCreator::SharedConst> InputCreators; + } // namespace Encode } // namespace JPEG |