Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "gpu/command_buffer/service/program_cache_lru_helper.h" | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace gpu { | |
| 11 namespace gles2 { | |
| 12 | |
| 13 class ProgramCacheLruHelperTest : public testing::Test { | |
| 14 public: | |
| 15 ProgramCacheLruHelperTest() : | |
| 16 lru_helper_(new ProgramCacheLruHelper()) { } | |
| 17 | |
| 18 protected: | |
| 19 virtual void SetUp() { | |
| 20 } | |
| 21 | |
| 22 virtual void TearDown() { | |
| 23 lru_helper_->Clear(); | |
| 24 } | |
| 25 | |
| 26 scoped_ptr<ProgramCacheLruHelper> lru_helper_; | |
| 27 }; | |
| 28 | |
| 29 TEST_F(ProgramCacheLruHelperTest, ProgramCacheLruHelperEvictionOrderNoReuse) { | |
| 30 lru_helper_->KeyUsed("1"); | |
| 31 lru_helper_->KeyUsed("2"); | |
| 32 lru_helper_->KeyUsed("3"); | |
| 33 lru_helper_->KeyUsed("4"); | |
| 34 const std::string& key = lru_helper_->PeekKey(); | |
| 35 ASSERT_EQ("1", key); | |
|
greggman
2012/06/26 23:00:27
All these ASSERT_XX should be EXPECT_XX
ASSERT_XX
dmurph
2012/07/04 00:01:29
Done.
| |
| 36 ASSERT_EQ("1", lru_helper_->PeekKey()); | |
| 37 lru_helper_->PopKey(); | |
| 38 ASSERT_FALSE(lru_helper_->IsEmpty()); | |
| 39 ASSERT_EQ("2", lru_helper_->PeekKey()); | |
| 40 lru_helper_->PopKey(); | |
| 41 ASSERT_FALSE(lru_helper_->IsEmpty()); | |
| 42 ASSERT_EQ("3", lru_helper_->PeekKey()); | |
| 43 lru_helper_->PopKey(); | |
| 44 ASSERT_FALSE(lru_helper_->IsEmpty()); | |
| 45 ASSERT_EQ("4", lru_helper_->PeekKey()); | |
| 46 lru_helper_->PopKey(); | |
| 47 ASSERT_TRUE(lru_helper_->IsEmpty()); | |
| 48 } | |
| 49 | |
| 50 TEST_F(ProgramCacheLruHelperTest, ProgramCacheLruHelperClear) { | |
| 51 ASSERT_TRUE(lru_helper_->IsEmpty()); | |
| 52 lru_helper_->KeyUsed("1"); | |
| 53 lru_helper_->KeyUsed("2"); | |
| 54 lru_helper_->KeyUsed("3"); | |
| 55 lru_helper_->KeyUsed("4"); | |
| 56 ASSERT_FALSE(lru_helper_->IsEmpty()); | |
| 57 lru_helper_->Clear(); | |
| 58 ASSERT_TRUE(lru_helper_->IsEmpty()); | |
| 59 } | |
| 60 | |
| 61 TEST_F(ProgramCacheLruHelperTest, ProgramCacheLruHelperEvictionOrderWithReuse) { | |
| 62 lru_helper_->KeyUsed("1"); | |
| 63 lru_helper_->KeyUsed("2"); | |
| 64 lru_helper_->KeyUsed("4"); | |
| 65 lru_helper_->KeyUsed("2"); | |
| 66 lru_helper_->KeyUsed("3"); | |
| 67 lru_helper_->KeyUsed("1"); | |
| 68 lru_helper_->KeyUsed("1"); | |
| 69 lru_helper_->KeyUsed("2"); | |
| 70 ASSERT_EQ("4", lru_helper_->PeekKey()); | |
|
greggman
2012/06/26 23:00:27
same check twice?
dmurph
2012/07/04 00:01:29
Yeah, checking that it didn't pop
| |
| 71 ASSERT_EQ("4", lru_helper_->PeekKey()); | |
| 72 lru_helper_->PopKey(); | |
| 73 ASSERT_EQ("3", lru_helper_->PeekKey()); | |
| 74 lru_helper_->PopKey(); | |
| 75 ASSERT_EQ("1", lru_helper_->PeekKey()); | |
| 76 lru_helper_->PopKey(); | |
| 77 ASSERT_FALSE(lru_helper_->IsEmpty()); | |
| 78 ASSERT_EQ("2", lru_helper_->PeekKey()); | |
| 79 lru_helper_->PopKey(); | |
| 80 ASSERT_TRUE(lru_helper_->IsEmpty()); | |
| 81 } | |
| 82 | |
| 83 } // namespace gles2 | |
| 84 } // namespace gpu | |
| OLD | NEW |