CCSolidColorLayerImplTest.cpp [plain text]
#include "config.h"
#include "cc/CCSolidColorLayerImpl.h"
#include "CCLayerTestCommon.h"
#include "MockCCQuadCuller.h"
#include "cc/CCSingleThreadProxy.h"
#include "cc/CCSolidColorDrawQuad.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using namespace WebCore;
using namespace CCLayerTestCommon;
namespace {
TEST(CCSolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap)
{
DebugScopedSetImplThread scopedImplThread;
MockCCQuadCuller quadCuller;
IntSize layerSize = IntSize(800, 600);
IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
layer->setVisibleLayerRect(visibleLayerRect);
layer->setBounds(layerSize);
OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState();
bool hadMissingTiles = false;
layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles);
verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleLayerRect);
}
TEST(CCSolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad)
{
DebugScopedSetImplThread scopedImplThread;
const Color testColor = 0xFFA55AFF;
MockCCQuadCuller quadCuller;
IntSize layerSize = IntSize(100, 100);
IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
layer->setVisibleLayerRect(visibleLayerRect);
layer->setBounds(layerSize);
layer->setBackgroundColor(testColor);
OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState();
bool hadMissingTiles = false;
layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles);
ASSERT_EQ(quadCuller.quadList().size(), 1U);
EXPECT_EQ(quadCuller.quadList()[0]->toSolidColorDrawQuad()->color(), testColor);
}
TEST(CCSolidColorLayerImplTest, verifyCorrectOpacityInQuad)
{
DebugScopedSetImplThread scopedImplThread;
const float opacity = 0.5f;
MockCCQuadCuller quadCuller;
IntSize layerSize = IntSize(100, 100);
IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
layer->setVisibleLayerRect(visibleLayerRect);
layer->setBounds(layerSize);
layer->setDrawOpacity(opacity);
OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState();
bool hadMissingTiles = false;
layer->appendQuads(quadCuller, sharedQuadState.get(), hadMissingTiles);
ASSERT_EQ(quadCuller.quadList().size(), 1U);
EXPECT_EQ(opacity, quadCuller.quadList()[0]->toSolidColorDrawQuad()->opacity());
}
}