OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file has the unit tests for the IdAllocator class. | 5 // This file has the unit tests for the IdAllocator class. |
6 | 6 |
7 #include "gpu/command_buffer/client/id_allocator.h" | 7 #include "gpu/command_buffer/client/id_allocator.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace gpu { | 10 namespace gpu { |
11 | 11 |
12 using gpu::ResourceId; | |
13 | |
14 class IdAllocatorTest : public testing::Test { | 12 class IdAllocatorTest : public testing::Test { |
15 protected: | 13 protected: |
16 virtual void SetUp() {} | 14 virtual void SetUp() {} |
17 virtual void TearDown() {} | 15 virtual void TearDown() {} |
18 | 16 |
19 IdAllocator* id_allocator() { return &id_allocator_; } | 17 IdAllocator* id_allocator() { return &id_allocator_; } |
20 | 18 |
21 private: | 19 private: |
22 IdAllocator id_allocator_; | 20 IdAllocator id_allocator_; |
23 }; | 21 }; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Check that a new allocation re-uses the resource we just freed. | 73 // Check that a new allocation re-uses the resource we just freed. |
76 ResourceId id1 = ids[kNumResources / 2]; | 74 ResourceId id1 = ids[kNumResources / 2]; |
77 allocator->FreeID(id1); | 75 allocator->FreeID(id1); |
78 EXPECT_FALSE(allocator->InUse(id1)); | 76 EXPECT_FALSE(allocator->InUse(id1)); |
79 ResourceId id2 = allocator->AllocateID(); | 77 ResourceId id2 = allocator->AllocateID(); |
80 EXPECT_TRUE(allocator->InUse(id2)); | 78 EXPECT_TRUE(allocator->InUse(id2)); |
81 EXPECT_EQ(id1, id2); | 79 EXPECT_EQ(id1, id2); |
82 } | 80 } |
83 | 81 |
84 } // namespace gpu | 82 } // namespace gpu |
OLD | NEW |