Kaydet (Commit) 528391f3 authored tarafından Thorsten Behrens's avatar Thorsten Behrens Kaydeden (comit) Thorsten Behrens

Resuscitate old vcl unit tests.

Needs a deleted canvastools method, move code into more idiomatic
vcl/qa place, adapt to new unit test framework.

Change-Id: Iddb9c2249673b4d580e46a1d72029be0a8c4d9ba
üst 7727b9e8
......@@ -90,6 +90,14 @@ namespace vcl
// Color conversions (vcl/tools Color <-> canvas standard color space)
// ===================================================================
/** Create a device-specific color sequence from VCL/Tools color
Note that this method assumes a color space equivalent to
the one returned from createStandardColorSpace()
*/
::com::sun::star::uno::Sequence< double >
VCL_DLLPUBLIC colorToStdColorSpaceSequence( const Color& rColor );
/** Convert color to device color sequence
@param rColor
......
......@@ -9,7 +9,13 @@
$(eval $(call gb_CppunitTest_CppunitTest,vcl_complextext))
$(eval $(call gb_CppunitTest_set_include,vcl_complextext,\
$$(INCLUDE) \
-I$(SRCDIR)/vcl/inc \
))
$(eval $(call gb_CppunitTest_add_exception_objects,vcl_complextext, \
vcl/qa/cppunit/canvasbitmaptest \
vcl/qa/cppunit/complextext \
))
......
......@@ -17,15 +17,18 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <unotest/filters-test.hxx>
#include <test/bootstrapfixture.hxx>
#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/lstbox.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/servicefactory.hxx>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase3.hxx>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
......@@ -34,9 +37,6 @@
#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp>
#include <osl/process.h>
#include <stdio.h>
using namespace ::rtl;
using namespace ::com::sun::star::io;
......@@ -48,16 +48,6 @@ using namespace ::com::sun::star::datatransfer::dnd;
// -----------------------------------------------------------------------
class MyApp : public Application
{
public:
void Main();
};
MyApp aMyApp;
// -----------------------------------------------------------------------
class MyWin : public WorkWindow
{
public:
......@@ -142,72 +132,39 @@ public:
// -----------------------------------------------------------------------
void MyApp::Main()
class VclDnDTest : public test::BootstrapFixture
{
OUString aRegistry;
for( sal_Int32 n = 0, nmax = osl_getCommandArgCount(); n < nmax; n++ )
{
OUString aArg;
osl_getCommandArg( n, &aArg.pData );
if( aArg.startsWith( "-r" ) )
{
if ( n + 1 < nmax )
osl_getCommandArg( ++n, &aRegistry.pData );
}
}
Reference< XMultiServiceFactory > xServiceManager;
if( aRegistry.getLength() )
{
xServiceManager = ::cppu::createRegistryServiceFactory( aRegistry, sal_True );
if( xServiceManager.is() )
{
::comphelper::setProcessServiceFactory( xServiceManager );
}
public:
VclDnDTest() : BootstrapFixture(true, false) {}
if( ! xServiceManager.is() )
printf( "No servicemanager available.\n" );
else
printf( "Ok\n" );
/// Play with drag and drop
void testDnD();
}
else
fprintf( stderr, "Usage: %s -r full-path-to-applicat.rdb\n", "dnddemo" );
CPPUNIT_TEST_SUITE(VclDnDTest);
CPPUNIT_TEST(testDnD);
CPPUNIT_TEST_SUITE_END();
};
// -----------------------------------------------------------------------
void VclDnDTest::testDnD()
{
MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
aMainWin.SetText( OUString( "Drag And Drop - Workbench" ) );
aMainWin.Show();
// test the clipboard code
Reference< XClipboard > xClipboard = aMainWin.GetClipboard();
if( xClipboard.is() )
{
printf( "System clipboard available.\n" );
xClipboard->getContents();
}
else
fprintf( stderr, "System clipboard not available.\n" );
CPPUNIT_ASSERT_MESSAGE("System clipboard not available",
xClipboard.is());
MyInfoBox aInfoBox( &aMainWin );
aInfoBox.Execute();
MyListBox aListBox( &aMainWin );
aListBox.SetPosSizePixel( 10, 10, 100, 100 );
aListBox.setPosSizePixel( 10, 10, 100, 100 );
aListBox.InsertEntry( OUString("TestItem"));
aListBox.Show();
Execute();
Reference< XComponent > xComponent( xServiceManager, UNO_QUERY );
if( xComponent.is() )
xComponent->dispose();
}
// -----------------------------------------------------------------------
......@@ -282,19 +239,14 @@ void MyWin::Resize()
void SAL_CALL MyDragAndDropListener::dragGestureRecognized( const DragGestureEvent& dge ) throw(RuntimeException)
{
printf( "XDragGestureListener::dragGestureRecognized called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dge.DragOriginX, dge.DragOriginY );
Reference< XDragSource > xDragSource( dge.DragSource, UNO_QUERY );
xDragSource->startDrag( dge, -1, 0, 0, new StringTransferable( OUString("TestString") ), this );
printf( "XDragSource::startDrag returned.\n" );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) throw(RuntimeException)
{
printf( "XDropTargetListener::drop called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->dropComplete( sal_True );
}
......@@ -302,7 +254,6 @@ void SAL_CALL MyDragAndDropListener::drop( const DropTargetDropEvent& dtde ) thr
void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent& dtdee ) throw(RuntimeException)
{
printf( "XDropTargetListener::dragEnter called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dtdee.LocationX, dtdee.LocationY );
dtdee.Context->acceptDrag( dtdee.DropAction );
}
......@@ -310,14 +261,12 @@ void SAL_CALL MyDragAndDropListener::dragEnter( const DropTargetDragEnterEvent&
void SAL_CALL MyDragAndDropListener::dragExit( const DropTargetEvent& ) throw(RuntimeException)
{
printf( "XDropTargetListener::dragExit called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde ) throw(RuntimeException)
{
printf( "XDropTargetListener::dragOver called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->acceptDrag( dtde.DropAction );
}
......@@ -325,50 +274,43 @@ void SAL_CALL MyDragAndDropListener::dragOver( const DropTargetDragEvent& dtde )
void SAL_CALL MyDragAndDropListener::dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException)
{
printf( "XDropTargetListener::dropActionChanged called ( Window: %p, %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 " ).\n", m_pWindow, dtde.LocationX, dtde.LocationY );
dtde.Context->acceptDrag( dtde.DropAction );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragDropEnd( const DragSourceDropEvent& dsde ) throw(RuntimeException)
void SAL_CALL MyDragAndDropListener::dragDropEnd( const DragSourceDropEvent& ) throw(RuntimeException)
{
printf( "XDragSourceListener::dropDropEnd called ( Window: %p, %s ).\n", m_pWindow, dsde.DropSuccess ? "success" : "failed" );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragEnter( const DragSourceDragEvent& ) throw(RuntimeException)
{
printf( "XDragSourceListener::dragEnter called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragExit( const DragSourceEvent& ) throw(RuntimeException)
{
printf( "XDragSourceListener::dragExit called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dragOver( const DragSourceDragEvent& ) throw(RuntimeException)
{
printf( "XDragSourceListener::dragOver called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::dropActionChanged( const DragSourceDragEvent& ) throw(RuntimeException)
{
printf( "XDragSourceListener::dropActionChanged called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
void SAL_CALL MyDragAndDropListener::disposing( const EventObject& ) throw(RuntimeException)
{
printf( "XEventListener::disposing called ( Window: %p ).\n", m_pWindow );
}
// -----------------------------------------------------------------------
......@@ -432,5 +374,6 @@ sal_Bool SAL_CALL StringTransferable::isDataFlavorSupported( const DataFlavor& )
return sal_True;
}
CPPUNIT_TEST_SUITE_REGISTRATION(VclDnDTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -575,6 +575,21 @@ namespace vcl
}
uno::Sequence< double > colorToStdColorSpaceSequence( const Color& rColor )
{
uno::Sequence< double > aRet(4);
double* pRet = aRet.getArray();
pRet[0] = toDoubleColor(rColor.GetRed());
pRet[1] = toDoubleColor(rColor.GetGreen());
pRet[2] = toDoubleColor(rColor.GetBlue());
// VCL's notion of alpha is different from the rest of the world's
pRet[3] = 1.0 - toDoubleColor(rColor.GetTransparency());
return aRet;
}
Color stdColorSpaceSequenceToColor( const uno::Sequence< double >& rColor )
{
ENSURE_ARG_OR_THROW( rColor.getLength() == 4,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment