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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/indexed_db/proxy_webidbcursor_impl.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/common/indexed_db/proxy_webidbcursor_impl.h"
6
7 #include "base/compiler_specific.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 class RendererWebIDBCursorImplTest : public testing::Test {
11 };
12
13 class MockIDBCallbacks : public WebKit::WebIDBCallbacks {
14 public:
15 MockIDBCallbacks() : m_called(false) { }
16 void reset() { m_called = false; }
17 bool wasCalled() { return m_called; }
18 virtual void onSuccessWithContinuation() OVERRIDE { m_called = true; };
19 private:
20 bool m_called;
21 };
22
23 TEST_F(RendererWebIDBCursorImplTest, PrefetchTest) {
24 RendererWebIDBCursorImpl cursor(kInvalidIDBCursorId);
michaeln 2012/03/13 18:39:48 I was wondering how the kInvalidIDBCursorId value
25
26 MockIDBCallbacks callbacks;
27
28 std::vector<IndexedDBKey> keys;
29 std::vector<IndexedDBKey> primary_keys;
30 std::vector<content::SerializedScriptValue> values;
31 for (int i = 0; i < 3; ++i) {
32 IndexedDBKey key;
33 IndexedDBKey primary_key;
34 content::SerializedScriptValue value;
35 key.SetNumber(i);
36 primary_key.SetNumber(i);
37 keys.push_back(key);
38 primary_keys.push_back(primary_key);
39 values.push_back(value);
40 }
41
42 cursor.SetPrefetchData(keys, primary_keys, values);
43
44 for (int i = 0; i < 3; ++i) {
45 callbacks.reset();
46 WebKit::WebIDBKey continueKey = WebKit::WebIDBKey::createNull();
47 WebKit::WebExceptionCode ec;
48 cursor.continueFunction(continueKey, &callbacks, ec);
49 EXPECT_TRUE(callbacks.wasCalled());
50 EXPECT_EQ(cursor.key().type(), WebKit::WebIDBKey::NumberType);
51 EXPECT_EQ(cursor.key().number(), i);
52 }
53 }
54
OLDNEW
« 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