| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Tests for the QueryTracker. | 5 // Tests for the QueryTracker. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/query_tracker.h" | 7 #include "gpu/command_buffer/client/query_tracker.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <memory> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "gpu/command_buffer/client/client_test_helper.h" | 16 #include "gpu/command_buffer/client/client_test_helper.h" |
| 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 18 #include "gpu/command_buffer/client/mapped_memory.h" | 18 #include "gpu/command_buffer/client/mapped_memory.h" |
| 19 #include "gpu/command_buffer/common/command_buffer.h" | 19 #include "gpu/command_buffer/common/command_buffer.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 22 |
| 23 namespace gpu { | 23 namespace gpu { |
| 24 namespace gles2 { | 24 namespace gles2 { |
| 25 | 25 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 38 sync_manager_.reset(new QuerySyncManager(mapped_memory_.get())); | 38 sync_manager_.reset(new QuerySyncManager(mapped_memory_.get())); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void TearDown() override { | 41 void TearDown() override { |
| 42 sync_manager_.reset(); | 42 sync_manager_.reset(); |
| 43 mapped_memory_.reset(); | 43 mapped_memory_.reset(); |
| 44 helper_.reset(); | 44 helper_.reset(); |
| 45 command_buffer_.reset(); | 45 command_buffer_.reset(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 scoped_ptr<CommandBuffer> command_buffer_; | 48 std::unique_ptr<CommandBuffer> command_buffer_; |
| 49 scoped_ptr<GLES2CmdHelper> helper_; | 49 std::unique_ptr<GLES2CmdHelper> helper_; |
| 50 scoped_ptr<MappedMemoryManager> mapped_memory_; | 50 std::unique_ptr<MappedMemoryManager> mapped_memory_; |
| 51 scoped_ptr<QuerySyncManager> sync_manager_; | 51 std::unique_ptr<QuerySyncManager> sync_manager_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 TEST_F(QuerySyncManagerTest, Basic) { | 54 TEST_F(QuerySyncManagerTest, Basic) { |
| 55 QuerySyncManager::QueryInfo infos[4]; | 55 QuerySyncManager::QueryInfo infos[4]; |
| 56 memset(&infos, 0xBD, sizeof(infos)); | 56 memset(&infos, 0xBD, sizeof(infos)); |
| 57 | 57 |
| 58 for (size_t ii = 0; ii < arraysize(infos); ++ii) { | 58 for (size_t ii = 0; ii < arraysize(infos); ++ii) { |
| 59 EXPECT_TRUE(sync_manager_->Alloc(&infos[ii])); | 59 EXPECT_TRUE(sync_manager_->Alloc(&infos[ii])); |
| 60 EXPECT_NE(0, infos[ii].shm_id); | 60 EXPECT_NE(0, infos[ii].shm_id); |
| 61 ASSERT_TRUE(infos[ii].sync != NULL); | 61 ASSERT_TRUE(infos[ii].sync != NULL); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 QuerySyncManager::Bucket* GetBucket(QueryTracker::Query* query) { | 106 QuerySyncManager::Bucket* GetBucket(QueryTracker::Query* query) { |
| 107 return query->info_.bucket; | 107 return query->info_.bucket; |
| 108 } | 108 } |
| 109 | 109 |
| 110 uint32_t GetBucketUsedCount(QuerySyncManager::Bucket* bucket) { | 110 uint32_t GetBucketUsedCount(QuerySyncManager::Bucket* bucket) { |
| 111 return bucket->in_use_queries.count(); | 111 return bucket->in_use_queries.count(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 uint32_t GetFlushGeneration() { return helper_->flush_generation(); } | 114 uint32_t GetFlushGeneration() { return helper_->flush_generation(); } |
| 115 | 115 |
| 116 scoped_ptr<CommandBuffer> command_buffer_; | 116 std::unique_ptr<CommandBuffer> command_buffer_; |
| 117 scoped_ptr<GLES2CmdHelper> helper_; | 117 std::unique_ptr<GLES2CmdHelper> helper_; |
| 118 scoped_ptr<MappedMemoryManager> mapped_memory_; | 118 std::unique_ptr<MappedMemoryManager> mapped_memory_; |
| 119 scoped_ptr<QueryTracker> query_tracker_; | 119 std::unique_ptr<QueryTracker> query_tracker_; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 TEST_F(QueryTrackerTest, Basic) { | 122 TEST_F(QueryTrackerTest, Basic) { |
| 123 const GLuint kId1 = 123; | 123 const GLuint kId1 = 123; |
| 124 const GLuint kId2 = 124; | 124 const GLuint kId2 = 124; |
| 125 | 125 |
| 126 // Check we can create a Query. | 126 // Check we can create a Query. |
| 127 QueryTracker::Query* query = query_tracker_->CreateQuery( | 127 QueryTracker::Query* query = query_tracker_->CreateQuery( |
| 128 kId1, GL_ANY_SAMPLES_PASSED_EXT); | 128 kId1, GL_ANY_SAMPLES_PASSED_EXT); |
| 129 ASSERT_TRUE(query != NULL); | 129 ASSERT_TRUE(query != NULL); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // Check FreeCompletedQueries. | 285 // Check FreeCompletedQueries. |
| 286 query_tracker_->FreeCompletedQueries(); | 286 query_tracker_->FreeCompletedQueries(); |
| 287 EXPECT_EQ(use_count_before_remove - 1, GetBucketUsedCount(bucket)); | 287 EXPECT_EQ(use_count_before_remove - 1, GetBucketUsedCount(bucket)); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 } // namespace gles2 | 291 } // namespace gles2 |
| 292 } // namespace gpu | 292 } // namespace gpu |
| 293 | 293 |
| 294 | 294 |
| OLD | NEW |