mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1286168 - Add a RAII class to initialize ImageLib services in GTests. r=njn
This commit is contained in:
parent
d6df5b5f4a
commit
a92a8b9e06
@ -15,6 +15,7 @@
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "Decoder.h"
|
||||
#include "gfxColor.h"
|
||||
#include "imgITools.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "SurfacePipe.h"
|
||||
#include "SurfacePipeFactory.h"
|
||||
@ -99,6 +100,23 @@ struct BGRAColor
|
||||
// General Helpers
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* A RAII class that ensure that ImageLib services are available. Any tests that
|
||||
* require ImageLib to be initialized (for example, any test that uses the
|
||||
* SurfaceCache; see image::EnsureModuleInitialized() for the full list) can
|
||||
* use this class to ensure that ImageLib services are available. Failure to do
|
||||
* so can result in strange, non-deterministic failures.
|
||||
*/
|
||||
struct AutoInitializeImageLib
|
||||
{
|
||||
AutoInitializeImageLib()
|
||||
{
|
||||
// Ensure that ImageLib services are initialized.
|
||||
nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
EXPECT_TRUE(imgTools != nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
/// Loads a file from the current directory. @return an nsIInputStream for it.
|
||||
already_AddRefed<nsIInputStream> LoadFile(const char* aRelativePath);
|
||||
|
||||
|
@ -87,13 +87,8 @@ RunDecodeToSurface(const ImageTestCase& aTestCase)
|
||||
|
||||
class ImageDecodeToSurface : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
// Ensure that ImageLib services are initialized.
|
||||
nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
EXPECT_TRUE(imgTools != nullptr);
|
||||
}
|
||||
protected:
|
||||
AutoInitializeImageLib mInit;
|
||||
};
|
||||
|
||||
TEST_F(ImageDecodeToSurface, PNG) { RunDecodeToSurface(GreenPNGTestCase()); }
|
||||
|
@ -206,13 +206,8 @@ CheckDownscaleDuringDecode(const ImageTestCase& aTestCase)
|
||||
|
||||
class ImageDecoders : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
// Ensure that ImageLib services are initialized.
|
||||
nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
EXPECT_TRUE(imgTools != nullptr);
|
||||
}
|
||||
protected:
|
||||
AutoInitializeImageLib mInit;
|
||||
};
|
||||
|
||||
TEST_F(ImageDecoders, PNGSingleChunk)
|
||||
|
@ -61,13 +61,8 @@ AssertConfiguringDeinterlacingFilterFails(const IntSize& aSize)
|
||||
|
||||
class ImageDeinterlacingFilter : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
// Ensure that ImageLib services are initialized.
|
||||
nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
EXPECT_TRUE(imgTools != nullptr);
|
||||
}
|
||||
protected:
|
||||
AutoInitializeImageLib mInit;
|
||||
};
|
||||
|
||||
TEST_F(ImageDeinterlacingFilter, WritePixels100_100)
|
||||
|
@ -135,13 +135,8 @@ CheckMetadata(const ImageTestCase& aTestCase,
|
||||
|
||||
class ImageDecoderMetadata : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
// Ensure that ImageLib services are initialized.
|
||||
nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
EXPECT_TRUE(imgTools != nullptr);
|
||||
}
|
||||
protected:
|
||||
AutoInitializeImageLib mInit;
|
||||
};
|
||||
|
||||
TEST_F(ImageDecoderMetadata, PNG) { CheckMetadata(GreenPNGTestCase()); }
|
||||
|
@ -131,13 +131,8 @@ CheckPalettedSurfacePipeMethodResults(SurfacePipe* aPipe,
|
||||
|
||||
class ImageSurfacePipeIntegration : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
// Ensure that ImageLib services are initialized.
|
||||
nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
EXPECT_TRUE(imgTools != nullptr);
|
||||
}
|
||||
protected:
|
||||
AutoInitializeImageLib mInit;
|
||||
};
|
||||
|
||||
TEST_F(ImageSurfacePipeIntegration, SurfacePipe)
|
||||
|
Loading…
Reference in New Issue
Block a user