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
3 // found in the LICENSE file.
5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/values.h"
8 #include "content/child/indexed_db/indexed_db_dispatcher.h"
9 #include "content/child/thread_safe_sender.h"
10 #include "content/common/indexed_db/indexed_db_key.h"
11 #include "ipc/ipc_sync_message_filter.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/WebKit/public/platform/WebData.h"
14 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h"
17 using blink::WebIDBCallbacks
;
18 using blink::WebIDBDatabase
;
19 using blink::WebIDBDatabaseError
;
20 using blink::WebIDBKey
;
21 using blink::WebVector
;
26 class MockCallbacks
: public WebIDBCallbacks
{
28 MockCallbacks() : error_seen_(false) {}
30 virtual void onError(const WebIDBDatabaseError
&) OVERRIDE
{
34 bool error_seen() const { return error_seen_
; }
42 TEST(IndexedDBDispatcherTest
, ValueSizeTest
) {
43 const std::vector
<char> data(kMaxIDBValueSizeInBytes
+ 1);
44 const WebData
value(&data
.front(), data
.size());
45 const int32 ipc_dummy_id
= -1;
46 const int64 transaction_id
= 1;
47 const int64 object_store_id
= 2;
49 scoped_refptr
<base::MessageLoopProxy
> message_loop_proxy(
50 base::MessageLoopProxy::current());
51 scoped_refptr
<IPC::SyncMessageFilter
> sync_message_filter(
52 new IPC::SyncMessageFilter(NULL
));
53 scoped_refptr
<ThreadSafeSender
> thread_safe_sender(new ThreadSafeSender(
54 message_loop_proxy
.get(), sync_message_filter
.get()));
56 MockCallbacks callbacks
;
57 IndexedDBDispatcher
dispatcher(thread_safe_sender
.get());
58 IndexedDBKey
key(0, blink::WebIDBKeyTypeNumber
);
59 dispatcher
.RequestIDBDatabasePut(ipc_dummy_id
,
64 WebIDBDatabase::AddOrUpdate
,
66 WebVector
<long long>(),
67 WebVector
<WebVector
<WebIDBKey
> >());
69 EXPECT_TRUE(callbacks
.error_seen());
72 } // namespace content