LCOV - code coverage report
Current view: top level - vcl/qa/cppunit - complextext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 23 23 100.0 %
Date: 2015-06-13 12:38:46 Functions: 13 14 92.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <unotest/filters-test.hxx>
      11             : #include <test/bootstrapfixture.hxx>
      12             : 
      13             : #include <vcl/wrkwin.hxx>
      14             : 
      15             : #include <osl/file.hxx>
      16             : #include <osl/process.h>
      17             : 
      18           2 : class VclComplexTextTest : public test::BootstrapFixture
      19             : {
      20             : public:
      21           1 :     VclComplexTextTest() : BootstrapFixture(true, false) {}
      22             : 
      23             :     /// Play with font measuring etc.
      24             :     void testArabic();
      25             : 
      26           2 :     CPPUNIT_TEST_SUITE(VclComplexTextTest);
      27           1 :     CPPUNIT_TEST(testArabic);
      28           5 :     CPPUNIT_TEST_SUITE_END();
      29             : };
      30             : 
      31           1 : void VclComplexTextTest::testArabic()
      32             : {
      33             : #if !defined (LINUX)
      34             :     return;
      35             : #else // only tested on Linux so far
      36             :     const unsigned char pOneTwoThreeUTF8[] = {
      37             :         0xd9, 0x88, 0xd8, 0xa7, 0xd8, 0xad, 0xd9, 0x90,
      38             :         0xd8, 0xaf, 0xd9, 0x92, 0x20, 0xd8, 0xa5, 0xd8,
      39             :         0xab, 0xd9, 0x8d, 0xd9, 0x86, 0xd9, 0x8a, 0xd9,
      40             :         0x86, 0x20, 0xd8, 0xab, 0xd9, 0x84, 0xd8, 0xa7,
      41             :         0xd8, 0xab, 0xd8, 0xa9, 0xd9, 0x8c, 0x00
      42           1 :     };
      43             :     OUString aOneTwoThree( reinterpret_cast<char const *>(pOneTwoThreeUTF8),
      44             :                            SAL_N_ELEMENTS( pOneTwoThreeUTF8 ) - 1,
      45           1 :                            RTL_TEXTENCODING_UTF8 );
      46           2 :     VclPtr<vcl::Window> pWin = VclPtr<WorkWindow>::Create( static_cast<vcl::Window *>(nullptr) );
      47           1 :     CPPUNIT_ASSERT( pWin );
      48             : 
      49           1 :     OutputDevice *pOutDev = static_cast< OutputDevice * >( pWin.get() );
      50             : 
      51             :     vcl::Font aFont = OutputDevice::GetDefaultFont(
      52             :                         DefaultFontType::CTL_SPREADSHEET,
      53             :                         LANGUAGE_ARABIC_SAUDI_ARABIA,
      54           2 :                         GetDefaultFontFlags::OnlyOne, 0 );
      55           1 :     pOutDev->SetFont( aFont );
      56             : 
      57             :     // normal orientation
      58           1 :     Rectangle aInput;
      59           1 :     Rectangle aRect = pOutDev->GetTextRect( aInput, aOneTwoThree );
      60             : 
      61             :     // now rotate 270 degress
      62           2 :     vcl::Font aRotated( aFont );
      63           1 :     aRotated.SetOrientation( 2700 );
      64           1 :     pOutDev->SetFont( aRotated );
      65           1 :     Rectangle aRectRot = pOutDev->GetTextRect( aInput, aOneTwoThree );
      66             : 
      67             :     // Check that we did do the rotation ...
      68             : #if 0
      69             :     fprintf( stderr, "%ld %ld %ld %ld\n",
      70             :              aRect.GetWidth(), aRect.GetHeight(),
      71             :              aRectRot.GetWidth(), aRectRot.GetHeight() );
      72             :     CPPUNIT_ASSERT( aRectRot.GetWidth() == aRect.GetHeight() );
      73             :     CPPUNIT_ASSERT( aRectRot.GetHeight() == aRect.GetWidth() );
      74             : #else
      75           1 :     (void)aRect; (void)aRectRot;
      76             : #endif
      77             : #endif
      78           1 : }
      79             : 
      80           1 : CPPUNIT_TEST_SUITE_REGISTRATION(VclComplexTextTest);
      81             : 
      82           4 : CPPUNIT_PLUGIN_IMPLEMENT();
      83             : 
      84             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11