summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/buffer_manager_unittest.cc
blob: 2b121d8211250169a02d51f71d913a5fc9196b55 (plain)
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
// Copyright (c) 2010 The Chromium 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 "gpu/command_buffer/service/buffer_manager.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace gpu {
namespace gles2 {

class BufferManagerTest : public testing::Test {
 public:
  BufferManagerTest() {
  }

 protected:
  virtual void SetUp() {
  }

  virtual void TearDown() {
  }

  BufferManager manager_;
};

TEST_F(BufferManagerTest, Basic) {
  const GLuint kBuffer1Id = 1;
  const GLsizeiptr kBuffer1Size = 123;
  const GLuint kBuffer2Id = 2;
  // Check we can create buffer.
  manager_.CreateBufferInfo(kBuffer1Id);
  // Check buffer got created.
  BufferManager::BufferInfo* info1 = manager_.GetBufferInfo(kBuffer1Id);
  ASSERT_TRUE(info1 != NULL);
  // Check we and set its size.
  info1->set_size(kBuffer1Size);
  EXPECT_EQ(kBuffer1Size, info1->size());
  // Check we get nothing for a non-existent buffer.
  EXPECT_TRUE(manager_.GetBufferInfo(kBuffer2Id) == NULL);
  // Check trying to a remove non-existent buffers does not crash.
  manager_.RemoveBufferInfo(kBuffer2Id);
  // Check we can't get the buffer after we remove it.
  manager_.RemoveBufferInfo(kBuffer1Id);
  EXPECT_TRUE(manager_.GetBufferInfo(kBuffer1Id) == NULL);
}

// TODO(gman): Test GetMaxValueForRange.

}  // namespace gles2
}  // namespace gpu