mirror of
https://github.com/utmapp/angle.git
synced 2026-12-01 14:00:09 -10:00
BUG=angleproject:773 Change-Id: I8b01a1f187456eb8997fc7a620b5ecdffb872c19 Reviewed-on: https://chromium-review.googlesource.com/221810 Reviewed-by: Jamie Madill <[email protected]> Reviewed-by: Shannon Woods <[email protected]> Tested-by: Kenneth Russell <[email protected]>
95 lines
2.6 KiB
C++
95 lines
2.6 KiB
C++
//
|
|
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
//
|
|
|
|
#include "gmock/gmock.h"
|
|
#include "gtest/gtest.h"
|
|
#include "libGLESv2/TransformFeedback.h"
|
|
#include "libGLESv2/renderer/TransformFeedbackImpl.h"
|
|
|
|
namespace {
|
|
|
|
class MockTransformFeedbackImpl : public rx::TransformFeedbackImpl
|
|
{
|
|
public:
|
|
virtual ~MockTransformFeedbackImpl() { destroy(); }
|
|
|
|
MOCK_METHOD1(begin, void(GLenum primitiveMode));
|
|
MOCK_METHOD0(end, void());
|
|
MOCK_METHOD0(pause, void());
|
|
MOCK_METHOD0(resume, void());
|
|
|
|
MOCK_METHOD0(destroy, void());
|
|
};
|
|
|
|
class TransformFeedbackTest : public testing::Test
|
|
{
|
|
protected:
|
|
virtual void SetUp()
|
|
{
|
|
mImpl = new MockTransformFeedbackImpl;
|
|
EXPECT_CALL(*mImpl, destroy());
|
|
mFeedback = new gl::TransformFeedback(mImpl, 1);
|
|
mFeedback->addRef();
|
|
}
|
|
|
|
virtual void TearDown()
|
|
{
|
|
mFeedback->release();
|
|
}
|
|
|
|
MockTransformFeedbackImpl* mImpl;
|
|
gl::TransformFeedback* mFeedback;
|
|
};
|
|
|
|
TEST_F(TransformFeedbackTest, DestructionDeletesImpl)
|
|
{
|
|
MockTransformFeedbackImpl* impl = new MockTransformFeedbackImpl;
|
|
EXPECT_CALL(*impl, destroy()).Times(1).RetiresOnSaturation();
|
|
|
|
gl::TransformFeedback* feedback = new gl::TransformFeedback(impl, 1);
|
|
feedback->addRef();
|
|
feedback->release();
|
|
|
|
// Only needed because the mock is leaked if bugs are present,
|
|
// which logs an error, but does not cause the test to fail.
|
|
// Ordinarily mocks are verified when destroyed.
|
|
testing::Mock::VerifyAndClear(impl);
|
|
}
|
|
|
|
TEST_F(TransformFeedbackTest, SideEffectsOfStartAndStop)
|
|
{
|
|
testing::InSequence seq;
|
|
|
|
EXPECT_EQ(GL_FALSE, mFeedback->isStarted());
|
|
EXPECT_CALL(*mImpl, begin(GL_TRIANGLES));
|
|
mFeedback->start(GL_TRIANGLES);
|
|
EXPECT_EQ(GL_TRUE, mFeedback->isStarted());
|
|
EXPECT_EQ(static_cast<GLenum>(GL_TRIANGLES), mFeedback->getDrawMode());
|
|
EXPECT_CALL(*mImpl, end());
|
|
mFeedback->stop();
|
|
EXPECT_EQ(GL_FALSE, mFeedback->isStarted());
|
|
}
|
|
|
|
TEST_F(TransformFeedbackTest, SideEffectsOfPauseAndResume)
|
|
{
|
|
testing::InSequence seq;
|
|
|
|
EXPECT_FALSE(mFeedback->isStarted());
|
|
EXPECT_CALL(*mImpl, begin(GL_TRIANGLES));
|
|
mFeedback->start(GL_TRIANGLES);
|
|
EXPECT_EQ(GL_FALSE, mFeedback->isPaused());
|
|
EXPECT_CALL(*mImpl, pause());
|
|
mFeedback->pause();
|
|
EXPECT_EQ(GL_TRUE, mFeedback->isPaused());
|
|
EXPECT_CALL(*mImpl, resume());
|
|
mFeedback->resume();
|
|
EXPECT_EQ(GL_FALSE, mFeedback->isPaused());
|
|
EXPECT_CALL(*mImpl, end());
|
|
mFeedback->stop();
|
|
}
|
|
|
|
} // namespace
|