Hash :
e0a2d1c5
Author :
Date :
2014-10-06T17:45:59
Add needed static_casts to GLenum for compilation on Linux. BUG=angleproject:773 Change-Id: I8b01a1f187456eb8997fc7a620b5ecdffb872c19 Reviewed-on: https://chromium-review.googlesource.com/221810 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@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(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