| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_INDEXED_DB_MOCK_INDEXED_DB_FACTORY_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_MOCK_INDEXED_DB_FACTORY_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_MOCK_INDEXED_DB_FACTORY_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_MOCK_INDEXED_DB_FACTORY_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "content/browser/indexed_db/indexed_db_factory.h" | 14 #include "content/browser/indexed_db/indexed_db_factory.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 class MockIndexedDBFactory : public IndexedDBFactory { | 19 class MockIndexedDBFactory : public IndexedDBFactory { |
| 19 public: | 20 public: |
| 20 MockIndexedDBFactory(); | 21 MockIndexedDBFactory(); |
| 21 MOCK_METHOD2(ReleaseDatabase, | 22 MOCK_METHOD2(ReleaseDatabase, |
| 22 void(const IndexedDBDatabase::Identifier& identifier, | 23 void(const IndexedDBDatabase::Identifier& identifier, |
| 23 bool forced_close)); | 24 bool forced_close)); |
| 24 MOCK_METHOD4(GetDatabaseNames, | 25 MOCK_METHOD4( |
| 25 void(scoped_refptr<IndexedDBCallbacks> callbacks, | 26 GetDatabaseNames, |
| 26 const url::Origin& origin, | 27 void(scoped_refptr<IndexedDBCallbacks> callbacks, |
| 27 const base::FilePath& data_directory, | 28 const url::Origin& origin, |
| 28 net::URLRequestContext* request_context)); | 29 const base::FilePath& data_directory, |
| 29 MOCK_METHOD5(OpenProxy, | 30 scoped_refptr<net::URLRequestContextGetter> request_context_getter)); |
| 30 void(const base::string16& name, | 31 MOCK_METHOD5( |
| 31 IndexedDBPendingConnection* connection, | 32 OpenProxy, |
| 32 net::URLRequestContext* request_context, | 33 void(const base::string16& name, |
| 33 const url::Origin& origin, | 34 IndexedDBPendingConnection* connection, |
| 34 const base::FilePath& data_directory)); | 35 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 36 const url::Origin& origin, |
| 37 const base::FilePath& data_directory)); |
| 35 // Googlemock can't deal with move-only types, so *Proxy() is a workaround. | 38 // Googlemock can't deal with move-only types, so *Proxy() is a workaround. |
| 36 virtual void Open(const base::string16& name, | 39 virtual void Open( |
| 37 std::unique_ptr<IndexedDBPendingConnection> connection, | 40 const base::string16& name, |
| 38 net::URLRequestContext* request_context, | 41 std::unique_ptr<IndexedDBPendingConnection> connection, |
| 39 const url::Origin& origin, | 42 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 40 const base::FilePath& data_directory) { | 43 const url::Origin& origin, |
| 41 OpenProxy(name, connection.get(), request_context, origin, data_directory); | 44 const base::FilePath& data_directory) { |
| 45 OpenProxy(name, connection.get(), request_context_getter, origin, |
| 46 data_directory); |
| 42 } | 47 } |
| 43 MOCK_METHOD5(DeleteDatabase, | 48 MOCK_METHOD5( |
| 44 void(const base::string16& name, | 49 DeleteDatabase, |
| 45 net::URLRequestContext* request_context, | 50 void(const base::string16& name, |
| 46 scoped_refptr<IndexedDBCallbacks> callbacks, | 51 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 47 const url::Origin& origin, | 52 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 48 const base::FilePath& data_directory)); | 53 const url::Origin& origin, |
| 54 const base::FilePath& data_directory)); |
| 49 MOCK_METHOD1(HandleBackingStoreFailure, void(const url::Origin& origin)); | 55 MOCK_METHOD1(HandleBackingStoreFailure, void(const url::Origin& origin)); |
| 50 MOCK_METHOD2(HandleBackingStoreCorruption, | 56 MOCK_METHOD2(HandleBackingStoreCorruption, |
| 51 void(const url::Origin& origin, | 57 void(const url::Origin& origin, |
| 52 const IndexedDBDatabaseError& error)); | 58 const IndexedDBDatabaseError& error)); |
| 53 // The Android NDK implements a subset of STL, and the gtest templates can't | 59 // The Android NDK implements a subset of STL, and the gtest templates can't |
| 54 // deal with std::pair's. This means we can't use GoogleMock for this method | 60 // deal with std::pair's. This means we can't use GoogleMock for this method |
| 55 OriginDBs GetOpenDatabasesForOrigin(const url::Origin& origin) const override; | 61 OriginDBs GetOpenDatabasesForOrigin(const url::Origin& origin) const override; |
| 56 MOCK_METHOD1(ForceClose, void(const url::Origin& origin)); | 62 MOCK_METHOD1(ForceClose, void(const url::Origin& origin)); |
| 57 MOCK_METHOD0(ContextDestroyed, void()); | 63 MOCK_METHOD0(ContextDestroyed, void()); |
| 58 MOCK_METHOD1(DatabaseDeleted, | 64 MOCK_METHOD1(DatabaseDeleted, |
| 59 void(const IndexedDBDatabase::Identifier& identifier)); | 65 void(const IndexedDBDatabase::Identifier& identifier)); |
| 60 MOCK_CONST_METHOD1(GetConnectionCount, size_t(const url::Origin& origin)); | 66 MOCK_CONST_METHOD1(GetConnectionCount, size_t(const url::Origin& origin)); |
| 61 | 67 |
| 62 MOCK_METHOD2(ReportOutstandingBlobs, | 68 MOCK_METHOD2(ReportOutstandingBlobs, |
| 63 void(const url::Origin& origin, bool blobs_outstanding)); | 69 void(const url::Origin& origin, bool blobs_outstanding)); |
| 64 | 70 |
| 65 protected: | 71 protected: |
| 66 virtual ~MockIndexedDBFactory(); | 72 virtual ~MockIndexedDBFactory(); |
| 67 | 73 |
| 68 MOCK_METHOD6(OpenBackingStore, | 74 MOCK_METHOD6( |
| 69 scoped_refptr<IndexedDBBackingStore>( | 75 OpenBackingStore, |
| 70 const url::Origin& origin, | 76 scoped_refptr<IndexedDBBackingStore>( |
| 71 const base::FilePath& data_directory, | 77 const url::Origin& origin, |
| 72 net::URLRequestContext* request_context, | 78 const base::FilePath& data_directory, |
| 73 IndexedDBDataLossInfo* data_loss_info, | 79 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 74 bool* disk_full, | 80 IndexedDBDataLossInfo* data_loss_info, |
| 75 leveldb::Status* s)); | 81 bool* disk_full, |
| 82 leveldb::Status* s)); |
| 76 | 83 |
| 77 MOCK_METHOD7(OpenBackingStoreHelper, | 84 MOCK_METHOD7( |
| 78 scoped_refptr<IndexedDBBackingStore>( | 85 OpenBackingStoreHelper, |
| 79 const url::Origin& origin, | 86 scoped_refptr<IndexedDBBackingStore>( |
| 80 const base::FilePath& data_directory, | 87 const url::Origin& origin, |
| 81 net::URLRequestContext* request_context, | 88 const base::FilePath& data_directory, |
| 82 IndexedDBDataLossInfo* data_loss_info, | 89 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 83 bool* disk_full, | 90 IndexedDBDataLossInfo* data_loss_info, |
| 84 bool first_time, | 91 bool* disk_full, |
| 85 leveldb::Status* s)); | 92 bool first_time, |
| 93 leveldb::Status* s)); |
| 86 | 94 |
| 87 private: | 95 private: |
| 88 DISALLOW_COPY_AND_ASSIGN(MockIndexedDBFactory); | 96 DISALLOW_COPY_AND_ASSIGN(MockIndexedDBFactory); |
| 89 }; | 97 }; |
| 90 | 98 |
| 91 } // namespace content | 99 } // namespace content |
| 92 | 100 |
| 93 #endif // CONTENT_BROWSER_INDEXED_DB_MOCK_INDEXED_DB_FACTORY_H_ | 101 #endif // CONTENT_BROWSER_INDEXED_DB_MOCK_INDEXED_DB_FACTORY_H_ |
| OLD | NEW |