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

Unified Diff: gpu/command_buffer/service/program_cache_lru_helper_unittest.cc

Issue 10797055: gpu in-memory program cache implementation with a memory limit + lru eviction. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nit fixes Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/program_cache_lru_helper_unittest.cc
diff --git a/gpu/command_buffer/service/program_cache_lru_helper_unittest.cc b/gpu/command_buffer/service/program_cache_lru_helper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5aaa08881d7e003910d6c7096357ed5f6668611e
--- /dev/null
+++ b/gpu/command_buffer/service/program_cache_lru_helper_unittest.cc
@@ -0,0 +1,84 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/service/program_cache_lru_helper.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gpu {
+namespace gles2 {
+
+class ProgramCacheLruHelperTest : public testing::Test {
+ public:
+ ProgramCacheLruHelperTest() :
+ lru_helper_(new ProgramCacheLruHelper()) { }
+
+ protected:
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ lru_helper_->Clear();
+ }
+
+ scoped_ptr<ProgramCacheLruHelper> lru_helper_;
+};
+
+TEST_F(ProgramCacheLruHelperTest, ProgramCacheLruHelperEvictionOrderNoReuse) {
+ lru_helper_->KeyUsed("1");
+ lru_helper_->KeyUsed("2");
+ lru_helper_->KeyUsed("3");
+ lru_helper_->KeyUsed("4");
+ const std::string* key = lru_helper_->PeekKey();
+ EXPECT_EQ("1", *key);
+ EXPECT_EQ("1", *lru_helper_->PeekKey());
+ lru_helper_->PopKey();
+ EXPECT_FALSE(lru_helper_->IsEmpty());
+ EXPECT_EQ("2", *lru_helper_->PeekKey());
+ lru_helper_->PopKey();
+ EXPECT_FALSE(lru_helper_->IsEmpty());
+ EXPECT_EQ("3", *lru_helper_->PeekKey());
+ lru_helper_->PopKey();
+ EXPECT_FALSE(lru_helper_->IsEmpty());
+ EXPECT_EQ("4", *lru_helper_->PeekKey());
+ lru_helper_->PopKey();
+ EXPECT_TRUE(lru_helper_->IsEmpty());
+}
+
+TEST_F(ProgramCacheLruHelperTest, ProgramCacheLruHelperClear) {
+ EXPECT_TRUE(lru_helper_->IsEmpty());
+ lru_helper_->KeyUsed("1");
+ lru_helper_->KeyUsed("2");
+ lru_helper_->KeyUsed("3");
+ lru_helper_->KeyUsed("4");
+ EXPECT_FALSE(lru_helper_->IsEmpty());
+ lru_helper_->Clear();
+ EXPECT_TRUE(lru_helper_->IsEmpty());
+}
+
+TEST_F(ProgramCacheLruHelperTest, ProgramCacheLruHelperEvictionOrderWithReuse) {
+ lru_helper_->KeyUsed("1");
+ lru_helper_->KeyUsed("2");
+ lru_helper_->KeyUsed("4");
+ lru_helper_->KeyUsed("2");
+ lru_helper_->KeyUsed("3");
+ lru_helper_->KeyUsed("1");
+ lru_helper_->KeyUsed("1");
+ lru_helper_->KeyUsed("2");
+ EXPECT_EQ("4", *lru_helper_->PeekKey());
+ EXPECT_EQ("4", *lru_helper_->PeekKey());
+ lru_helper_->PopKey();
+ EXPECT_EQ("3", *lru_helper_->PeekKey());
+ lru_helper_->PopKey();
+ EXPECT_EQ("1", *lru_helper_->PeekKey());
+ lru_helper_->PopKey();
+ EXPECT_FALSE(lru_helper_->IsEmpty());
+ EXPECT_EQ("2", *lru_helper_->PeekKey());
+ lru_helper_->PopKey();
+ EXPECT_TRUE(lru_helper_->IsEmpty());
+}
+
+} // namespace gles2
+} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/program_cache_lru_helper.cc ('k') | gpu/command_buffer/service/program_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698