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

Side by Side Diff: command_buffer/client/cross/id_allocator_test.cc

Issue 208037: Added command buffer unit tests to gyp.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 allocator->FreeID(id2); 75 allocator->FreeID(id2);
76 EXPECT_FALSE(allocator->InUse(id2)); 76 EXPECT_FALSE(allocator->InUse(id2));
77 } 77 }
78 78
79 // Checks that the resource IDs are allocated conservatively, and re-used after 79 // Checks that the resource IDs are allocated conservatively, and re-used after
80 // being freed. 80 // being freed.
81 TEST_F(IdAllocatorTest, TestAdvanced) { 81 TEST_F(IdAllocatorTest, TestAdvanced) {
82 IdAllocator *allocator = id_allocator(); 82 IdAllocator *allocator = id_allocator();
83 83
84 // Allocate a significant number of resources. 84 // Allocate a significant number of resources.
85 const int kNumResources = 100; 85 const unsigned int kNumResources = 100;
86 ResourceID ids[kNumResources]; 86 ResourceID ids[kNumResources];
87 for (int i = 0; i < kNumResources; ++i) { 87 for (int i = 0; i < kNumResources; ++i) {
88 ids[i] = allocator->AllocateID(); 88 ids[i] = allocator->AllocateID();
89 EXPECT_TRUE(allocator->InUse(ids[i])); 89 EXPECT_TRUE(allocator->InUse(ids[i]));
90 } 90 }
91 91
92 // Check that the allocation is conservative with resource IDs, that is that 92 // Check that the allocation is conservative with resource IDs, that is that
93 // the resource IDs don't go over kNumResources - so that the service doesn't 93 // the resource IDs don't go over kNumResources - so that the service doesn't
94 // have to allocate too many internal structures when the resources are used. 94 // have to allocate too many internal structures when the resources are used.
95 for (int i = 0; i < kNumResources; ++i) { 95 for (int i = 0; i < kNumResources; ++i) {
96 EXPECT_GT(kNumResources, ids[i]); 96 EXPECT_GT(kNumResources, ids[i]);
97 } 97 }
98 98
99 // Check that the next resources are still free. 99 // Check that the next resources are still free.
100 for (int i = 0; i < kNumResources; ++i) { 100 for (int i = 0; i < kNumResources; ++i) {
101 EXPECT_FALSE(allocator->InUse(kNumResources + i)); 101 EXPECT_FALSE(allocator->InUse(kNumResources + i));
102 } 102 }
103 103
104 // Check that a new allocation re-uses the resource we just freed. 104 // Check that a new allocation re-uses the resource we just freed.
105 ResourceID id1 = ids[kNumResources / 2]; 105 ResourceID id1 = ids[kNumResources / 2];
106 allocator->FreeID(id1); 106 allocator->FreeID(id1);
107 EXPECT_FALSE(allocator->InUse(id1)); 107 EXPECT_FALSE(allocator->InUse(id1));
108 ResourceID id2 = allocator->AllocateID(); 108 ResourceID id2 = allocator->AllocateID();
109 EXPECT_TRUE(allocator->InUse(id2)); 109 EXPECT_TRUE(allocator->InUse(id2));
110 EXPECT_EQ(id1, id2); 110 EXPECT_EQ(id1, id2);
111 } 111 }
112 112
113 } // namespace command_buffer 113 } // namespace command_buffer
114 } // namespace o3d 114 } // namespace o3d
OLDNEW
« no previous file with comments | « command_buffer/client/cross/cmd_buffer_helper_test.cc ('k') | command_buffer/command_buffer.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698