OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/values.h" | 6 #include "base/values.h" |
7 #include "content/common/indexed_db/indexed_db_dispatcher.h" | 7 #include "content/common/indexed_db/indexed_db_dispatcher.h" |
8 #include "content/common/indexed_db/indexed_db_key.h" | 8 #include "content/common/indexed_db/indexed_db_key.h" |
9 #include "content/public/common/serialized_script_value.h" | 9 #include "content/public/common/serialized_script_value.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
14 | 14 |
15 using content::IndexedDBKey; | 15 using content::IndexedDBKey; |
16 using content::SerializedScriptValue; | 16 using content::SerializedScriptValue; |
| 17 using WebKit::WebVector; |
| 18 using WebKit::WebString; |
17 | 19 |
18 class FakeWebIDBTransaction : public WebKit::WebIDBTransaction { | 20 class FakeWebIDBTransaction : public WebKit::WebIDBTransaction { |
19 public: | 21 public: |
20 FakeWebIDBTransaction() {} | 22 FakeWebIDBTransaction() {} |
21 }; | 23 }; |
22 | 24 |
23 TEST(IndexedDBDispatcherTest, ValueSizeTest) { | 25 TEST(IndexedDBDispatcherTest, ValueSizeTest) { |
24 string16 data; | 26 string16 data; |
25 data.resize(kMaxIDBValueSizeInBytes / sizeof(char16) + 1, 'x'); | 27 data.resize(kMaxIDBValueSizeInBytes / sizeof(char16) + 1, 'x'); |
26 const bool kIsNull = false; | 28 const bool kIsNull = false; |
27 const bool kIsInvalid = false; | 29 const bool kIsInvalid = false; |
28 const SerializedScriptValue value(kIsNull, kIsInvalid, data); | 30 const SerializedScriptValue value(kIsNull, kIsInvalid, data); |
29 const int32 dummy_id = -1; | 31 const int32 dummy_id = -1; |
30 | 32 |
31 { | 33 { |
32 IndexedDBDispatcher dispatcher; | 34 IndexedDBDispatcher dispatcher; |
33 IndexedDBKey key; | 35 IndexedDBKey key; |
34 key.SetNumber(0); | 36 key.SetNumber(0); |
35 WebKit::WebExceptionCode ec = 0; | 37 WebKit::WebExceptionCode ec = 0; |
36 dispatcher.RequestIDBObjectStorePut( | 38 dispatcher.RequestIDBObjectStorePut( |
37 value, | 39 value, |
38 key, | 40 key, |
39 WebKit::WebIDBObjectStore::AddOrUpdate, | 41 WebKit::WebIDBObjectStore::AddOrUpdate, |
40 static_cast<WebKit::WebIDBCallbacks*>(NULL), | 42 static_cast<WebKit::WebIDBCallbacks*>(NULL), |
41 dummy_id, | 43 dummy_id, |
42 FakeWebIDBTransaction(), | 44 FakeWebIDBTransaction(), |
| 45 WebVector<WebString>(), |
| 46 WebVector<WebVector<WebKit::WebIDBKey> >(), |
43 &ec); | 47 &ec); |
44 EXPECT_NE(ec, 0); | 48 EXPECT_NE(ec, 0); |
45 } | 49 } |
46 | 50 |
47 { | 51 { |
48 IndexedDBDispatcher dispatcher; | 52 IndexedDBDispatcher dispatcher; |
49 WebKit::WebExceptionCode ec = 0; | 53 WebKit::WebExceptionCode ec = 0; |
50 dispatcher.RequestIDBCursorUpdate( | 54 dispatcher.RequestIDBCursorUpdate( |
51 value, | 55 value, |
52 static_cast<WebKit::WebIDBCallbacks*>(NULL), | 56 static_cast<WebKit::WebIDBCallbacks*>(NULL), |
53 dummy_id, | 57 dummy_id, |
54 &ec); | 58 &ec); |
55 EXPECT_NE(ec, 0); | 59 EXPECT_NE(ec, 0); |
56 } | 60 } |
57 } | 61 } |
OLD | NEW |