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

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper_test.cc

Issue 162023002: Reduce internal Flush() in GL resource glGen/Delete APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
OLDNEW
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 Command Buffer Helper. 5 // Tests for the Command Buffer Helper.
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 int32 GetPutOffset() { 222 int32 GetPutOffset() {
223 return command_buffer_->GetState().put_offset; 223 return command_buffer_->GetState().put_offset;
224 } 224 }
225 225
226 int32 GetHelperGetOffset() { return helper_->get_offset(); } 226 int32 GetHelperGetOffset() { return helper_->get_offset(); }
227 227
228 int32 GetHelperPutOffset() { return helper_->put_; } 228 int32 GetHelperPutOffset() { return helper_->put_; }
229 229
230 uint32 GetHelperFlushGeneration() { return helper_->flush_generation(); }
231
230 error::Error GetError() { 232 error::Error GetError() {
231 return command_buffer_->GetState().error; 233 return command_buffer_->GetState().error;
232 } 234 }
233 235
234 CommandBufferOffset get_helper_put() { return helper_->put_; } 236 CommandBufferOffset get_helper_put() { return helper_->put_; }
235 237
236 #if defined(OS_MACOSX) 238 #if defined(OS_MACOSX)
237 base::mac::ScopedNSAutoreleasePool autorelease_pool_; 239 base::mac::ScopedNSAutoreleasePool autorelease_pool_;
238 #endif 240 #endif
239 base::MessageLoop message_loop_; 241 base::MessageLoop message_loop_;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 EXPECT_EQ(ii, put_after - put_before); 607 EXPECT_EQ(ii, put_after - put_before);
606 } 608 }
607 } 609 }
608 610
609 TEST_F(CommandBufferHelperTest, IsContextLost) { 611 TEST_F(CommandBufferHelperTest, IsContextLost) {
610 EXPECT_FALSE(helper_->IsContextLost()); 612 EXPECT_FALSE(helper_->IsContextLost());
611 command_buffer_->SetParseError(error::kGenericError); 613 command_buffer_->SetParseError(error::kGenericError);
612 EXPECT_TRUE(helper_->IsContextLost()); 614 EXPECT_TRUE(helper_->IsContextLost());
613 } 615 }
614 616
617 // Checks immediate_entry_count_ calc when automatic flushing is enabled.
618 TEST_F(CommandBufferHelperTest, TestFlushGeneration) {
619 command_buffer_->LockFlush();
620
621 // Generation should change after Flush() but not before.
622 uint32 gen1, gen2, gen3;
623
624 gen1 = GetHelperFlushGeneration();
625 AddUniqueCommandWithExpect(error::kNoError, 2);
626 gen2 = GetHelperFlushGeneration();
627 helper_->Flush();
628 gen3 = GetHelperFlushGeneration();
629 EXPECT_EQ(gen2, gen1);
630 EXPECT_NE(gen3, gen2);
631
632 // Generation should change after FlushSync() but not before.
633 gen1 = GetHelperFlushGeneration();
634 AddUniqueCommandWithExpect(error::kNoError, 2);
635 gen2 = GetHelperFlushGeneration();
636 helper_->FlushSync();
637 gen3 = GetHelperFlushGeneration();
638 EXPECT_EQ(gen2, gen1);
639 EXPECT_NE(gen3, gen2);
640
641 // Generation should change after Finish() but not before.
642 gen1 = GetHelperFlushGeneration();
643 AddUniqueCommandWithExpect(error::kNoError, 2);
644 gen2 = GetHelperFlushGeneration();
645 helper_->Finish();
646 gen3 = GetHelperFlushGeneration();
647 EXPECT_EQ(gen2, gen1);
648 EXPECT_NE(gen3, gen2);
649
650 helper_->Finish();
651
652 // Check that the commands did happen.
653 Mock::VerifyAndClearExpectations(api_mock_.get());
654
655 // Check the error status.
656 EXPECT_EQ(error::kNoError, GetError());
657 }
658
615 } // namespace gpu 659 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698