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

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

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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
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 <stdint.h>
6
5 #include <set> 7 #include <set>
6 8
9 #include "base/macros.h"
7 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
8 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" 11 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h"
9 #include "content/browser/indexed_db/indexed_db_backing_store.h" 12 #include "content/browser/indexed_db/indexed_db_backing_store.h"
10 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h" 13 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h"
11 #include "content/browser/indexed_db/mock_indexed_db_factory.h" 14 #include "content/browser/indexed_db/mock_indexed_db_factory.h"
12 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
13 16
14 namespace content { 17 namespace content {
15 18
16 namespace { 19 namespace {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 ~RegistryTestMockFactory() override {} 51 ~RegistryTestMockFactory() override {}
49 52
50 std::set<GURL> origins_; 53 std::set<GURL> origins_;
51 bool duplicate_calls_; 54 bool duplicate_calls_;
52 55
53 DISALLOW_COPY_AND_ASSIGN(RegistryTestMockFactory); 56 DISALLOW_COPY_AND_ASSIGN(RegistryTestMockFactory);
54 }; 57 };
55 58
56 class MockIDBBackingStore : public IndexedDBFakeBackingStore { 59 class MockIDBBackingStore : public IndexedDBFakeBackingStore {
57 public: 60 public:
58 typedef std::pair<int64, int64> KeyPair; 61 typedef std::pair<int64_t, int64_t> KeyPair;
59 typedef std::set<KeyPair> KeyPairSet; 62 typedef std::set<KeyPair> KeyPairSet;
60 63
61 MockIDBBackingStore(IndexedDBFactory* factory, 64 MockIDBBackingStore(IndexedDBFactory* factory,
62 base::SequencedTaskRunner* task_runner) 65 base::SequencedTaskRunner* task_runner)
63 : IndexedDBFakeBackingStore(factory, task_runner), 66 : IndexedDBFakeBackingStore(factory, task_runner),
64 duplicate_calls_(false) {} 67 duplicate_calls_(false) {}
65 68
66 void ReportBlobUnused(int64 database_id, int64 blob_key) override { 69 void ReportBlobUnused(int64_t database_id, int64_t blob_key) override {
67 unused_blobs_.insert(std::make_pair(database_id, blob_key)); 70 unused_blobs_.insert(std::make_pair(database_id, blob_key));
68 } 71 }
69 72
70 bool CheckUnusedBlobsEmpty() const { 73 bool CheckUnusedBlobsEmpty() const {
71 return !duplicate_calls_ && !unused_blobs_.size(); 74 return !duplicate_calls_ && !unused_blobs_.size();
72 } 75 }
73 bool CheckSingleUnusedBlob(int64 database_id, int64 blob_key) const { 76 bool CheckSingleUnusedBlob(int64_t database_id, int64_t blob_key) const {
74 return !duplicate_calls_ && unused_blobs_.size() == 1 && 77 return !duplicate_calls_ && unused_blobs_.size() == 1 &&
75 unused_blobs_.count(std::make_pair(database_id, blob_key)); 78 unused_blobs_.count(std::make_pair(database_id, blob_key));
76 } 79 }
77 80
78 const KeyPairSet& unused_blobs() const { return unused_blobs_; } 81 const KeyPairSet& unused_blobs() const { return unused_blobs_; }
79 82
80 protected: 83 protected:
81 ~MockIDBBackingStore() override {} 84 ~MockIDBBackingStore() override {}
82 85
83 private: 86 private:
84 KeyPairSet unused_blobs_; 87 KeyPairSet unused_blobs_;
85 bool duplicate_calls_; 88 bool duplicate_calls_;
86 89
87 DISALLOW_COPY_AND_ASSIGN(MockIDBBackingStore); 90 DISALLOW_COPY_AND_ASSIGN(MockIDBBackingStore);
88 }; 91 };
89 92
90 // Base class for our test fixtures. 93 // Base class for our test fixtures.
91 class IndexedDBActiveBlobRegistryTest : public testing::Test { 94 class IndexedDBActiveBlobRegistryTest : public testing::Test {
92 public: 95 public:
93 typedef storage::ShareableFileReference::FinalReleaseCallback 96 typedef storage::ShareableFileReference::FinalReleaseCallback
94 ReleaseCallback; 97 ReleaseCallback;
95 98
96 static const int64 kDatabaseId0 = 7; 99 static const int64_t kDatabaseId0 = 7;
97 static const int64 kDatabaseId1 = 12; 100 static const int64_t kDatabaseId1 = 12;
98 static const int64 kBlobKey0 = 77; 101 static const int64_t kBlobKey0 = 77;
99 static const int64 kBlobKey1 = 14; 102 static const int64_t kBlobKey1 = 14;
100 103
101 IndexedDBActiveBlobRegistryTest() 104 IndexedDBActiveBlobRegistryTest()
102 : task_runner_(new base::TestSimpleTaskRunner), 105 : task_runner_(new base::TestSimpleTaskRunner),
103 factory_(new RegistryTestMockFactory), 106 factory_(new RegistryTestMockFactory),
104 backing_store_( 107 backing_store_(
105 new MockIDBBackingStore(factory_.get(), task_runner_.get())), 108 new MockIDBBackingStore(factory_.get(), task_runner_.get())),
106 registry_(new IndexedDBActiveBlobRegistry(backing_store_.get())) {} 109 registry_(new IndexedDBActiveBlobRegistry(backing_store_.get())) {}
107 110
108 void RunUntilIdle() { task_runner_->RunUntilIdle(); } 111 void RunUntilIdle() { task_runner_->RunUntilIdle(); }
109 RegistryTestMockFactory* factory() const { return factory_.get(); } 112 RegistryTestMockFactory* factory() const { return factory_.get(); }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 RunUntilIdle(); 271 RunUntilIdle();
269 272
270 // Nothing changes. 273 // Nothing changes.
271 EXPECT_TRUE(factory()->CheckSingleOriginInUse(backing_store()->origin_url())); 274 EXPECT_TRUE(factory()->CheckSingleOriginInUse(backing_store()->origin_url()));
272 EXPECT_TRUE(backing_store()->CheckUnusedBlobsEmpty()); 275 EXPECT_TRUE(backing_store()->CheckUnusedBlobsEmpty());
273 } 276 }
274 277
275 } // namespace 278 } // namespace
276 279
277 } // namespace content 280 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_active_blob_registry.cc ('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