Remove support for specifying version on command line.
[chromium-blink-merge.git] / content / test / image_decoder_test.h
blob5983e7aeddddf9651fbeed36e0233e9cfc7a7683
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_TEST_IMAGE_DECODER_TEST_H_
6 #define CONTENT_TEST_IMAGE_DECODER_TEST_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h"
15 #include "testing/gtest/include/gtest/gtest.h"
17 namespace blink { class WebImageDecoder; }
19 // If CALCULATE_MD5_SUMS is not defined, then this test decodes a handful of
20 // image files and compares their MD5 sums to the stored sums on disk.
22 // To recalculate the MD5 sums, uncommment CALCULATE_MD5_SUMS.
24 // The image files and corresponding MD5 sums live in the directory
25 // chrome/test/data/*_decoder (where "*" is the format being tested).
27 // Note: The MD5 sums calculated in this test by little- and big-endian systems
28 // will differ, since no endianness correction is done. If we start compiling
29 // for big endian machines this should be fixed.
31 // #define CALCULATE_MD5_SUMS
33 enum ImageDecoderTestFileSelection {
34 TEST_ALL,
35 TEST_SMALLER,
36 TEST_BIGGER,
39 // Returns the path the decoded data is saved at.
40 base::FilePath GetMD5SumPath(const base::FilePath& path);
42 class ImageDecoderTest : public testing::Test {
43 public:
44 explicit ImageDecoderTest(const std::string& format) : format_(format) { }
46 protected:
47 virtual void SetUp() OVERRIDE;
49 // Returns the vector of image files for testing.
50 std::vector<base::FilePath> GetImageFiles() const;
52 // Returns true if the image is bogus and should not be successfully decoded.
53 bool ShouldImageFail(const base::FilePath& path) const;
55 // Tests if decoder decodes image at image_path with underlying frame at
56 // index desired_frame_index. The md5_sum_path is needed if the test is not
57 // asked to generate one i.e. if # #define CALCULATE_MD5_SUMS is set.
58 void TestWebKitImageDecoder(const base::FilePath& image_path,
59 const base::FilePath& md5_sum_path, int desired_frame_index) const;
61 // Verifies each of the test image files is decoded correctly and matches the
62 // expected state. |file_selection| and |threshold| can be used to select
63 // files to test based on file size.
64 // If just the MD5 sum is wanted, this skips chunking.
65 void TestDecoding(ImageDecoderTestFileSelection file_selection,
66 const int64 threshold);
68 void TestDecoding() {
69 TestDecoding(TEST_ALL, 0);
72 // Creates WebKit API's decoder.
73 virtual blink::WebImageDecoder* CreateWebKitImageDecoder() const = 0;
75 // The format to be decoded, like "bmp" or "ico".
76 std::string format_;
78 protected:
79 // Path to the test files.
80 base::FilePath data_dir_;
82 private:
83 DISALLOW_COPY_AND_ASSIGN(ImageDecoderTest);
86 #endif // CONTENT_TEST_IMAGE_DECODER_TEST_H_