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