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

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: Revert lock_ pattern change in IdHandler::FreeIds. 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 helper's 'flush generation' updates.
618 TEST_F(CommandBufferHelperTest, TestFlushGeneration) {
619 // Explicit flushing only.
620 helper_->SetAutomaticFlushes(false);
621
622 // Generation should change after Flush() but not before.
623 uint32 gen1, gen2, gen3;
624
625 gen1 = GetHelperFlushGeneration();
626 AddUniqueCommandWithExpect(error::kNoError, 2);
627 gen2 = GetHelperFlushGeneration();
628 helper_->Flush();
629 gen3 = GetHelperFlushGeneration();
630 EXPECT_EQ(gen2, gen1);
631 EXPECT_NE(gen3, gen2);
632
633 // Generation should change after FlushSync() but not before.
634 gen1 = GetHelperFlushGeneration();
635 AddUniqueCommandWithExpect(error::kNoError, 2);
636 gen2 = GetHelperFlushGeneration();
637 helper_->FlushSync();
638 gen3 = GetHelperFlushGeneration();
639 EXPECT_EQ(gen2, gen1);
640 EXPECT_NE(gen3, gen2);
641
642 // Generation should change after Finish() but not before.
643 gen1 = GetHelperFlushGeneration();
644 AddUniqueCommandWithExpect(error::kNoError, 2);
645 gen2 = GetHelperFlushGeneration();
646 helper_->Finish();
647 gen3 = GetHelperFlushGeneration();
648 EXPECT_EQ(gen2, gen1);
649 EXPECT_NE(gen3, gen2);
650
651 helper_->Finish();
652
653 // Check that the commands did happen.
654 Mock::VerifyAndClearExpectations(api_mock_.get());
655
656 // Check the error status.
657 EXPECT_EQ(error::kNoError, GetError());
658 }
659
615 } // namespace gpu 660 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.cc ('k') | gpu/command_buffer/client/gles2_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698