Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: content/common/indexed_db/proxy_webidbcursor_impl_unittest.cc

Issue 9691021: IndexedDB: Fix prefetching; cache was always being bypassed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests to verify prefetch cache is used Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/indexed_db/proxy_webidbcursor_impl.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
+}
+
« no previous file with comments | « content/common/indexed_db/proxy_webidbcursor_impl.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698