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

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

Issue 2500263003: Port messages sent by WebIDBCursorImpl to Mojo. (Closed)
Patch Set: Address dcheng@'s comments. Created 4 years, 1 month 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const std::vector<char> data(kMaxValueSizeForTesting + 1); 51 const std::vector<char> data(kMaxValueSizeForTesting + 1);
52 const WebData value(&data.front(), data.size()); 52 const WebData value(&data.front(), data.size());
53 const WebVector<WebBlobInfo> web_blob_info; 53 const WebVector<WebBlobInfo> web_blob_info;
54 54
55 const int64_t transaction_id = 1; 55 const int64_t transaction_id = 1;
56 const int64_t object_store_id = 2; 56 const int64_t object_store_id = 2;
57 57
58 StrictMock<MockWebIDBCallbacks> callbacks; 58 StrictMock<MockWebIDBCallbacks> callbacks;
59 EXPECT_CALL(callbacks, onError(_)).Times(1); 59 EXPECT_CALL(callbacks, onError(_)).Times(1);
60 60
61 WebIDBDatabaseImpl database_impl(nullptr, base::ThreadTaskRunnerHandle::Get(), 61 WebIDBDatabaseImpl database_impl(nullptr,
62 nullptr); 62 base::ThreadTaskRunnerHandle::Get());
63 database_impl.max_put_value_size_ = kMaxValueSizeForTesting; 63 database_impl.max_put_value_size_ = kMaxValueSizeForTesting;
64 database_impl.put(transaction_id, object_store_id, value, web_blob_info, 64 database_impl.put(transaction_id, object_store_id, value, web_blob_info,
65 WebIDBKey::createNumber(0), blink::WebIDBPutModeAddOrUpdate, 65 WebIDBKey::createNumber(0), blink::WebIDBPutModeAddOrUpdate,
66 &callbacks, WebVector<long long>(), 66 &callbacks, WebVector<long long>(),
67 WebVector<WebVector<WebIDBKey>>()); 67 WebVector<WebVector<WebIDBKey>>());
68 } 68 }
69 69
70 TEST_F(WebIDBDatabaseImplTest, KeyAndValueSizeTest) { 70 TEST_F(WebIDBDatabaseImplTest, KeyAndValueSizeTest) {
71 // For testing use a much smaller maximum size to prevent allocating >100 MB 71 // For testing use a much smaller maximum size to prevent allocating >100 MB
72 // of memory, which crashes on memory-constrained systems. 72 // of memory, which crashes on memory-constrained systems.
73 const size_t kMaxValueSizeForTesting = 10 * 1024 * 1024; // 10 MB 73 const size_t kMaxValueSizeForTesting = 10 * 1024 * 1024; // 10 MB
74 const size_t kKeySize = 1024 * 1024; 74 const size_t kKeySize = 1024 * 1024;
75 75
76 const std::vector<char> data(kMaxValueSizeForTesting - kKeySize); 76 const std::vector<char> data(kMaxValueSizeForTesting - kKeySize);
77 const WebData value(&data.front(), data.size()); 77 const WebData value(&data.front(), data.size());
78 const WebVector<WebBlobInfo> web_blob_info; 78 const WebVector<WebBlobInfo> web_blob_info;
79 const WebIDBKey key = WebIDBKey::createString( 79 const WebIDBKey key = WebIDBKey::createString(
80 base::string16(kKeySize / sizeof(base::string16::value_type), 'x')); 80 base::string16(kKeySize / sizeof(base::string16::value_type), 'x'));
81 81
82 const int64_t transaction_id = 1; 82 const int64_t transaction_id = 1;
83 const int64_t object_store_id = 2; 83 const int64_t object_store_id = 2;
84 84
85 StrictMock<MockWebIDBCallbacks> callbacks; 85 StrictMock<MockWebIDBCallbacks> callbacks;
86 EXPECT_CALL(callbacks, onError(_)).Times(1); 86 EXPECT_CALL(callbacks, onError(_)).Times(1);
87 87
88 WebIDBDatabaseImpl database_impl(nullptr, base::ThreadTaskRunnerHandle::Get(), 88 WebIDBDatabaseImpl database_impl(nullptr,
89 nullptr); 89 base::ThreadTaskRunnerHandle::Get());
90 database_impl.max_put_value_size_ = kMaxValueSizeForTesting; 90 database_impl.max_put_value_size_ = kMaxValueSizeForTesting;
91 database_impl.put(transaction_id, object_store_id, value, web_blob_info, key, 91 database_impl.put(transaction_id, object_store_id, value, web_blob_info, key,
92 blink::WebIDBPutModeAddOrUpdate, &callbacks, 92 blink::WebIDBPutModeAddOrUpdate, &callbacks,
93 WebVector<long long>(), WebVector<WebVector<WebIDBKey>>()); 93 WebVector<long long>(), WebVector<WebVector<WebIDBKey>>());
94 } 94 }
95 95
96 } // namespace content 96 } // namespace content
OLDNEW
« no previous file with comments | « content/child/indexed_db/webidbdatabase_impl.cc ('k') | content/child/indexed_db/webidbfactory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698