2016-02-13 16:08:01 +11:00
/* -*- 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/.
*/
# include <test/bootstrapfixture.hxx>
# include <cppunit/TestAssert.h>
# include <cppunit/TestFixture.h>
# include <osl/file.hxx>
# include <osl/process.h>
# include <vcl/mapmod.hxx>
class VclMapModeTest : public test : : BootstrapFixture
{
public :
VclMapModeTest ( ) : BootstrapFixture ( true , false ) { }
void testMultiplier ( ) ;
CPPUNIT_TEST_SUITE ( VclMapModeTest ) ;
CPPUNIT_TEST ( testMultiplier ) ;
CPPUNIT_TEST_SUITE_END ( ) ;
} ;
void VclMapModeTest : : testMultiplier ( )
{
MapMode aMapMode ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Default map mode is MapUnit::MapPixel, multiplier should be 1 " , 1.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : MapSysFont ) ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::MapSysFont, multiplier should be 1 " , 1.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : MapAppFont ) ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::MapAppFont, multiplier should be 1 " , 1.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : Map100thMM ) ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::Map100thMM, multiplier should be 1 " , 1.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : Map10thMM ) ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::Map10thMM, multiplier should be 10 " , 10.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : MapMM ) ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::MapMM, multiplier should be 100 " , 100.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : MapCM ) ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::MapCM, multiplier should be 1000 " , 1000.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : Map1000thInch ) ;
2016-10-06 16:34:21 +02:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::Map1000thInch, multiplier should be 2.54 " , 2.54 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : Map100thInch ) ;
2016-10-06 16:34:21 +02:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::Map100thInch, multiplier should be 2.54 " , 25.4 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : Map10thInch ) ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::Map10thInch, multiplier should be 254 " , 254.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : MapInch ) ;
2016-12-22 09:11:47 +01:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::MapInch, multiplier should be 2540 " , 2540.0 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : MapTwip ) ;
2016-10-06 16:34:21 +02:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::MapTwip, multiplier should be 1.76388889 " , 1.76388889 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-09-20 16:41:39 +02:00
aMapMode . SetMapUnit ( MapUnit : : MapPoint ) ;
2016-10-06 16:34:21 +02:00
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE ( " Map mode is MapUnit::MapPoint, multiplier should be 35.27777778 " , 35.27777778 , aMapMode . GetUnitMultiplier ( ) , 1E-12 ) ;
2016-02-13 16:08:01 +11:00
}
CPPUNIT_TEST_SUITE_REGISTRATION ( VclMapModeTest ) ;
CPPUNIT_PLUGIN_IMPLEMENT ( ) ;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */