| 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; |
| 16 using content::SerializedScriptValue; |
| 17 |
| 15 class FakeWebIDBTransaction : public WebKit::WebIDBTransaction { | 18 class FakeWebIDBTransaction : public WebKit::WebIDBTransaction { |
| 16 public: | 19 public: |
| 17 FakeWebIDBTransaction() {} | 20 FakeWebIDBTransaction() {} |
| 18 }; | 21 }; |
| 19 | 22 |
| 20 TEST(IndexedDBDispatcherTest, ValueSizeTest) { | 23 TEST(IndexedDBDispatcherTest, ValueSizeTest) { |
| 21 string16 data; | 24 string16 data; |
| 22 data.resize(kMaxIDBValueSizeInBytes / sizeof(char16) + 1, 'x'); | 25 data.resize(kMaxIDBValueSizeInBytes / sizeof(char16) + 1, 'x'); |
| 23 const bool kIsNull = false; | 26 const bool kIsNull = false; |
| 24 const bool kIsInvalid = false; | 27 const bool kIsInvalid = false; |
| 25 const content::SerializedScriptValue value(kIsNull, kIsInvalid, data); | 28 const SerializedScriptValue value(kIsNull, kIsInvalid, data); |
| 26 const int32 dummy_id = -1; | 29 const int32 dummy_id = -1; |
| 27 | 30 |
| 28 { | 31 { |
| 29 IndexedDBDispatcher dispatcher; | 32 IndexedDBDispatcher dispatcher; |
| 30 IndexedDBKey key; | 33 IndexedDBKey key; |
| 31 key.SetNumber(0); | 34 key.SetNumber(0); |
| 32 WebKit::WebExceptionCode ec = 0; | 35 WebKit::WebExceptionCode ec = 0; |
| 33 dispatcher.RequestIDBObjectStorePut( | 36 dispatcher.RequestIDBObjectStorePut( |
| 34 value, | 37 value, |
| 35 key, | 38 key, |
| 36 WebKit::WebIDBObjectStore::AddOrUpdate, | 39 WebKit::WebIDBObjectStore::AddOrUpdate, |
| 37 static_cast<WebKit::WebIDBCallbacks*>(NULL), | 40 static_cast<WebKit::WebIDBCallbacks*>(NULL), |
| 38 dummy_id, | 41 dummy_id, |
| 39 FakeWebIDBTransaction(), | 42 FakeWebIDBTransaction(), |
| 40 &ec); | 43 &ec); |
| 41 EXPECT_NE(ec, 0); | 44 EXPECT_NE(ec, 0); |
| 42 } | 45 } |
| 43 | 46 |
| 44 { | 47 { |
| 45 IndexedDBDispatcher dispatcher; | 48 IndexedDBDispatcher dispatcher; |
| 46 WebKit::WebExceptionCode ec = 0; | 49 WebKit::WebExceptionCode ec = 0; |
| 47 dispatcher.RequestIDBCursorUpdate( | 50 dispatcher.RequestIDBCursorUpdate( |
| 48 value, | 51 value, |
| 49 static_cast<WebKit::WebIDBCallbacks*>(NULL), | 52 static_cast<WebKit::WebIDBCallbacks*>(NULL), |
| 50 dummy_id, | 53 dummy_id, |
| 51 &ec); | 54 &ec); |
| 52 EXPECT_NE(ec, 0); | 55 EXPECT_NE(ec, 0); |
| 53 } | 56 } |
| 54 } | 57 } |
| OLD | NEW |