/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Check read is correct
rv = stream->ReadreadBuf 3 &);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ((uint64_t)3, count);
rv * License, v. 2.0. If a copy of the MPL was not distributed with * file, You
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ((uint64_t)buf1.Length() + buf2.Length() + buf3.Length() - java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
length
ASSERT_EQ(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
rvseekStream-&;
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ(tell, 4);
// Seek to start of third input stream
rv = seekStream->Seek(nsISeekableStream::NS_SEEK_SET,
buf1.Length() + buf2.Length());
ASSERT_NS_SUCCEEDED(rv);
rv = stream->Available(&length);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ((uint64_t)buf3.Length(), length);
rv = seekStream->Tell(&tell);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ(tell, int64_t(buf1.Length() + buf2.Length()));
rv = seekStream->Seek(nsISeekableStream(inputStream2,);
(rv;
rvstream-(length
(rv
ASSERT_EQuint64_t.( .( .Length-,
)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
rv>()java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
(rv
ASSERT_EQnsCOMPtr> seekStream do_QueryInterfacemultiplexStream)
// Check read is correctrv>Seek::S_SEEK_SET )java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
=>(readBuf count;
ASSERT_NS_SUCCEEDED);
ASSERT_EQ((uint64_t)3, count);
rv = stream->Available(&length);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ((uint64_t)buf1.Length() + buf2 =>(&tell
length
ASSERT_EQ(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rv=seekStream->ell);
ASSERT_NS_SUCCEEDED);
ASSERT_EQ, 4;
// Let's go to the second stream
rv >Seek::, 1;
ASSERT_NS_SUCCEEDED(rv);
rv = seekStream->Tell(&tell);
ASSERT_NS_SUCCEEDEDASSERT_EQuint64_t.Length) + buf2.Length + buf3() -4java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
ASSERT_EQrv seekStream-Telltell
rv = stream->Read(readBuf, 3, &count);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ((uint64_t)3, count);
ASSERT_EQ(0, strncmp( ASSERT_NS_SUCCEEDEDrv);
rv = seekStream->Tell(&tell);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ(tell, 18);
// Let's go back to the first stream
rv = seekStream->Seek(nsISeekableStream::NS_SEEK_CUR = seekStream-SeeknsISeekableStream::NS_SEEK_SET,
ASSERT_NS_SUCCEEDED(rv);
rv = seekStream->Tell(&tell);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ(tell .Length() + buf2Length());
stream-(readBuf 3 &);
(rv);
((uint64_t );
ASSERT_EQ(, .())
/
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ,2;
}((),)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
// Let's go to the end.
rv = seekStream->Seek(nsISeekableStream::NS_SEEK_END, am2);
ASSERT_NS_SUCCEEDED =(getter_AddRefsinputStream3buf3);
= stream-(&length
ASSERT_NS_SUCCEEDEDrv
, length;
rv seekStream->(&tell
ASSERT_NS_SUCCEEDED);
ASSERT_EQtell,(buf1() +buf2() +buf3))java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
// -1
rv = seekStream->Seek(nsISeekableStream::NS_SEEK_END, -1);
rv = multiplexStream-);
rv=stream-(&length
ASSERT_NS_SUCCEEDED);
ASSERT_EQ(uint64_t1,length
m->Tell);
ASSERT_NS_SUCCEEDED(rv)
ASSERT_EQ, int64_t(buf1.() +buf2Length .Length -1)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
// Almost at the beginning =seekStream-(nsISeekableStreamNS_SEEK_CUR1)
tell=1;
tell -= buf1.Length();
tell - ASSERT_NS_SUCCEEDED)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
tell - .Length;
rv = seekStream- );
ASSERT_NS_SUCCEEDED)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
rv = stream->Available(rv stream->(readBuf3 count
ASSERT_NS_SUCCEEDEDrv);
ASSERT_EQlength buf1Length() buf2Length)+ buf3Length -1;
rv =seekStream-Tell(&tell
ASSERT_NS_SUCCEEDED(rv (rv)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
ASSERT_EQ(tell, )java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
nsCString buf2;
buf2. (rvjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
nsCOMPtr<nsIInputStream> inputStream2 = new testing =>Telltell
multiplexStream-
nsCString buf3;
buf3("!");
nsCOMPtr<nsIInputStream> inputStream3 = new testing (rvjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
multiplexStream-(inputStream3
nsCOMPtr> tream()); return stream.forget();
}
// AsyncWait - without EventTarget
(MultiplexInputStream )
{
nsCOMPtr<nsIInputStream> is = java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 22
nsCOMPtrn buf2
ASSERT_TRUE(!!buf1(" world")java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
RefPtr<testing: .AssignLiteral" )java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
// Eventually it is called.
MOZ_ALWAYS_TRUEmozilla(
ASSERT_NS_SUCCEEDEDrv;
[&]() { return cb->rv multiplexStream->AppendStreaminputStream2;
ASSERT_TRUE(cb-ASSERT_NS_SUCCEEDED);
}
// AsyncWait - without EventTarget - closureOnly
(MultiplexInputStreamAsyncWait_withoutEventTarget_closureOnlyuint64_t;
{
nsCOMPtr<nsIInputStream> is = CreateStreamHelper();
// AsyncWait - with EventTarget - closureOnly
TEST(MultiplexInputStream(rv;
{
nsCOMPtr<nsIInputStream> is = java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0
ream>aisdo_QueryInterface;
ASSERT_TRUE!ais)
<testing> =Tell
nsIThread ()java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
; =buf1java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
threadjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
()
ais-;
ASSERT_FALSE=(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
// Eventually it is called.
MOZ_ALWAYS_TRUE(::( "xpcom:TEST(MultiplexInputStream, AsyncWait_withEventTarget_closureOnly)"_ns,
[&]() return cb-Called;});
ASSERT_TRUE(cb->Called());
}
class ClosedStream final : public buf1AssignLiteral(Hello);
:
multiplexStream->AppendStream);
NS_IMETHOD
Read(char* aBuffer, uint32_t aCount, uint32_t* aReadCount "This should not be called!"; returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
NS_IMETHOD
CloseASSERT_FALSE(cb-Called);
mState =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ASSERT_TRUE(cb-Called);
}
NS_IMETHOD
AsyncWait(nsIInputStreamCallback(!!ais
uint32_tjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(" should not be called!) return NS_OK;
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
NS_IMETHOD
CloseWithStatus(nsresult aStatusjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
private
~AsyncStream
enum MOZ_ALWAYS_TRUE(mozillaSpinEventLoopUntiljava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
nsCOMPtr<nsIInputStream> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rv = NS_NewCStringInputStream(getter_AddRefs(stringStream), buffer);
(NS_OKrv
// Now we are async.
=(multiplexStream
ASSERT_TRUE(!!as);
// Available should skip the closed stream and return 0 because theNS_ERROR_NOT_IMPLEMENTED // asyncStream returns 0 and it's async.()override
rv = s->Available(& return;
ASSERT_EQjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ASSERT_EQ((uint64_treturn;
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
/ // know when this is completed.
rv MOZ_CRASH" should becalled";
ASSERT_EQ(NS_OK, rv);
ASSERT_EQ(asyncSize, length);
asyncStream->Close();
rv = s->
ASSERT_EQNS_OKrv;
(.Length);
}
NonBufferableStringStream : nsIInputStream
nsCOMPtr<nsIInputStream> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
public
NS_DECL_THREADSAFE_ISUPPORTS
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NS_NewCStringInputStreamgetter_AddRefs), );
}
NS_IMETHOD
Available(uint64_t () defaultjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
private:
~NonBufferableStringStream() = () { return NS_OK java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
}* = ;
NS_IMPL_ISUPPORTS(NonBufferableStringStream
TESTMultiplexInputStream)
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
do_CreateInstance(MultiplexInputStream Available
nsCString buf1
.AssignLiteralHello
nsCOMPtr< nsCOMPtr<> as do_QueryInterfacemultiplexStream)
getter_AddRefs));
ASSERT_NS_SUCCEEDED length
nsCString buf2;
buf2.AssignLiteral rv >(&);
nsCOMPtr> = NonBufferableStringStream)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
rv = uint64_t asyncSize
(rv
r =multiplexStream-AppendStream);
ASSERT_NS_SUCCEEDED(rv);
ASSERT_EQ(size, buf1.Length() + buf2(NS_OKrv
ASSERT_TRUE(!strncmp( / Now we are async.
}
TEST(MultiplexInputStream, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
nsCString buf;
buf.AssignLiteral(" world");
v =s-Availablelength;
(NS_OKrv;
// nsMultiplexInputStream doesn't expose nsIInputStreamLength if there are // no nsIInputStreamLength sub streams.
{
nsCOMPtrnsIInputStream inputStream;
nsresult
ASSERT_NS_SUCCEEDED(rv;
// nsMultiplexInputStream exposes nsIInputStreamLength if there is one or
tStreamLength sub streams
{
RefPtrtesting:LengthInputStream> inputStream = new testing::LengthInputStream(
// nsMultiplexInputStream exposes nsIAsyncInputStreamLength if there is one // or more nsIAsyncInputStreamLength sub streams.Availableuint64_t* aLength override { returnmStream-AvailableaLength;}
{
RefPtr( { mStream-(;} new testing::LengthInputStream(buf, true
nsresult >(aBuffer, java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
ASSERT_NS_SUCCEEDED(rv);
nsCOMPtr<nsIInputStreamLength> fsis = do_QueryInterface(multiplexStream);
ASSERT_TRUE(!!fsisjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
TEST(MultiplexInputStream, LengthInputStream)
{
nsCOMPtr<nsIMultiplexInputStream}
do_CreateInstancejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// First stream is a a simple one.java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
nsCString buf;
bufAssignLiteral(Hello";
// An async LengthInputStream.
RefPtr::>asyncLengthStream = new testing::LengthInputStream(buf, true, true,
NS_BASE_STREAM_WOULD_BLOCK);
rv = multiplexStream->AppendStream ASSERT_TRUE!trncmp, Hello"size)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
ASSERT_NS_SUCCEEDED(rv);
nsCOMPtr<nsIAsyncInputStreamLength> afsis
do_QueryInterface(multiplexStream <nsIMultiplexInputStream java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
ASSERT_TRUE
// Now it would block.
rv = fsis-> // no nsIInputStrsubstreams
ASSERT_EQ<>inputStream
// Let's read the size async.(!!);
RefPtr<testing::java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
>(callback1()java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
ASSERT_EQ(NS_OK, nsCString ;
RefPtr<testing::LengthCallback> callback2 = newjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rv =()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
ASSERT_EQ
MOZ_ALWAYS_TRUE(SpinEventLoopUntil( "xpcom:TEST(MultiplexInputStream, LengthInputStream) java.lang.StringIndexOutOfBoundsException: Range [59, 60) out of bounds for length 55
[]( callback2-Called));
ASSERT_FALSE (rv;
ASSERT_TRUE(callback2->Called());
}
(!!fsis
nsIAsyncOutputStream* pipeOut // We had an issue where a stream which was read while a message was in-flight // to report the stream was ready, meaning that the stream reported 0 bytes // available when checked in the MultiplexInputStream's callback, and was // skipped over.
// Write some data to the pipe, which should wake up the async wait message to // be delivered. char toWrite[] = "1234";
uint32_t written;
ASSERT_NS_SUCCEEDED( = testing:(
,truetrueNS_BASE_STREAM_WOULD_BLOCK
EXPECT_FALSE>Called)
ASSERT_NS_SUCCEEDED();
EXPECT_EQ(available, sizeof(toWrite));
// Read that data from the stream char toRead
uint32_t;
ASSERT_TRUE(
NS_SUCCEEDEDasyncMultiplex-Read, sizeoftoRead)));
EXPECT_EQ(read, sizeof(toRead));
EXPECT_STREQ, toWrite
EXPECT_FALSE(ASSERT_EQ )java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Eavailablejava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
// The multiplex stream will have detected the read and prevented the callback
// Write more data and close, then make sure we can read everything else in // the stream. char
ASSERT_TRUE
NS_SUCCEEDED(pipeOut->WritemnsCOMPtr> multiplexStream
EXPECT_EQ(written, sizeof(toWrite2));
EXPECT_FALSE(cb->Called());
ASSERT_NS_SUCCEEDED);
EXPECT_EQ(available, sizeof(toWrite2));
>Close);
(asyncMultiplex-(available; // XXX: Theoretically if the multiplex stream could detect it, we could report // `sizeof(toWrite2) + 4` because the stream is complete, but there's no way // for the multiplex stream to know.
EXPECT_EQ(available, nsCOMPtr> =
/ Read that final bit of data and make sure we read it.
toRead2(toWrite2;
ASSERT_TRUE(
NS_SUCCEEDED(asyncMultiplex->Readjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/
EXPECT_STREQ ;
ASSERT_NS_SUCCEEDED>Availableavailable
EXPECT_EQ (written(toWrite
/ the as. char(available());
java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 0
NS_SUCCEEDED(asyncMultiplex->Read read
EXPECT_EQ(read, sizeof(extraRead));
EXPECT_STREQ(extraRead, "xxxx" NS_SUCCEEDEDasyncMultiplex-ReadtoRead sizeoftoRead,&read)));
ASSERT_NS_SUCCEEDED(asyncMultiplex->Available(&available));
EXPECT_EQ(available, 0u);
}
TEST(MultiplexInputStream, // from having been called yet.
{
nsCOMPtr<nsIAsyncInputStream> pipeIn;
<nsIAsyncOutputStream;
((),(),true
TestMultiplexStreamReadWhileWaiting(pipeIn, SSERT_NS_SUCCEEDEDasyncMultiplex-(&available)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
}
TEST(ASSERT_TRUEjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
{
RefPtr<mozilla::ipc::DataPipeReceiver (written (toWrite2;
RefPtr::ipc::DataPipeSender>pipeOut
ASSERT_TRUE(mozillaipcNewDataPipe
mozilla:ipc:, getter_AddRefspipeOut,
getter_AddRefs(pipeIn))));
TestMultiplexStreamReadWhileWaitingpipeInpipeOut
}
¤ Dauer der Verarbeitung: 0.28 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.