Index: net/disk_cache/backend_unittest.cc |
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc |
index 1dbdd56df102ef214386fe9a16c783434ceb9fa6..c3998e0461b8dfd7f51c329942346654dbc1e7bc 100644 |
--- a/net/disk_cache/backend_unittest.cc |
+++ b/net/disk_cache/backend_unittest.cc |
@@ -4,6 +4,7 @@ |
#include "base/basictypes.h" |
#include "base/file_util.h" |
+#include "base/metrics/field_trial.h" |
#include "base/port.h" |
#include "base/string_util.h" |
#include "base/stringprintf.h" |
@@ -32,6 +33,8 @@ |
using base::Time; |
+namespace { |
+ |
// Tests that can run with different types of caches. |
class DiskCacheBackendTest : public DiskCacheTestWithCache { |
protected: |
@@ -1677,6 +1680,72 @@ TEST_F(DiskCacheTest, WrongVersion) { |
delete cache; |
} |
+class BadEntropyProvider : public base::FieldTrial::EntropyProvider { |
+ public: |
+ virtual ~BadEntropyProvider() {} |
+ |
+ virtual double GetEntropyForTrial(const std::string& trial_name, |
+ uint32 randomization_seed) const OVERRIDE { |
+ return 0.5; |
+ } |
+}; |
+ |
+TEST_F(DiskCacheTest, SimpleCacheControlJoin) { |
+ ASSERT_TRUE(CopyTestCache("insert_empty1")); |
+ |
+ base::FieldTrialList field_trial_list(new BadEntropyProvider()); |
+ base::FieldTrialList::FactoryGetFieldTrial("SimpleCacheTrial", 100, |
+ "Control", 2013, 12, 31, NULL); |
+ |
+ base::Thread cache_thread("CacheThread"); |
+ ASSERT_TRUE(cache_thread.StartWithOptions( |
+ base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
+ net::TestCompletionCallback cb; |
+ |
+ disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( |
+ cache_path_, cache_thread.message_loop_proxy(), NULL); |
+ int rv = cache->Init(cb.callback()); |
+ ASSERT_EQ(net::ERR_FAILED, cb.GetResult(rv)); |
+ |
+ delete cache; |
+} |
+ |
+TEST_F(DiskCacheTest, SimpleCacheControlRestart) { |
+ ASSERT_TRUE(CopyTestCache("simple_cache_control")); |
+ |
+ base::FieldTrialList field_trial_list(new BadEntropyProvider()); |
+ base::FieldTrialList::FactoryGetFieldTrial("SimpleCacheTrial", 100, |
+ "Control", 2013, 12, 31, NULL); |
+ |
+ base::Thread cache_thread("CacheThread"); |
+ ASSERT_TRUE(cache_thread.StartWithOptions( |
+ base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
+ net::TestCompletionCallback cb; |
+ |
+ disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( |
+ cache_path_, cache_thread.message_loop_proxy(), NULL); |
+ int rv = cache->Init(cb.callback()); |
+ ASSERT_EQ(net::OK, cb.GetResult(rv)); |
+ |
+ delete cache; |
+} |
+ |
+TEST_F(DiskCacheTest, SimpleCacheControlLeave) { |
+ ASSERT_TRUE(CopyTestCache("simple_cache_control")); |
pasko-google - do not use
2013/04/19 18:00:30
coud we create this file programmatically here? bi
gavinp
2013/04/20 07:17:32
Mooted, as Ricardo has asked for the removal of th
|
+ |
+ base::Thread cache_thread("CacheThread"); |
+ ASSERT_TRUE(cache_thread.StartWithOptions( |
+ base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
+ net::TestCompletionCallback cb; |
+ |
+ disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( |
+ cache_path_, cache_thread.message_loop_proxy(), NULL); |
+ int rv = cache->Init(cb.callback()); |
+ ASSERT_EQ(net::OK, cb.GetResult(rv)); |
+ |
+ delete cache; |
+} |
+ |
rvargas (doing something else)
2013/04/19 17:40:55
I would actually prefer not adding these tests. I
gavinp
2013/04/20 07:17:32
Done.
|
// Tests that the cache is properly restarted on recovery error. |
TEST_F(DiskCacheBackendTest, DeleteOld) { |
ASSERT_TRUE(CopyTestCache("wrong_version")); |
@@ -2797,6 +2866,8 @@ TEST_F(DiskCacheBackendTest, ShaderCacheUpdateRankForExternalCacheHit) { |
entry->Close(); |
} |
+} // namespace |
rvargas (doing something else)
2013/04/19 17:40:55
I don't understand why you're placing half of the
gavinp
2013/04/20 07:17:32
Moot, now that I"m not adding tests.
|
+ |
void DiskCacheBackendTest::TracingBackendBasics() { |
InitCache(); |
cache_ = new disk_cache::TracingCacheBackend(cache_); |