1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_INDEXEDDB_MOCK_IDB_DATABASE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_INDEXEDDB_MOCK_IDB_DATABASE_H_
#include <gmock/gmock.h>
#include <memory>
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h"
namespace blink {
class AbstrackMockIDBDatabase {
virtual void OnDisconnect() = 0;
};
class MockIDBDatabase : public testing::StrictMock<mojom::blink::IDBDatabase>,
public testing::StrictMock<AbstrackMockIDBDatabase> {
public:
MOCK_METHOD(void,
RenameObjectStore,
(int64_t transaction_id,
int64_t object_store_id,
const String& new_name),
(override));
MOCK_METHOD(
void,
CreateTransaction,
(mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction> receiver,
int64_t id,
const Vector<int64_t>& scope,
mojom::blink::IDBTransactionMode,
mojom::blink::IDBTransactionDurability),
(override));
MOCK_METHOD(void, VersionChangeIgnored, (), (override));
MOCK_METHOD(void, Abort, (int64_t transaction_id), (override));
MOCK_METHOD(void,
CreateIndex,
(int64_t transaction_id,
int64_t object_store_id,
const scoped_refptr<IDBIndexMetadata>& index_metadata),
(override));
MOCK_METHOD(void,
DeleteIndex,
(int64_t transaction_id,
int64_t object_store_id,
int64_t index_id),
(override));
MOCK_METHOD(void,
RenameIndex,
(int64_t transaction_id,
int64_t object_store_id,
int64_t index_id,
const String& new_name),
(override));
MOCK_METHOD(void,
Get,
(int64_t transaction_id,
int64_t object_store_id,
int64_t index_id,
mojom::blink::IDBKeyRangePtr,
bool key_only,
GetCallback),
(override));
MOCK_METHOD(void,
GetAll,
(int64_t transaction_id,
int64_t object_store_id,
int64_t index_id,
mojom::blink::IDBKeyRangePtr,
mojom::blink::IDBGetAllResultType result_type,
int64_t max_count,
mojom::blink::IDBCursorDirection direction,
GetAllCallback),
(override));
MOCK_METHOD(void,
SetIndexKeys,
(int64_t transaction_id,
int64_t object_store_id,
std::unique_ptr<IDBKey> primary_key,
Vector<IDBIndexKeys>),
(override));
MOCK_METHOD(void,
SetIndexesReady,
(int64_t transaction_id,
int64_t object_store_id,
const Vector<int64_t>& index_ids),
(override));
MOCK_METHOD(void,
OpenCursor,
(int64_t transaction_id,
int64_t object_store_id,
int64_t index_id,
mojom::blink::IDBKeyRangePtr,
mojom::blink::IDBCursorDirection,
bool key_only,
mojom::blink::IDBTaskType,
OpenCursorCallback),
(override));
MOCK_METHOD(void,
Count,
(int64_t transaction_id,
int64_t object_store_id,
int64_t index_id,
mojom::blink::IDBKeyRangePtr,
CountCallback),
(override));
MOCK_METHOD(void,
DeleteRange,
(int64_t transaction_id,
int64_t object_store_id,
mojom::blink::IDBKeyRangePtr,
DeleteRangeCallback),
(override));
MOCK_METHOD(void,
GetKeyGeneratorCurrentNumber,
(int64_t transaction_id,
int64_t object_store_id,
GetKeyGeneratorCurrentNumberCallback),
(override));
MOCK_METHOD(void,
Clear,
(int64_t transaction_id, int64_t object_store_id, ClearCallback),
(override));
MOCK_METHOD(void, DidBecomeInactive, (), (override));
MOCK_METHOD(void, UpdatePriority, (int new_priority), (override));
// AbstrackMockIDBDatabase::OnDisconnect()
MOCK_METHOD(void, OnDisconnect, (), (override));
void Bind(mojo::PendingAssociatedReceiver<mojom::blink::IDBDatabase>);
mojo::PendingAssociatedRemote<mojom::blink::IDBDatabase>
BindNewEndpointAndPassDedicatedRemote();
void Flush() { receiver_.FlushForTesting(); }
private:
mojo::AssociatedReceiver<mojom::blink::IDBDatabase> receiver_{this};
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_INDEXEDDB_MOCK_IDB_DATABASE_H_
|