diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 18:52:52 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 18:52:52 +0000 |
commit | 94100156abc9d9a36470867075f0c3b2b6ea0578 (patch) | |
tree | 7ac863326136ee7bc89aa71ba85b165b42e11faf /webkit | |
parent | 496034c82857371cda3ce133e1bb6d409b37f44c (diff) | |
download | chromium_src-94100156abc9d9a36470867075f0c3b2b6ea0578.zip chromium_src-94100156abc9d9a36470867075f0c3b2b6ea0578.tar.gz chromium_src-94100156abc9d9a36470867075f0c3b2b6ea0578.tar.bz2 |
Split BMPImageDecoderTest.* tests into fast and slow tests. Enable fast tests under Valgrind.
BUG=9177
Review URL: http://codereview.chromium.org/113384
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16086 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
4 files changed, 72 insertions, 12 deletions
diff --git a/webkit/data/valgrind/test_shell_tests.gtest.txt b/webkit/data/valgrind/test_shell_tests.gtest.txt index 9d9e8a9..9c8fb22 100644 --- a/webkit/data/valgrind/test_shell_tests.gtest.txt +++ b/webkit/data/valgrind/test_shell_tests.gtest.txt @@ -1,2 +1,3 @@ # Way too slow under Valgrind at the moment; http://crbug.com/9177 -BMPImageDecoderTest.* +BMPImageDecoderTest.ChunkedDecodingSlow +BMPImageDecoderTest.DecodingSlow diff --git a/webkit/tools/test_shell/image_decoder_unittest.cc b/webkit/tools/test_shell/image_decoder_unittest.cc index f4c9b72..f946e48 100644 --- a/webkit/tools/test_shell/image_decoder_unittest.cc +++ b/webkit/tools/test_shell/image_decoder_unittest.cc @@ -6,7 +6,6 @@ #include "webkit/tools/test_shell/image_decoder_unittest.h" -#include "base/file_path.h" #include "base/file_util.h" #include "base/md5.h" #include "base/path_service.h" @@ -16,6 +15,23 @@ using base::Time; +namespace { + +// Determine if we should test with file specified by |path| based +// on |file_selection| and the |threshold| for the file size. +bool ShouldSkipFile(const std::wstring& path, + ImageDecoderTestFileSelection file_selection, + const int64 threshold) { + if (file_selection == TEST_ALL) + return false; + + int64 image_size = 0; + file_util::GetFileSize(path, &image_size); + return (file_selection == TEST_SMALLER) == (image_size > threshold); +} + +} // anonymous namespace + void ReadFileToVector(const std::wstring& path, Vector<char>* contents) { std::string contents_str; file_util::ReadFileToString(path, &contents_str); @@ -114,10 +130,15 @@ bool ImageDecoderTest::ShouldImageFail(const std::wstring& path) const { kBadSuffix.length(), kBadSuffix)); } -void ImageDecoderTest::TestDecoding() const { +void ImageDecoderTest::TestDecoding( + ImageDecoderTestFileSelection file_selection, + const int64 threshold) const { const std::vector<std::wstring> image_files(GetImageFiles()); for (std::vector<std::wstring>::const_iterator i(image_files.begin()); i != image_files.end(); ++i) { + if (ShouldSkipFile(*i, file_selection, threshold)) + continue; + Vector<char> image_contents; ReadFileToVector(*i, &image_contents); @@ -150,7 +171,9 @@ void ImageDecoderTest::TestDecoding() const { } #ifndef CALCULATE_MD5_SUMS -void ImageDecoderTest::TestChunkedDecoding() const { +void ImageDecoderTest::TestChunkedDecoding( + ImageDecoderTestFileSelection file_selection, + const int64 threshold) const { // Init random number generator with current day, so a failing case will fail // consistently over the course of a whole day. const Time today = Time::Now().LocalMidnight(); @@ -159,6 +182,9 @@ void ImageDecoderTest::TestChunkedDecoding() const { const std::vector<std::wstring> image_files(GetImageFiles()); for (std::vector<std::wstring>::const_iterator i(image_files.begin()); i != image_files.end(); ++i) { + if (ShouldSkipFile(*i, file_selection, threshold)) + continue; + if (ShouldImageFail(*i)) continue; diff --git a/webkit/tools/test_shell/image_decoder_unittest.h b/webkit/tools/test_shell/image_decoder_unittest.h index 52b72a6..33c99d1 100644 --- a/webkit/tools/test_shell/image_decoder_unittest.h +++ b/webkit/tools/test_shell/image_decoder_unittest.h @@ -29,6 +29,12 @@ //#define CALCULATE_MD5_SUMS +enum ImageDecoderTestFileSelection { + TEST_ALL, + TEST_SMALLER, + TEST_BIGGER, +}; + // Reads the contents of the specified file into the specified vector. void ReadFileToVector(const std::wstring& path, Vector<char>* contents); @@ -59,13 +65,26 @@ class ImageDecoderTest : public testing::Test { bool ShouldImageFail(const std::wstring& path) const; // Verifies each of the test image files is decoded correctly and matches the - // expected state. - void TestDecoding() const; + // expected state. |file_selection| and |threshold| can be used to select + // files to test based on file size. + void TestDecoding(ImageDecoderTestFileSelection file_selection, + const int64 threshold) const; + + void TestDecoding() const { + TestDecoding(TEST_ALL, 0); + } #ifndef CALCULATE_MD5_SUMS // Verifies that decoding still works correctly when the files are split into - // pieces at a random point. - void TestChunkedDecoding() const; + // pieces at a random point. |file_selection| and |threshold| can be used to + // select files to test based on file size. + void TestChunkedDecoding(ImageDecoderTestFileSelection file_selection, + const int64 threshold) const; + + void TestChunkedDecoding() const { + TestChunkedDecoding(TEST_ALL, 0); + } + #endif // Returns the correct type of image decoder for this test. diff --git a/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp b/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp index 4d8b55a..bc3c681 100644 --- a/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp +++ b/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp @@ -40,14 +40,28 @@ class BMPImageDecoderTest : public ImageDecoderTest { virtual WebCore::ImageDecoder* CreateDecoder() const { return new WebCore::BMPImageDecoder(); } + + // The BMPImageDecoderTest tests are really slow under Valgrind. + // Thus it is split into fast and slow versions. The threshold is + // set to 10KB because the fast test can finish under Valgrind in + // less than 30 seconds. + static const int64 kThresholdSize = 10240; }; -TEST_F(BMPImageDecoderTest, Decoding) { - TestDecoding(); +TEST_F(BMPImageDecoderTest, DecodingFast) { + TestDecoding(TEST_SMALLER, kThresholdSize); +} + +TEST_F(BMPImageDecoderTest, DecodingSlow) { + TestDecoding(TEST_BIGGER, kThresholdSize); } #ifndef CALCULATE_MD5_SUMS -TEST_F(BMPImageDecoderTest, ChunkedDecoding) { - TestChunkedDecoding(); +TEST_F(BMPImageDecoderTest, ChunkedDecodingFast) { + TestChunkedDecoding(TEST_SMALLER, kThresholdSize); +} + +TEST_F(BMPImageDecoderTest, ChunkedDecodingSlow) { + TestChunkedDecoding(TEST_BIGGER, kThresholdSize); } #endif |