/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * 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/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/// Working method which should be overridden. virtualvoid SAL_CALL run() { for( int i = 0 ; i < m_iMax ; i ++ ) {
m_output->writeBytes( createIntSeq(i) );
}
m_output->closeOutput();
}
/** Called when run() is done. * You might want to override it to do some cleanup.
*/ virtualvoid SAL_CALL onTerminated()
{ deletethis;
}
private:
Reference < XOutputStream > m_output; int m_iMax;
};
class OPipeTest : public WeakImplHelper < XSimpleTest >
{ public: explicit OPipeTest( const Reference< XMultiServiceFactory > & rFactory );
~OPipeTest();
// available shouldn't return a negative value
input->skipBytes( seqWrite.getLength() - 5 );
ERROR_ASSERT( 0 == input->available() , "wrong available after skip" );
// 5 bytes should be available
output->writeBytes( seqWrite );
ERROR_ASSERT( 5 == input->available() , "wrong available after skip/write " );
ERROR_ASSERT( 10 == input->readSomeBytes( seqRead , 10 ) , "maximal number of bytes ignored" );
ERROR_ASSERT( seqWrite.getLength() -10 == input->readSomeBytes( seqRead , 100 ) , "something wrong with readSomeBytes" );
output->closeOutput(); try{
output->writeBytes( Sequence<sal_Int8> (100) );
ERROR_ASSERT( 0 , "writing on a closed stream does not cause an exception" );
} catch (IOException & )
{
}
ERROR_ASSERT(! input->readBytes( seqRead , 1 ), "eof not found !" );
input->closeInput(); try
{
input->readBytes( seqRead , 1 );
ERROR_ASSERT( 0 , "reading from a closed stream does not cause an exception" );
} catch( IOException & ) {
}
try
{
input->available( );
ERROR_ASSERT( 0 , "calling available from a closed stream should thrown an io exception" );
} catch( IOException & )
{
} try
{
input->skipBytes(42 );
ERROR_ASSERT( 0 , "calling available from a closed stream should thrown an io exception" );
} catch( IOException & )
{
}
}
void OPipeTest::testBufferResizing( const Reference < XInterface > &r )
{ int i; int iMax = 20000;
Reference< XInputStream > input( r , UNO_QUERY );
Reference < XOutputStream > output( r , UNO_QUERY );
ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" );
ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" );
Sequence<sal_Int8> seqRead;
// this is just to better check the // internal buffers
output->writeBytes( Sequence<sal_Int8>(100) );
Sequence< sal_Int8 > dummy;
input->readBytes( dummy , 100);
for( i = 0 ; i < iMax ; i ++ ) {
output->writeBytes( createIntSeq( i ) );
}
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 und die Messung sind noch experimentell.