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