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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp

Issue 1878463002: Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy Created 4 years, 8 months 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/fetch/FetchFormDataConsumerHandle.h" 5 #include "modules/fetch/FetchFormDataConsumerHandle.h"
6 6
7 #include "core/dom/DOMTypedArray.h" 7 #include "core/dom/DOMTypedArray.h"
8 #include "core/html/FormData.h" 8 #include "core/html/FormData.h"
9 #include "core/loader/MockThreadableLoader.h" 9 #include "core/loader/MockThreadableLoader.h"
10 #include "core/loader/ThreadableLoaderClient.h" 10 #include "core/loader/ThreadableLoaderClient.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create (String(cs)); 154 OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create (String(cs));
155 HandleReaderRunner<HandleReader> runner(handle.release()); 155 HandleReaderRunner<HandleReader> runner(handle.release());
156 OwnPtr<HandleReadResult> r = runner.wait(); 156 OwnPtr<HandleReadResult> r = runner.wait();
157 EXPECT_EQ(kDone, r->result()); 157 EXPECT_EQ(kDone, r->result());
158 EXPECT_EQ("\xe3\x81\x82", toString(r->data())); 158 EXPECT_EQ("\xe3\x81\x82", toString(r->data()));
159 } 159 }
160 160
161 TEST_F(FetchFormDataConsumerHandleTest, ReadFromArrayBuffer) 161 TEST_F(FetchFormDataConsumerHandleTest, ReadFromArrayBuffer)
162 { 162 {
163 const unsigned char data[] = { 0x21, 0xfe, 0x00, 0x00, 0xff, 0xa3, 0x42, 0x3 0, 0x42, 0x99, 0x88 }; 163 const unsigned char data[] = { 0x21, 0xfe, 0x00, 0x00, 0xff, 0xa3, 0x42, 0x3 0, 0x42, 0x99, 0x88 };
164 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, WTF_ARRAY_LENGT H(data)); 164 DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, WTF_ARRAY_LENGTH(data) );
165 OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create (buffer); 165 OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create (buffer);
166 HandleReaderRunner<HandleReader> runner(handle.release()); 166 HandleReaderRunner<HandleReader> runner(handle.release());
167 OwnPtr<HandleReadResult> r = runner.wait(); 167 OwnPtr<HandleReadResult> r = runner.wait();
168 EXPECT_EQ(kDone, r->result()); 168 EXPECT_EQ(kDone, r->result());
169 Vector<char> expected; 169 Vector<char> expected;
170 expected.append(data, WTF_ARRAY_LENGTH(data)); 170 expected.append(data, WTF_ARRAY_LENGTH(data));
171 EXPECT_EQ(expected, r->data()); 171 EXPECT_EQ(expected, r->data());
172 } 172 }
173 173
174 TEST_F(FetchFormDataConsumerHandleTest, ReadFromArrayBufferView) 174 TEST_F(FetchFormDataConsumerHandleTest, ReadFromArrayBufferView)
175 { 175 {
176 const unsigned char data[] = { 0x21, 0xfe, 0x00, 0x00, 0xff, 0xa3, 0x42, 0x3 0, 0x42, 0x99, 0x88 }; 176 const unsigned char data[] = { 0x21, 0xfe, 0x00, 0x00, 0xff, 0xa3, 0x42, 0x3 0, 0x42, 0x99, 0x88 };
177 const size_t offset = 1, size = 4; 177 const size_t offset = 1, size = 4;
178 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, WTF_ARRAY_LENGT H(data)); 178 DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, WTF_ARRAY_LENGTH(data) );
179 OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create (DOMUint8Array::create(buffer, offset, size)); 179 OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create (DOMUint8Array::create(buffer, offset, size));
180 HandleReaderRunner<HandleReader> runner(handle.release()); 180 HandleReaderRunner<HandleReader> runner(handle.release());
181 OwnPtr<HandleReadResult> r = runner.wait(); 181 OwnPtr<HandleReadResult> r = runner.wait();
182 EXPECT_EQ(kDone, r->result()); 182 EXPECT_EQ(kDone, r->result());
183 Vector<char> expected; 183 Vector<char> expected;
184 expected.append(data + offset, size); 184 expected.append(data + offset, size);
185 EXPECT_EQ(expected, r->data()); 185 EXPECT_EQ(expected, r->data());
186 } 186 }
187 187
188 TEST_F(FetchFormDataConsumerHandleTest, ReadFromSimplFormData) 188 TEST_F(FetchFormDataConsumerHandleTest, ReadFromSimplFormData)
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); 438 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available));
439 testing::runPendingTasks(); 439 testing::runPendingTasks();
440 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available)); 440 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available));
441 EXPECT_FALSE(reader->drainAsFormData()); 441 EXPECT_FALSE(reader->drainAsFormData());
442 reader->endRead(0); 442 reader->endRead(0);
443 EXPECT_FALSE(reader->drainAsFormData()); 443 EXPECT_FALSE(reader->drainAsFormData());
444 } 444 }
445 445
446 } // namespace 446 } // namespace
447 } // namespace blink 447 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698