Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: gpu/command_buffer/client/mapped_memory_unittest.cc

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/client/mapped_memory.cc ('k') | gpu/command_buffer/client/program_info_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/mapped_memory_unittest.cc
diff --git a/gpu/command_buffer/client/mapped_memory_unittest.cc b/gpu/command_buffer/client/mapped_memory_unittest.cc
index 15f5fbf6914fb4220e2c535c6f237665298b7b16..ac30abbf130a92e3f23ab5d359248038c0ac7758 100644
--- a/gpu/command_buffer/client/mapped_memory_unittest.cc
+++ b/gpu/command_buffer/client/mapped_memory_unittest.cc
@@ -4,6 +4,9 @@
#include "gpu/command_buffer/client/mapped_memory.h"
+#include <stddef.h>
+#include <stdint.h>
+
#include <list>
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
@@ -63,9 +66,7 @@ class MappedMemoryTestBase : public testing::Test {
helper_->Initialize(kBufferSize);
}
- int32 GetToken() {
- return command_buffer_->GetLastState().token;
- }
+ int32_t GetToken() { return command_buffer_->GetLastState().token; }
scoped_ptr<AsyncAPIMock> api_mock_;
scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_;
@@ -85,7 +86,7 @@ const unsigned int MappedMemoryTestBase::kBufferSize;
// and SetToken are properly forwarded to the engine.
class MemoryChunkTest : public MappedMemoryTestBase {
protected:
- static const int32 kShmId = 123;
+ static const int32_t kShmId = 123;
void SetUp() override {
MappedMemoryTestBase::SetUp();
scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory());
@@ -101,14 +102,14 @@ class MemoryChunkTest : public MappedMemoryTestBase {
MappedMemoryTestBase::TearDown();
}
- uint8* buffer_memory() { return static_cast<uint8*>(buffer_->memory()); }
+ uint8_t* buffer_memory() { return static_cast<uint8_t*>(buffer_->memory()); }
scoped_ptr<MemoryChunk> chunk_;
scoped_refptr<gpu::Buffer> buffer_;
};
#ifndef _MSC_VER
-const int32 MemoryChunkTest::kShmId;
+const int32_t MemoryChunkTest::kShmId;
#endif
TEST_F(MemoryChunkTest, Basic) {
@@ -119,9 +120,9 @@ TEST_F(MemoryChunkTest, Basic) {
EXPECT_EQ(kBufferSize, chunk_->GetSize());
void *pointer = chunk_->Alloc(kSize);
ASSERT_TRUE(pointer);
- EXPECT_LE(buffer_->memory(), static_cast<uint8*>(pointer));
+ EXPECT_LE(buffer_->memory(), static_cast<uint8_t*>(pointer));
EXPECT_GE(kBufferSize,
- static_cast<uint8*>(pointer) - buffer_memory() + kSize);
+ static_cast<uint8_t*>(pointer) - buffer_memory() + kSize);
EXPECT_EQ(kBufferSize - kSize, chunk_->GetLargestFreeSizeWithoutWaiting());
EXPECT_EQ(kBufferSize - kSize, chunk_->GetLargestFreeSizeWithWaiting());
EXPECT_EQ(kBufferSize, chunk_->GetSize());
@@ -130,7 +131,7 @@ TEST_F(MemoryChunkTest, Basic) {
EXPECT_EQ(kBufferSize, chunk_->GetLargestFreeSizeWithoutWaiting());
EXPECT_EQ(kBufferSize, chunk_->GetLargestFreeSizeWithWaiting());
- uint8 *pointer_char = static_cast<uint8*>(chunk_->Alloc(kSize));
+ uint8_t* pointer_char = static_cast<uint8_t*>(chunk_->Alloc(kSize));
ASSERT_TRUE(pointer_char);
EXPECT_LE(buffer_memory(), pointer_char);
EXPECT_GE(buffer_memory() + kBufferSize, pointer_char + kSize);
@@ -167,14 +168,14 @@ class MappedMemoryManagerTest : public MappedMemoryTestBase {
TEST_F(MappedMemoryManagerTest, Basic) {
const unsigned int kSize = 1024;
// Check we can alloc.
- int32 id1 = -1;
+ int32_t id1 = -1;
unsigned int offset1 = 0xFFFFFFFFU;
void* mem1 = manager_->Alloc(kSize, &id1, &offset1);
ASSERT_TRUE(mem1);
EXPECT_NE(-1, id1);
EXPECT_EQ(0u, offset1);
// Check if we free and realloc the same size we get the same memory
- int32 id2 = -1;
+ int32_t id2 = -1;
unsigned int offset2 = 0xFFFFFFFFU;
manager_->Free(mem1);
void* mem2 = manager_->Alloc(kSize, &id2, &offset2);
@@ -182,7 +183,7 @@ TEST_F(MappedMemoryManagerTest, Basic) {
EXPECT_EQ(id1, id2);
EXPECT_EQ(offset1, offset2);
// Check if we allocate again we get different shared memory
- int32 id3 = -1;
+ int32_t id3 = -1;
unsigned int offset3 = 0xFFFFFFFFU;
void* mem3 = manager_->Alloc(kSize, &id3, &offset3);
ASSERT_TRUE(mem3 != NULL);
@@ -191,8 +192,8 @@ TEST_F(MappedMemoryManagerTest, Basic) {
EXPECT_EQ(0u, offset3);
// Free 3 and allocate 2 half size blocks.
manager_->Free(mem3);
- int32 id4 = -1;
- int32 id5 = -1;
+ int32_t id4 = -1;
+ int32_t id5 = -1;
unsigned int offset4 = 0xFFFFFFFFU;
unsigned int offset5 = 0xFFFFFFFFU;
void* mem4 = manager_->Alloc(kSize / 2, &id4, &offset4);
@@ -216,7 +217,7 @@ TEST_F(MappedMemoryManagerTest, FreePendingToken) {
// Allocate several buffers across multiple chunks.
void *pointers[kAllocCount];
for (unsigned int i = 0; i < kAllocCount; ++i) {
- int32 id = -1;
+ int32_t id = -1;
unsigned int offset = 0xFFFFFFFFu;
pointers[i] = manager_->Alloc(kSize, &id, &offset);
EXPECT_TRUE(pointers[i]);
@@ -225,7 +226,7 @@ TEST_F(MappedMemoryManagerTest, FreePendingToken) {
}
// Free one successful allocation, pending fence.
- int32 token = helper_.get()->InsertToken();
+ int32_t token = helper_.get()->InsertToken();
manager_->FreePendingToken(pointers[0], token);
// The way we hooked up the helper and engine, it won't process commands
@@ -238,7 +239,7 @@ TEST_F(MappedMemoryManagerTest, FreePendingToken) {
EXPECT_LE(token, GetToken());
// This allocation should use the spot just freed above.
- int32 new_id = -1;
+ int32_t new_id = -1;
unsigned int new_offset = 0xFFFFFFFFu;
void* new_ptr = manager_->Alloc(kSize, &new_id, &new_offset);
EXPECT_TRUE(new_ptr);
@@ -254,7 +255,7 @@ TEST_F(MappedMemoryManagerTest, FreePendingToken) {
}
TEST_F(MappedMemoryManagerTest, FreeUnused) {
- int32 id = -1;
+ int32_t id = -1;
unsigned int offset = 0xFFFFFFFFU;
void* m1 = manager_->Alloc(kBufferSize, &id, &offset);
void* m2 = manager_->Alloc(kBufferSize, &id, &offset);
@@ -278,13 +279,13 @@ TEST_F(MappedMemoryManagerTest, ChunkSizeMultiple) {
manager_->set_chunk_size_multiple(kSize * 2);
// Check if we allocate less than the chunk size multiple we get
// chunks arounded up.
- int32 id1 = -1;
+ int32_t id1 = -1;
unsigned int offset1 = 0xFFFFFFFFU;
void* mem1 = manager_->Alloc(kSize, &id1, &offset1);
- int32 id2 = -1;
+ int32_t id2 = -1;
unsigned int offset2 = 0xFFFFFFFFU;
void* mem2 = manager_->Alloc(kSize, &id2, &offset2);
- int32 id3 = -1;
+ int32_t id3 = -1;
unsigned int offset3 = 0xFFFFFFFFU;
void* mem3 = manager_->Alloc(kSize, &id3, &offset3);
ASSERT_TRUE(mem1);
@@ -309,7 +310,7 @@ TEST_F(MappedMemoryManagerTest, UnusedMemoryLimit) {
manager_->set_chunk_size_multiple(kChunkSize);
// Allocate one chunk worth of memory.
- int32 id1 = -1;
+ int32_t id1 = -1;
unsigned int offset1 = 0xFFFFFFFFU;
void* mem1 = manager_->Alloc(kChunkSize, &id1, &offset1);
ASSERT_TRUE(mem1);
@@ -318,7 +319,7 @@ TEST_F(MappedMemoryManagerTest, UnusedMemoryLimit) {
// Allocate half a chunk worth of memory again.
// The same chunk will be used.
- int32 id2 = -1;
+ int32_t id2 = -1;
unsigned int offset2 = 0xFFFFFFFFU;
void* mem2 = manager_->Alloc(kChunkSize, &id2, &offset2);
ASSERT_TRUE(mem2);
@@ -341,7 +342,7 @@ TEST_F(MappedMemoryManagerTest, MemoryLimitWithReuse) {
manager_->set_chunk_size_multiple(kChunkSize);
// Allocate half a chunk worth of memory.
- int32 id1 = -1;
+ int32_t id1 = -1;
unsigned int offset1 = 0xFFFFFFFFU;
void* mem1 = manager_->Alloc(kSize, &id1, &offset1);
ASSERT_TRUE(mem1);
@@ -350,7 +351,7 @@ TEST_F(MappedMemoryManagerTest, MemoryLimitWithReuse) {
// Allocate half a chunk worth of memory again.
// The same chunk will be used.
- int32 id2 = -1;
+ int32_t id2 = -1;
unsigned int offset2 = 0xFFFFFFFFU;
void* mem2 = manager_->Alloc(kSize, &id2, &offset2);
ASSERT_TRUE(mem2);
@@ -358,7 +359,7 @@ TEST_F(MappedMemoryManagerTest, MemoryLimitWithReuse) {
EXPECT_EQ(kSize, offset2);
// Free one successful allocation, pending fence.
- int32 token = helper_.get()->InsertToken();
+ int32_t token = helper_.get()->InsertToken();
manager_->FreePendingToken(mem2, token);
// The way we hooked up the helper and engine, it won't process commands
@@ -370,7 +371,7 @@ TEST_F(MappedMemoryManagerTest, MemoryLimitWithReuse) {
// We won't be able to claim the free memory without waiting and
// as we've already met the memory limit we'll have to wait
// on the token.
- int32 id3 = -1;
+ int32_t id3 = -1;
unsigned int offset3 = 0xFFFFFFFFU;
void* mem3 = manager_->Alloc(kSize, &id3, &offset3);
ASSERT_TRUE(mem3);
@@ -394,14 +395,14 @@ TEST_F(MappedMemoryManagerTest, MaxAllocationTest) {
manager_->set_chunk_size_multiple(kLimit);
// Allocate twice the limit worth of memory (currently unbounded).
- int32 id1 = -1;
+ int32_t id1 = -1;
unsigned int offset1 = 0xFFFFFFFFU;
void* mem1 = manager_->Alloc(kLimit, &id1, &offset1);
ASSERT_TRUE(mem1);
EXPECT_NE(-1, id1);
EXPECT_EQ(0u, offset1);
- int32 id2 = -1;
+ int32_t id2 = -1;
unsigned int offset2 = 0xFFFFFFFFU;
void* mem2 = manager_->Alloc(kLimit, &id2, &offset2);
ASSERT_TRUE(mem2);
@@ -411,7 +412,7 @@ TEST_F(MappedMemoryManagerTest, MaxAllocationTest) {
manager_->set_max_allocated_bytes(kLimit);
// A new allocation should now fail.
- int32 id3 = -1;
+ int32_t id3 = -1;
unsigned int offset3 = 0xFFFFFFFFU;
void* mem3 = manager_->Alloc(kLimit, &id3, &offset3);
ASSERT_FALSE(mem3);
@@ -421,7 +422,7 @@ TEST_F(MappedMemoryManagerTest, MaxAllocationTest) {
manager_->Free(mem2);
// New allocation is over the limit but should reuse allocated space
- int32 id4 = -1;
+ int32_t id4 = -1;
unsigned int offset4 = 0xFFFFFFFFU;
void* mem4 = manager_->Alloc(kLimit, &id4, &offset4);
ASSERT_TRUE(mem4);
« no previous file with comments | « gpu/command_buffer/client/mapped_memory.cc ('k') | gpu/command_buffer/client/program_info_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698