• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 #include "libANGLE/ResourceManager.h"
13 #include "tests/angle_unittests_utils.h"
14 
15 using namespace rx;
16 using namespace gl;
17 
18 using ::testing::_;
19 
20 namespace
21 {
22 
23 class ResourceManagerTest : public testing::Test
24 {
25   protected:
SetUp()26     void SetUp() override
27     {
28         mTextureManager      = new TextureManager();
29         mBufferManager       = new BufferManager();
30         mRenderbuffermanager = new RenderbufferManager();
31     }
32 
TearDown()33     void TearDown() override
34     {
35         mTextureManager->release(nullptr);
36         mBufferManager->release(nullptr);
37         mRenderbuffermanager->release(nullptr);
38     }
39 
40     MockGLFactory mMockFactory;
41     TextureManager *mTextureManager;
42     BufferManager *mBufferManager;
43     RenderbufferManager *mRenderbuffermanager;
44 };
45 
TEST_F(ResourceManagerTest,ReallocateBoundTexture)46 TEST_F(ResourceManagerTest, ReallocateBoundTexture)
47 {
48     EXPECT_CALL(mMockFactory, createTexture(_)).Times(1).RetiresOnSaturation();
49 
50     mTextureManager->checkTextureAllocation(&mMockFactory, {1}, TextureType::_2D);
51     TextureID newTexture = mTextureManager->createTexture();
52     EXPECT_NE(1u, newTexture.value);
53 }
54 
TEST_F(ResourceManagerTest,ReallocateBoundBuffer)55 TEST_F(ResourceManagerTest, ReallocateBoundBuffer)
56 {
57     EXPECT_CALL(mMockFactory, createBuffer(_)).Times(1).RetiresOnSaturation();
58 
59     mBufferManager->checkBufferAllocation(&mMockFactory, {1});
60     BufferID newBuffer = mBufferManager->createBuffer();
61     EXPECT_NE(1u, newBuffer.value);
62 }
63 
TEST_F(ResourceManagerTest,ReallocateBoundRenderbuffer)64 TEST_F(ResourceManagerTest, ReallocateBoundRenderbuffer)
65 {
66     EXPECT_CALL(mMockFactory, createRenderbuffer(_)).Times(1).RetiresOnSaturation();
67 
68     mRenderbuffermanager->checkRenderbufferAllocation(&mMockFactory, {1});
69     RenderbufferID newRenderbuffer = mRenderbuffermanager->createRenderbuffer();
70     EXPECT_NE(1u, newRenderbuffer.value);
71 }
72 
73 }  // anonymous namespace
74