Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2015 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // Unit tests for ResourceManager. |
| 7 | // |
| 8 | |
| 9 | #include <gmock/gmock.h> |
| 10 | #include <gtest/gtest.h> |
| 11 | |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 12 | #include "libANGLE/ResourceManager.h" |
Olli Etuaho | 82c47ad | 2016-04-20 18:28:47 +0300 | [diff] [blame^] | 13 | #include "tests/angle_unittests_utils.h" |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 14 | |
| 15 | using namespace rx; |
| 16 | using namespace gl; |
| 17 | |
| 18 | namespace |
| 19 | { |
| 20 | |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 21 | class ResourceManagerTest : public testing::Test |
| 22 | { |
| 23 | protected: |
| 24 | void SetUp() override |
| 25 | { |
| 26 | mResourceManager = new ResourceManager(&mMockFactory); |
| 27 | } |
| 28 | |
| 29 | void TearDown() override |
| 30 | { |
| 31 | SafeDelete(mResourceManager); |
| 32 | } |
| 33 | |
| 34 | MockFactory mMockFactory; |
| 35 | ResourceManager *mResourceManager; |
| 36 | }; |
| 37 | |
| 38 | TEST_F(ResourceManagerTest, ReallocateBoundTexture) |
| 39 | { |
| 40 | EXPECT_CALL(mMockFactory, createTexture(GL_TEXTURE_2D)).Times(1).RetiresOnSaturation(); |
| 41 | |
| 42 | mResourceManager->checkTextureAllocation(1, GL_TEXTURE_2D); |
| 43 | GLuint newTexture = mResourceManager->createTexture(); |
| 44 | EXPECT_NE(1u, newTexture); |
| 45 | } |
| 46 | |
| 47 | TEST_F(ResourceManagerTest, ReallocateBoundBuffer) |
| 48 | { |
| 49 | EXPECT_CALL(mMockFactory, createBuffer()).Times(1).RetiresOnSaturation(); |
| 50 | |
| 51 | mResourceManager->checkBufferAllocation(1); |
| 52 | GLuint newBuffer = mResourceManager->createBuffer(); |
| 53 | EXPECT_NE(1u, newBuffer); |
| 54 | } |
| 55 | |
| 56 | TEST_F(ResourceManagerTest, ReallocateBoundRenderbuffer) |
| 57 | { |
| 58 | EXPECT_CALL(mMockFactory, createRenderbuffer()).Times(1).RetiresOnSaturation(); |
| 59 | |
| 60 | mResourceManager->checkRenderbufferAllocation(1); |
| 61 | GLuint newRenderbuffer = mResourceManager->createRenderbuffer(); |
| 62 | EXPECT_NE(1u, newRenderbuffer); |
| 63 | } |
| 64 | |
| 65 | } |