| OLD | NEW |
| (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 "base/memory/scoped_ptr.h" | |
| 6 #include "base/values.h" | |
| 7 #include "content/common/indexed_db/indexed_db_key.h" | |
| 8 #include "content/common_child/indexed_db/indexed_db_dispatcher.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 #include "third_party/WebKit/public/platform/WebData.h" | |
| 11 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h" | |
| 12 | |
| 13 using WebKit::WebData; | |
| 14 using WebKit::WebIDBCallbacks; | |
| 15 using WebKit::WebIDBDatabase; | |
| 16 using WebKit::WebIDBDatabaseError; | |
| 17 using WebKit::WebIDBKey; | |
| 18 using WebKit::WebVector; | |
| 19 | |
| 20 namespace content { | |
| 21 namespace { | |
| 22 | |
| 23 class MockCallbacks : public WebIDBCallbacks { | |
| 24 public: | |
| 25 MockCallbacks() : error_seen_(false) {} | |
| 26 | |
| 27 virtual void onError(const WebIDBDatabaseError&) OVERRIDE { | |
| 28 error_seen_ = true; | |
| 29 } | |
| 30 | |
| 31 bool error_seen() const { return error_seen_; } | |
| 32 | |
| 33 private: | |
| 34 bool error_seen_; | |
| 35 }; | |
| 36 | |
| 37 } // namespace | |
| 38 | |
| 39 TEST(IndexedDBDispatcherTest, ValueSizeTest) { | |
| 40 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1); | |
| 41 const WebData value(&data.front(), data.size()); | |
| 42 const int32 ipc_dummy_id = -1; | |
| 43 const int64 transaction_id = 1; | |
| 44 const int64 object_store_id = 2; | |
| 45 | |
| 46 MockCallbacks callbacks; | |
| 47 IndexedDBDispatcher dispatcher; | |
| 48 IndexedDBKey key(0, WebIDBKey::NumberType); | |
| 49 dispatcher.RequestIDBDatabasePut(ipc_dummy_id, | |
| 50 transaction_id, | |
| 51 object_store_id, | |
| 52 value, | |
| 53 key, | |
| 54 WebIDBDatabase::AddOrUpdate, | |
| 55 &callbacks, | |
| 56 WebVector<long long>(), | |
| 57 WebVector<WebVector<WebIDBKey> >()); | |
| 58 | |
| 59 EXPECT_TRUE(callbacks.error_seen()); | |
| 60 } | |
| 61 | |
| 62 } // namespace content | |
| OLD | NEW |