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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/thread_task_runner_handle.h" | 6 #include "base/thread_task_runner_handle.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 8 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
9 #include "content/child/indexed_db/indexed_db_key_builders.h" | 9 #include "content/child/indexed_db/indexed_db_key_builders.h" |
10 #include "content/child/indexed_db/webidbcursor_impl.h" | 10 #include "content/child/indexed_db/webidbcursor_impl.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 *key_ = IndexedDBKeyBuilder::Build(key); | 108 *key_ = IndexedDBKeyBuilder::Build(key); |
109 if (web_blob_info_) | 109 if (web_blob_info_) |
110 *web_blob_info_ = webBlobInfo; | 110 *web_blob_info_ = webBlobInfo; |
111 } | 111 } |
112 | 112 |
113 private: | 113 private: |
114 IndexedDBKey* key_; | 114 IndexedDBKey* key_; |
115 WebVector<WebBlobInfo>* web_blob_info_; | 115 WebVector<WebBlobInfo>* web_blob_info_; |
116 }; | 116 }; |
117 | 117 |
| 118 class MockSyncMessageFilter : public IPC::SyncMessageFilter { |
| 119 public: |
| 120 MockSyncMessageFilter() |
| 121 : SyncMessageFilter(nullptr, false /* is_channel_send_thread_safe */) {} |
| 122 |
| 123 private: |
| 124 ~MockSyncMessageFilter() override {} |
| 125 }; |
| 126 |
118 } // namespace | 127 } // namespace |
119 | 128 |
120 class WebIDBCursorImplTest : public testing::Test { | 129 class WebIDBCursorImplTest : public testing::Test { |
121 public: | 130 public: |
122 WebIDBCursorImplTest() { | 131 WebIDBCursorImplTest() { |
123 null_key_.assignNull(); | 132 null_key_.assignNull(); |
124 sync_message_filter_ = new IPC::SyncMessageFilter(NULL); | |
125 thread_safe_sender_ = new ThreadSafeSender( | 133 thread_safe_sender_ = new ThreadSafeSender( |
126 base::ThreadTaskRunnerHandle::Get(), sync_message_filter_.get()); | 134 base::ThreadTaskRunnerHandle::Get(), new MockSyncMessageFilter); |
127 dispatcher_ = | 135 dispatcher_ = |
128 make_scoped_ptr(new MockDispatcher(thread_safe_sender_.get())); | 136 make_scoped_ptr(new MockDispatcher(thread_safe_sender_.get())); |
129 } | 137 } |
130 | 138 |
131 protected: | 139 protected: |
132 base::MessageLoop message_loop_; | 140 base::MessageLoop message_loop_; |
133 WebIDBKey null_key_; | 141 WebIDBKey null_key_; |
134 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 142 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
135 scoped_ptr<MockDispatcher> dispatcher_; | 143 scoped_ptr<MockDispatcher> dispatcher_; |
136 | 144 |
137 private: | 145 private: |
138 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; | |
139 | |
140 DISALLOW_COPY_AND_ASSIGN(WebIDBCursorImplTest); | 146 DISALLOW_COPY_AND_ASSIGN(WebIDBCursorImplTest); |
141 }; | 147 }; |
142 | 148 |
143 TEST_F(WebIDBCursorImplTest, PrefetchTest) { | 149 TEST_F(WebIDBCursorImplTest, PrefetchTest) { |
144 const int64 transaction_id = 1; | 150 const int64 transaction_id = 1; |
145 { | 151 { |
146 WebIDBCursorImpl cursor(WebIDBCursorImpl::kInvalidCursorId, | 152 WebIDBCursorImpl cursor(WebIDBCursorImpl::kInvalidCursorId, |
147 transaction_id, | 153 transaction_id, |
148 thread_safe_sender_.get()); | 154 thread_safe_sender_.get()); |
149 | 155 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // The real dispatcher would call cursor->CachedContinue(), so do that: | 328 // The real dispatcher would call cursor->CachedContinue(), so do that: |
323 scoped_ptr<WebIDBCallbacks> callbacks(new MockContinueCallbacks()); | 329 scoped_ptr<WebIDBCallbacks> callbacks(new MockContinueCallbacks()); |
324 cursor.CachedContinue(callbacks.get()); | 330 cursor.CachedContinue(callbacks.get()); |
325 | 331 |
326 // Now the cursor should have reset the rest of the cache. | 332 // Now the cursor should have reset the rest of the cache. |
327 EXPECT_EQ(1, dispatcher_->reset_calls()); | 333 EXPECT_EQ(1, dispatcher_->reset_calls()); |
328 EXPECT_EQ(1, dispatcher_->last_used_count()); | 334 EXPECT_EQ(1, dispatcher_->last_used_count()); |
329 } | 335 } |
330 | 336 |
331 } // namespace content | 337 } // namespace content |
OLD | NEW |