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

Side by Side Diff: content/browser/indexed_db/indexed_db_active_blob_registry_unittest.cc

Issue 475063004: IndexedDB + Coding Style: re-order enums/typedefs/... to match guide (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased after r291485 Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <set> 5 #include <set>
6 6
7 #include "base/test/test_simple_task_runner.h" 7 #include "base/test/test_simple_task_runner.h"
8 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" 8 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h"
9 #include "content/browser/indexed_db/indexed_db_backing_store.h" 9 #include "content/browser/indexed_db/indexed_db_backing_store.h"
10 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h" 10 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 virtual ~RegistryTestMockFactory() {} 48 virtual ~RegistryTestMockFactory() {}
49 49
50 std::set<GURL> origins_; 50 std::set<GURL> origins_;
51 bool duplicate_calls_; 51 bool duplicate_calls_;
52 52
53 DISALLOW_COPY_AND_ASSIGN(RegistryTestMockFactory); 53 DISALLOW_COPY_AND_ASSIGN(RegistryTestMockFactory);
54 }; 54 };
55 55
56 class MockIDBBackingStore : public IndexedDBFakeBackingStore { 56 class MockIDBBackingStore : public IndexedDBFakeBackingStore {
57 public: 57 public:
58 typedef std::pair<int64, int64> KeyPair;
59 typedef std::set<KeyPair> KeyPairSet;
60
58 MockIDBBackingStore(IndexedDBFactory* factory, 61 MockIDBBackingStore(IndexedDBFactory* factory,
59 base::SequencedTaskRunner* task_runner) 62 base::SequencedTaskRunner* task_runner)
60 : IndexedDBFakeBackingStore(factory, task_runner), 63 : IndexedDBFakeBackingStore(factory, task_runner),
61 duplicate_calls_(false) {} 64 duplicate_calls_(false) {}
62 65
63 virtual void ReportBlobUnused(int64 database_id, int64 blob_key) OVERRIDE { 66 virtual void ReportBlobUnused(int64 database_id, int64 blob_key) OVERRIDE {
64 unused_blobs_.insert(std::make_pair(database_id, blob_key)); 67 unused_blobs_.insert(std::make_pair(database_id, blob_key));
65 } 68 }
66 69
67 typedef std::pair<int64, int64> KeyPair;
68 typedef std::set<KeyPair> KeyPairSet;
69 bool CheckUnusedBlobsEmpty() const { 70 bool CheckUnusedBlobsEmpty() const {
70 return !duplicate_calls_ && !unused_blobs_.size(); 71 return !duplicate_calls_ && !unused_blobs_.size();
71 } 72 }
72 bool CheckSingleUnusedBlob(int64 database_id, int64 blob_key) const { 73 bool CheckSingleUnusedBlob(int64 database_id, int64 blob_key) const {
73 return !duplicate_calls_ && unused_blobs_.size() == 1 && 74 return !duplicate_calls_ && unused_blobs_.size() == 1 &&
74 unused_blobs_.count(std::make_pair(database_id, blob_key)); 75 unused_blobs_.count(std::make_pair(database_id, blob_key));
75 } 76 }
76 77
77 const KeyPairSet& unused_blobs() const { return unused_blobs_; } 78 const KeyPairSet& unused_blobs() const { return unused_blobs_; }
78 79
79 protected: 80 protected:
80 virtual ~MockIDBBackingStore() {} 81 virtual ~MockIDBBackingStore() {}
81 82
82 private: 83 private:
83 KeyPairSet unused_blobs_; 84 KeyPairSet unused_blobs_;
84 bool duplicate_calls_; 85 bool duplicate_calls_;
85 86
86 DISALLOW_COPY_AND_ASSIGN(MockIDBBackingStore); 87 DISALLOW_COPY_AND_ASSIGN(MockIDBBackingStore);
87 }; 88 };
88 89
89 // Base class for our test fixtures. 90 // Base class for our test fixtures.
90 class IndexedDBActiveBlobRegistryTest : public testing::Test { 91 class IndexedDBActiveBlobRegistryTest : public testing::Test {
91 public: 92 public:
93 typedef storage::ShareableFileReference::FinalReleaseCallback
94 ReleaseCallback;
95
96 static const int64 kDatabaseId0 = 7;
97 static const int64 kDatabaseId1 = 12;
98 static const int64 kBlobKey0 = 77;
99 static const int64 kBlobKey1 = 14;
100
92 IndexedDBActiveBlobRegistryTest() 101 IndexedDBActiveBlobRegistryTest()
93 : task_runner_(new base::TestSimpleTaskRunner), 102 : task_runner_(new base::TestSimpleTaskRunner),
94 factory_(new RegistryTestMockFactory), 103 factory_(new RegistryTestMockFactory),
95 backing_store_(new MockIDBBackingStore(factory_, task_runner_)), 104 backing_store_(new MockIDBBackingStore(factory_, task_runner_)),
96 registry_(new IndexedDBActiveBlobRegistry(backing_store_.get())) {} 105 registry_(new IndexedDBActiveBlobRegistry(backing_store_.get())) {}
97 106
98 void RunUntilIdle() { task_runner_->RunUntilIdle(); } 107 void RunUntilIdle() { task_runner_->RunUntilIdle(); }
99 RegistryTestMockFactory* factory() const { return factory_.get(); } 108 RegistryTestMockFactory* factory() const { return factory_.get(); }
100 MockIDBBackingStore* backing_store() const { return backing_store_.get(); } 109 MockIDBBackingStore* backing_store() const { return backing_store_.get(); }
101 IndexedDBActiveBlobRegistry* registry() const { return registry_.get(); } 110 IndexedDBActiveBlobRegistry* registry() const { return registry_.get(); }
102 111
103 static const int64 kDatabaseId0 = 7;
104 static const int64 kDatabaseId1 = 12;
105 static const int64 kBlobKey0 = 77;
106 static const int64 kBlobKey1 = 14;
107
108 typedef storage::ShareableFileReference::FinalReleaseCallback ReleaseCallback;
109
110 private: 112 private:
111 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 113 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
112 scoped_refptr<RegistryTestMockFactory> factory_; 114 scoped_refptr<RegistryTestMockFactory> factory_;
113 scoped_refptr<MockIDBBackingStore> backing_store_; 115 scoped_refptr<MockIDBBackingStore> backing_store_;
114 scoped_ptr<IndexedDBActiveBlobRegistry> registry_; 116 scoped_ptr<IndexedDBActiveBlobRegistry> registry_;
115 117
116 DISALLOW_COPY_AND_ASSIGN(IndexedDBActiveBlobRegistryTest); 118 DISALLOW_COPY_AND_ASSIGN(IndexedDBActiveBlobRegistryTest);
117 }; 119 };
118 120
119 TEST_F(IndexedDBActiveBlobRegistryTest, DeleteUnused) { 121 TEST_F(IndexedDBActiveBlobRegistryTest, DeleteUnused) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 RunUntilIdle(); 267 RunUntilIdle();
266 268
267 // Nothing changes. 269 // Nothing changes.
268 EXPECT_TRUE(factory()->CheckSingleOriginInUse(backing_store()->origin_url())); 270 EXPECT_TRUE(factory()->CheckSingleOriginInUse(backing_store()->origin_url()));
269 EXPECT_TRUE(backing_store()->CheckUnusedBlobsEmpty()); 271 EXPECT_TRUE(backing_store()->CheckUnusedBlobsEmpty());
270 } 272 }
271 273
272 } // namespace 274 } // namespace
273 275
274 } // namespace content 276 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_active_blob_registry.h ('k') | content/browser/indexed_db/indexed_db_backing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698