Chromium Code Reviews| Index: content/common/indexed_db/proxy_webidbcursor_impl_unittest.cc |
| diff --git a/content/common/indexed_db/proxy_webidbcursor_impl_unittest.cc b/content/common/indexed_db/proxy_webidbcursor_impl_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3d5ab5324cb8ee86f5e7a870e55c606158cbd94e |
| --- /dev/null |
| +++ b/content/common/indexed_db/proxy_webidbcursor_impl_unittest.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/common/indexed_db/proxy_webidbcursor_impl.h" |
| + |
| +#include "base/compiler_specific.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +class RendererWebIDBCursorImplTest : public testing::Test { |
| +}; |
| + |
| +class MockIDBCallbacks : public WebKit::WebIDBCallbacks { |
| +public: |
| + MockIDBCallbacks() : m_called(false) { } |
| + void reset() { m_called = false; } |
| + bool wasCalled() { return m_called; } |
| + virtual void onSuccessWithContinuation() OVERRIDE { m_called = true; }; |
| + private: |
| + bool m_called; |
| +}; |
| + |
| +TEST_F(RendererWebIDBCursorImplTest, PrefetchTest) { |
| + RendererWebIDBCursorImpl cursor(kInvalidIDBCursorId); |
|
michaeln
2012/03/13 18:39:48
I was wondering how the kInvalidIDBCursorId value
|
| + |
| + MockIDBCallbacks callbacks; |
| + |
| + std::vector<IndexedDBKey> keys; |
| + std::vector<IndexedDBKey> primary_keys; |
| + std::vector<content::SerializedScriptValue> values; |
| + for (int i = 0; i < 3; ++i) { |
| + IndexedDBKey key; |
| + IndexedDBKey primary_key; |
| + content::SerializedScriptValue value; |
| + key.SetNumber(i); |
| + primary_key.SetNumber(i); |
| + keys.push_back(key); |
| + primary_keys.push_back(primary_key); |
| + values.push_back(value); |
| + } |
| + |
| + cursor.SetPrefetchData(keys, primary_keys, values); |
| + |
| + for (int i = 0; i < 3; ++i) { |
| + callbacks.reset(); |
| + WebKit::WebIDBKey continueKey = WebKit::WebIDBKey::createNull(); |
| + WebKit::WebExceptionCode ec; |
| + cursor.continueFunction(continueKey, &callbacks, ec); |
| + EXPECT_TRUE(callbacks.wasCalled()); |
| + EXPECT_EQ(cursor.key().type(), WebKit::WebIDBKey::NumberType); |
| + EXPECT_EQ(cursor.key().number(), i); |
| + } |
| +} |
| + |