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

Side by Side Diff: content/child/indexed_db/indexed_db_dispatcher_unittest.cc

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle the rest of Josh's feedback. Created 7 years 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
OLDNEW
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/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.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/thread_safe_sender.h" 9 #include "content/child/thread_safe_sender.h"
10 #include "content/common/indexed_db/indexed_db_key.h" 10 #include "content/common/indexed_db/indexed_db_key.h"
11 #include "ipc/ipc_sync_message_filter.h" 11 #include "ipc/ipc_sync_message_filter.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/WebKit/public/platform/WebBlobInfo.h"
13 #include "third_party/WebKit/public/platform/WebData.h" 14 #include "third_party/WebKit/public/platform/WebData.h"
14 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h" 15 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h"
15 16
17 using blink::WebBlobInfo;
16 using blink::WebData; 18 using blink::WebData;
17 using blink::WebIDBCallbacks; 19 using blink::WebIDBCallbacks;
18 using blink::WebIDBDatabase; 20 using blink::WebIDBDatabase;
19 using blink::WebIDBDatabaseError; 21 using blink::WebIDBDatabaseError;
20 using blink::WebIDBKey; 22 using blink::WebIDBKey;
21 using blink::WebVector; 23 using blink::WebVector;
22 24
23 namespace content { 25 namespace content {
24 namespace { 26 namespace {
25 27
26 class MockCallbacks : public WebIDBCallbacks { 28 class MockCallbacks : public WebIDBCallbacks {
27 public: 29 public:
28 MockCallbacks() : error_seen_(false) {} 30 MockCallbacks() : error_seen_(false) {}
29 31
30 virtual void onError(const WebIDBDatabaseError&) OVERRIDE { 32 virtual void onError(const WebIDBDatabaseError&) OVERRIDE {
31 error_seen_ = true; 33 error_seen_ = true;
32 } 34 }
33 35
34 bool error_seen() const { return error_seen_; } 36 bool error_seen() const { return error_seen_; }
35 37
36 private: 38 private:
37 bool error_seen_; 39 bool error_seen_;
38 }; 40 };
39 41
40 } // namespace 42 } // namespace
41 43
42 TEST(IndexedDBDispatcherTest, ValueSizeTest) { 44 TEST(IndexedDBDispatcherTest, ValueSizeTest) {
43 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1); 45 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1);
44 const WebData value(&data.front(), data.size()); 46 const WebData value(&data.front(), data.size());
47 const WebVector<WebBlobInfo> webBlobInfo;
45 const int32 ipc_dummy_id = -1; 48 const int32 ipc_dummy_id = -1;
46 const int64 transaction_id = 1; 49 const int64 transaction_id = 1;
47 const int64 object_store_id = 2; 50 const int64 object_store_id = 2;
48 51
49 scoped_refptr<base::MessageLoopProxy> message_loop_proxy( 52 scoped_refptr<base::MessageLoopProxy> message_loop_proxy(
50 base::MessageLoopProxy::current()); 53 base::MessageLoopProxy::current());
51 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter( 54 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter(
52 new IPC::SyncMessageFilter(NULL)); 55 new IPC::SyncMessageFilter(NULL));
53 scoped_refptr<ThreadSafeSender> thread_safe_sender(new ThreadSafeSender( 56 scoped_refptr<ThreadSafeSender> thread_safe_sender(new ThreadSafeSender(
54 message_loop_proxy.get(), sync_message_filter.get())); 57 message_loop_proxy.get(), sync_message_filter.get()));
55 58
56 MockCallbacks callbacks; 59 MockCallbacks callbacks;
57 IndexedDBDispatcher dispatcher(thread_safe_sender.get()); 60 IndexedDBDispatcher dispatcher(thread_safe_sender.get());
58 IndexedDBKey key(0, blink::WebIDBKeyTypeNumber); 61 IndexedDBKey key(0, blink::WebIDBKeyTypeNumber);
59 dispatcher.RequestIDBDatabasePut(ipc_dummy_id, 62 dispatcher.RequestIDBDatabasePut(ipc_dummy_id,
60 transaction_id, 63 transaction_id,
61 object_store_id, 64 object_store_id,
62 value, 65 value,
66 webBlobInfo,
63 key, 67 key,
64 WebIDBDatabase::AddOrUpdate, 68 WebIDBDatabase::AddOrUpdate,
65 &callbacks, 69 &callbacks,
66 WebVector<long long>(), 70 WebVector<long long>(),
67 WebVector<WebVector<WebIDBKey> >()); 71 WebVector<WebVector<WebIDBKey> >());
68 72
69 EXPECT_TRUE(callbacks.error_seen()); 73 EXPECT_TRUE(callbacks.error_seen());
70 } 74 }
71 75
72 } // namespace content 76 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698