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/webidbcursor_impl.h" | 5 #include "content/child/indexed_db/webidbcursor_impl.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> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/test/scoped_task_environment.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "content/child/indexed_db/indexed_db_key_builders.h" | 18 #include "content/child/indexed_db/indexed_db_key_builders.h" |
18 #include "content/child/indexed_db/mock_webidbcallbacks.h" | 19 #include "content/child/indexed_db/mock_webidbcallbacks.h" |
19 #include "content/child/thread_safe_sender.h" | 20 #include "content/child/thread_safe_sender.h" |
20 #include "content/common/indexed_db/indexed_db_key.h" | 21 #include "content/common/indexed_db/indexed_db_key.h" |
21 #include "mojo/public/cpp/bindings/associated_binding.h" | 22 #include "mojo/public/cpp/bindings/associated_binding.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "third_party/WebKit/public/platform/WebData.h" | 24 #include "third_party/WebKit/public/platform/WebData.h" |
24 | 25 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 WebIDBCursorImplTest() { | 122 WebIDBCursorImplTest() { |
122 null_key_.assignNull(); | 123 null_key_.assignNull(); |
123 indexed_db::mojom::CursorAssociatedPtr ptr; | 124 indexed_db::mojom::CursorAssociatedPtr ptr; |
124 mock_cursor_ = | 125 mock_cursor_ = |
125 base::MakeUnique<MockCursorImpl>(mojo::MakeIsolatedRequest(&ptr)); | 126 base::MakeUnique<MockCursorImpl>(mojo::MakeIsolatedRequest(&ptr)); |
126 cursor_ = base::MakeUnique<WebIDBCursorImpl>( | 127 cursor_ = base::MakeUnique<WebIDBCursorImpl>( |
127 ptr.PassInterface(), 1, base::ThreadTaskRunnerHandle::Get()); | 128 ptr.PassInterface(), 1, base::ThreadTaskRunnerHandle::Get()); |
128 } | 129 } |
129 | 130 |
130 protected: | 131 protected: |
131 base::MessageLoop message_loop_; | 132 base::test::ScopedTaskEnvironment scoped_task_environment_; |
132 WebIDBKey null_key_; | 133 WebIDBKey null_key_; |
133 std::unique_ptr<WebIDBCursorImpl> cursor_; | 134 std::unique_ptr<WebIDBCursorImpl> cursor_; |
134 std::unique_ptr<MockCursorImpl> mock_cursor_; | 135 std::unique_ptr<MockCursorImpl> mock_cursor_; |
135 | 136 |
136 private: | 137 private: |
137 DISALLOW_COPY_AND_ASSIGN(WebIDBCursorImplTest); | 138 DISALLOW_COPY_AND_ASSIGN(WebIDBCursorImplTest); |
138 }; | 139 }; |
139 | 140 |
140 TEST_F(WebIDBCursorImplTest, PrefetchTest) { | 141 TEST_F(WebIDBCursorImplTest, PrefetchTest) { |
141 // Call continue() until prefetching should kick in. | 142 // Call continue() until prefetching should kick in. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 base::RunLoop().RunUntilIdle(); | 323 base::RunLoop().RunUntilIdle(); |
323 EXPECT_EQ(1, mock_cursor_->reset_calls()); | 324 EXPECT_EQ(1, mock_cursor_->reset_calls()); |
324 EXPECT_EQ(1, mock_cursor_->last_used_count()); | 325 EXPECT_EQ(1, mock_cursor_->last_used_count()); |
325 | 326 |
326 cursor_.reset(); | 327 cursor_.reset(); |
327 base::RunLoop().RunUntilIdle(); | 328 base::RunLoop().RunUntilIdle(); |
328 EXPECT_TRUE(mock_cursor_->destroyed()); | 329 EXPECT_TRUE(mock_cursor_->destroyed()); |
329 } | 330 } |
330 | 331 |
331 } // namespace content | 332 } // namespace content |
OLD | NEW |