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 | |
Olli Etuaho | 77ae8d5 | 2016-05-06 14:19:01 +0300 | [diff] [blame^] | 18 | using ::testing::_; |
| 19 | |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 20 | namespace |
| 21 | { |
| 22 | |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 23 | class ResourceManagerTest : public testing::Test |
| 24 | { |
| 25 | protected: |
| 26 | void SetUp() override |
| 27 | { |
| 28 | mResourceManager = new ResourceManager(&mMockFactory); |
| 29 | } |
| 30 | |
| 31 | void TearDown() override |
| 32 | { |
| 33 | SafeDelete(mResourceManager); |
| 34 | } |
| 35 | |
Jamie Madill | 7aea7e0 | 2016-05-10 10:39:45 -0400 | [diff] [blame] | 36 | MockGLFactory mMockFactory; |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 37 | ResourceManager *mResourceManager; |
| 38 | }; |
| 39 | |
| 40 | TEST_F(ResourceManagerTest, ReallocateBoundTexture) |
| 41 | { |
Olli Etuaho | 77ae8d5 | 2016-05-06 14:19:01 +0300 | [diff] [blame^] | 42 | EXPECT_CALL(mMockFactory, createTexture(_)).Times(1).RetiresOnSaturation(); |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 43 | |
| 44 | mResourceManager->checkTextureAllocation(1, GL_TEXTURE_2D); |
| 45 | GLuint newTexture = mResourceManager->createTexture(); |
| 46 | EXPECT_NE(1u, newTexture); |
| 47 | } |
| 48 | |
| 49 | TEST_F(ResourceManagerTest, ReallocateBoundBuffer) |
| 50 | { |
| 51 | EXPECT_CALL(mMockFactory, createBuffer()).Times(1).RetiresOnSaturation(); |
| 52 | |
| 53 | mResourceManager->checkBufferAllocation(1); |
| 54 | GLuint newBuffer = mResourceManager->createBuffer(); |
| 55 | EXPECT_NE(1u, newBuffer); |
| 56 | } |
| 57 | |
| 58 | TEST_F(ResourceManagerTest, ReallocateBoundRenderbuffer) |
| 59 | { |
| 60 | EXPECT_CALL(mMockFactory, createRenderbuffer()).Times(1).RetiresOnSaturation(); |
| 61 | |
| 62 | mResourceManager->checkRenderbufferAllocation(1); |
| 63 | GLuint newRenderbuffer = mResourceManager->createRenderbuffer(); |
| 64 | EXPECT_NE(1u, newRenderbuffer); |
| 65 | } |
| 66 | |
| 67 | } |