Hash :
db8ae16b
Author :
Date :
2014-08-25T19:02:35
Refactored TransformFeedback for multi-platform ANGLE and added tests. Added angle_implementation_unit_tests target designed for testing the cross-platform code in libGLESv2, and libGLESv2_static target as a dependency. The goal is to incorporate these tests into Chromium's angle_unittests target on all platforms; however, more work is needed to make libGLESv2's common code compile on non-Windows platforms, so this is an intermediate step. BUG=angle:719 Change-Id: Ifc44a779352294e857d6e913d9b997a60674c443 Reviewed-on: https://chromium-review.googlesource.com/214105 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Kenneth Russell <kbr@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
//
// 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(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