| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/child/indexed_db/indexed_db_dispatcher.h" | 5 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 blink::WebIDBCursorDirectionNext; | 151 blink::WebIDBCursorDirectionNext; |
| 152 const bool key_only = false; | 152 const bool key_only = false; |
| 153 | 153 |
| 154 MockDispatcher dispatcher(thread_safe_sender_.get()); | 154 MockDispatcher dispatcher(thread_safe_sender_.get()); |
| 155 | 155 |
| 156 // First case: successful cursor open. | 156 // First case: successful cursor open. |
| 157 { | 157 { |
| 158 std::unique_ptr<WebIDBCursor> cursor; | 158 std::unique_ptr<WebIDBCursor> cursor; |
| 159 EXPECT_EQ(0UL, dispatcher.cursor_transaction_ids_.size()); | 159 EXPECT_EQ(0UL, dispatcher.cursor_transaction_ids_.size()); |
| 160 | 160 |
| 161 auto callbacks = new StrictMock<MockWebIDBCallbacks>(); | 161 auto* callbacks = new StrictMock<MockWebIDBCallbacks>(); |
| 162 // Reference first param (cursor) to keep it alive. | 162 // Reference first param (cursor) to keep it alive. |
| 163 // TODO(cmumford): Cleanup (and below) once std::addressof() is allowed. | 163 // TODO(cmumford): Cleanup (and below) once std::addressof() is allowed. |
| 164 ON_CALL(*callbacks, onSuccess(testing::A<WebIDBCursor*>(), _, _, _)) | 164 ON_CALL(*callbacks, onSuccess(testing::A<WebIDBCursor*>(), _, _, _)) |
| 165 .WillByDefault( | 165 .WillByDefault( |
| 166 WithArgs<0>(Invoke(&cursor.operator=(nullptr), | 166 WithArgs<0>(Invoke(&cursor.operator=(nullptr), |
| 167 &std::unique_ptr<WebIDBCursor>::reset))); | 167 &std::unique_ptr<WebIDBCursor>::reset))); |
| 168 EXPECT_CALL(*callbacks, onSuccess(testing::A<WebIDBCursor*>(), _, _, _)) | 168 EXPECT_CALL(*callbacks, onSuccess(testing::A<WebIDBCursor*>(), _, _, _)) |
| 169 .Times(1); | 169 .Times(1); |
| 170 | 170 |
| 171 // Make a cursor request. This should record the transaction id. | 171 // Make a cursor request. This should record the transaction id. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 197 | 197 |
| 198 // This is the primary expectation of this test: the transaction id was | 198 // This is the primary expectation of this test: the transaction id was |
| 199 // applied to the cursor. | 199 // applied to the cursor. |
| 200 EXPECT_EQ(transaction_id, impl->transaction_id()); | 200 EXPECT_EQ(transaction_id, impl->transaction_id()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Second case: null cursor (no data in range) | 203 // Second case: null cursor (no data in range) |
| 204 { | 204 { |
| 205 EXPECT_EQ(0UL, dispatcher.cursor_transaction_ids_.size()); | 205 EXPECT_EQ(0UL, dispatcher.cursor_transaction_ids_.size()); |
| 206 | 206 |
| 207 auto callbacks = new StrictMock<MockWebIDBCallbacks>(); | 207 auto* callbacks = new StrictMock<MockWebIDBCallbacks>(); |
| 208 EXPECT_CALL(*callbacks, onSuccess(testing::A<const blink::WebIDBValue&>())) | 208 EXPECT_CALL(*callbacks, onSuccess(testing::A<const blink::WebIDBValue&>())) |
| 209 .Times(1); | 209 .Times(1); |
| 210 | 210 |
| 211 // Make a cursor request. This should record the transaction id. | 211 // Make a cursor request. This should record the transaction id. |
| 212 dispatcher.RequestIDBDatabaseOpenCursor( | 212 dispatcher.RequestIDBDatabaseOpenCursor( |
| 213 ipc_database_id, transaction_id, object_store_id, index_id, | 213 ipc_database_id, transaction_id, object_store_id, index_id, |
| 214 IndexedDBKeyRange(), direction, key_only, blink::WebIDBTaskTypeNormal, | 214 IndexedDBKeyRange(), direction, key_only, blink::WebIDBTaskTypeNormal, |
| 215 callbacks); | 215 callbacks); |
| 216 | 216 |
| 217 // Verify that the transaction id was captured. | 217 // Verify that the transaction id was captured. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 other_cursor_ipc_id, cursor1_transaction_id); | 313 other_cursor_ipc_id, cursor1_transaction_id); |
| 314 | 314 |
| 315 EXPECT_EQ(2, cursor1->reset_count()); | 315 EXPECT_EQ(2, cursor1->reset_count()); |
| 316 EXPECT_EQ(0, cursor2->reset_count()); | 316 EXPECT_EQ(0, cursor2->reset_count()); |
| 317 | 317 |
| 318 cursor1.reset(); | 318 cursor1.reset(); |
| 319 cursor2.reset(); | 319 cursor2.reset(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 } // namespace content | 322 } // namespace content |
| OLD | NEW |