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

Unified Diff: net/disk_cache/flash/log_store_unittest.cc

Issue 182093002: Remove the flash specific disk cache backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/flash/log_store_entry_unittest.cc ('k') | net/disk_cache/flash/segment.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/flash/log_store_unittest.cc
diff --git a/net/disk_cache/flash/log_store_unittest.cc b/net/disk_cache/flash/log_store_unittest.cc
deleted file mode 100644
index 2678316d499ee3c27001dead7a494baa2ed1930a..0000000000000000000000000000000000000000
--- a/net/disk_cache/flash/log_store_unittest.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-// 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 "net/disk_cache/flash/flash_cache_test_base.h"
-#include "net/disk_cache/flash/format.h"
-#include "net/disk_cache/flash/log_store.h"
-#include "net/disk_cache/flash/segment.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace disk_cache {
-
-TEST_F(FlashCacheTest, LogStoreCreateEntry) {
- LogStore log_store(path_, kStorageSize);
- EXPECT_TRUE(log_store.Init());
-
- const int32 kSize = 100;
- const std::string buf(kSize, 0);
-
- int32 id;
- EXPECT_TRUE(log_store.CreateEntry(kSize, &id));
- EXPECT_TRUE(log_store.WriteData(buf.data(), kSize/2));
- EXPECT_TRUE(log_store.WriteData(buf.data(), kSize/2));
- log_store.CloseEntry(id);
-
- EXPECT_TRUE(log_store.Close());
-}
-
-// Also tests reading from current segment.
-TEST_F(FlashCacheTest, LogStoreOpenEntry) {
- LogStore log_store(path_, kStorageSize);
- EXPECT_TRUE(log_store.Init());
-
- const int32 kSize = 100;
- const std::vector<char> expected(kSize, 'b');
-
- int32 id;
- EXPECT_TRUE(log_store.CreateEntry(kSize, &id));
- EXPECT_TRUE(log_store.WriteData(&expected[0], kSize));
- log_store.CloseEntry(id);
-
- EXPECT_TRUE(log_store.OpenEntry(id));
- std::vector<char> actual(kSize, 0);
- EXPECT_TRUE(log_store.ReadData(id, &actual[0], kSize, 0));
- log_store.CloseEntry(id);
-
- EXPECT_EQ(expected, actual);
- EXPECT_TRUE(log_store.Close());
-}
-
-// Also tests that writing advances segments.
-TEST_F(FlashCacheTest, LogStoreReadFromClosedSegment) {
- LogStore log_store(path_, kStorageSize);
- EXPECT_TRUE(log_store.Init());
-
- const int32 kSize = disk_cache::kFlashSegmentFreeSpace;
- const std::vector<char> expected(kSize, 'a');
-
- // First two entries go to segment 0.
- int32 id1;
- EXPECT_EQ(0, log_store.write_index_);
- EXPECT_TRUE(log_store.CreateEntry(kSize/2, &id1));
- EXPECT_TRUE(log_store.WriteData(&expected[0], kSize/2));
- log_store.CloseEntry(id1);
-
- int32 id2;
- EXPECT_EQ(0, log_store.write_index_);
- EXPECT_TRUE(log_store.CreateEntry(kSize/2, &id2));
- EXPECT_TRUE(log_store.WriteData(&expected[0], kSize/2));
- log_store.CloseEntry(id2);
-
- // This entry goes to segment 1.
- int32 id3;
- EXPECT_TRUE(log_store.CreateEntry(kSize, &id3));
- EXPECT_EQ(1, log_store.write_index_);
- EXPECT_TRUE(log_store.WriteData(&expected[0], kSize));
- log_store.CloseEntry(id3);
-
- // We read from segment 0.
- EXPECT_TRUE(log_store.OpenEntry(id1));
- std::vector<char> actual(kSize, 0);
- EXPECT_TRUE(log_store.ReadData(id1, &actual[0], kSize, id1));
- log_store.CloseEntry(id1);
-
- EXPECT_EQ(expected, actual);
- EXPECT_TRUE(log_store.Close());
-}
-
-TEST_F(FlashCacheTest, LogStoreReadFromCurrentAfterClose) {
- LogStore log_store(path_, kStorageSize);
- EXPECT_TRUE(log_store.Init());
-
- const int32 kSize = disk_cache::kFlashSegmentFreeSpace;
- const std::vector<char> expected(kSize, 'a');
-
- int32 id1;
- EXPECT_EQ(0, log_store.write_index_);
- EXPECT_TRUE(log_store.CreateEntry(kSize/2, &id1));
- EXPECT_TRUE(log_store.WriteData(&expected[0], kSize/2));
- log_store.CloseEntry(id1);
-
- // Create a reference to above entry.
- EXPECT_TRUE(log_store.OpenEntry(id1));
-
- // This entry fills the first segment.
- int32 id2;
- EXPECT_EQ(0, log_store.write_index_);
- EXPECT_TRUE(log_store.CreateEntry(kSize/2, &id2));
- EXPECT_TRUE(log_store.WriteData(&expected[0], kSize/2));
- log_store.CloseEntry(id2);
-
- // Creating this entry forces closing of the first segment.
- int32 id3;
- EXPECT_TRUE(log_store.CreateEntry(kSize, &id3));
- EXPECT_EQ(1, log_store.write_index_);
- EXPECT_TRUE(log_store.WriteData(&expected[0], kSize));
- log_store.CloseEntry(id3);
-
- // Now attempt to read from the closed segment.
- std::vector<char> actual(kSize, 0);
- EXPECT_TRUE(log_store.ReadData(id1, &actual[0], kSize, id1));
- log_store.CloseEntry(id1);
-
- EXPECT_EQ(expected, actual);
- EXPECT_TRUE(log_store.Close());
-}
-
-// TODO(agayev): Add a test that confirms that in-use segment is not selected as
-// the next write segment.
-
-} // namespace disk_cache
« no previous file with comments | « net/disk_cache/flash/log_store_entry_unittest.cc ('k') | net/disk_cache/flash/segment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698