Index: gpu/command_buffer/client/query_tracker_unittest.cc |
diff --git a/gpu/command_buffer/client/query_tracker_unittest.cc b/gpu/command_buffer/client/query_tracker_unittest.cc |
index 0820a994cd3632baed84dcbc0fc54674b0ebed47..cd2ccf63297b37e7e3e392ef9d255de14e6d3b4f 100644 |
--- a/gpu/command_buffer/client/query_tracker_unittest.cc |
+++ b/gpu/command_buffer/client/query_tracker_unittest.cc |
@@ -107,6 +107,8 @@ class QueryTrackerTest : public testing::Test { |
return query->info_.bucket; |
} |
+ uint32 GetFlushGeneration() { return helper_->flush_generation(); } |
+ |
scoped_ptr<CommandBuffer> command_buffer_; |
scoped_ptr<GLES2CmdHelper> helper_; |
scoped_ptr<MappedMemoryManager> mapped_memory_; |
@@ -164,6 +166,27 @@ TEST_F(QueryTrackerTest, Query) { |
EXPECT_FALSE(query->NeverUsed()); |
EXPECT_TRUE(query->Pending()); |
+ // Flush only once if no more flushes happened between a call to |
+ // EndQuery command and CheckResultsAvailable |
+ // Advance put_ so flush calls in CheckResultsAvailable go through |
+ // and updates flush_generation count |
+ helper_->Noop(1); |
+ // Set Query in pending state_ to simulate EndQuery command is called |
+ query->MarkAsPending(kToken); |
+ EXPECT_TRUE(query->Pending()); |
+ // Store FlushGeneration count after EndQuery is called |
+ uint32 gen1 = GetFlushGeneration(); |
+ EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
+ uint32 gen2 = GetFlushGeneration(); |
+ EXPECT_NE(gen1, gen2); |
+ // Repeated calls to CheckResultsAvailable should not flush unnecessarily |
+ EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
+ gen1 = GetFlushGeneration(); |
+ EXPECT_EQ(gen1, gen2); |
+ EXPECT_FALSE(query->CheckResultsAvailable(helper_.get())); |
+ gen1 = GetFlushGeneration(); |
+ EXPECT_EQ(gen1, gen2); |
+ |
// Simulate GPU process marking it as available. |
QuerySync* sync = GetSync(query); |
sync->process_count = query->submit_count(); |