os/textandloc/fontservices/textshaperplugin/test/t_shapeteststep.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/test/t_shapeteststep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1042 @@
     1.4 +/*
     1.5 +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +#include <e32math.h>
    1.22 +#include <fbs.h>
    1.23 +#include <badesca.h>
    1.24 +#include <ecom/ecom.h>
    1.25 +#include <ecom/implementationproxy.h>
    1.26 +#include <graphics/shapeimpl.h>
    1.27 +#include <graphics/openfontrasterizer.h>
    1.28 +#include <graphics/openfontconstants.h>
    1.29 +
    1.30 +#include "testData.h"
    1.31 +#include "t_shapeteststep.h"
    1.32 +
    1.33 +#define test(cond)                                          \
    1.34 +    {                                                       \
    1.35 +    TBool __bb = (cond);                                    \
    1.36 +    TEST(__bb);                                             \
    1.37 +    if (!__bb)                                              \
    1.38 +        {                                                   \
    1.39 +        ERR_PRINTF1(_L("ERROR: Test Failed"));              \
    1.40 +        User::Leave(1);                                     \
    1.41 +        }                                                   \
    1.42 +    }
    1.43 +
    1.44 +//add filenames for any test data here
    1.45 +const TText16* KTestFilenames[] =
    1.46 +    {
    1.47 +    //created from original iculayoutengine test data
    1.48 +    (const TText16*) L"z:\\test\\data\\tnr_dev_otshaperdata1.dat",
    1.49 +    //created from input data provided by licensee
    1.50 +    (const TText16*) L"z:\\test\\data\\tnr_dev_otshaperdata2.dat",
    1.51 +    //created from input data provided by licensee
    1.52 +    (const TText16*) L"z:\\test\\data\\tnr_dev_otshaperdata3.dat",
    1.53 +    //created from input data provided by licensee
    1.54 +    (const TText16*) L"z:\\test\\data\\tnr_dev_otshaperdata4.dat",
    1.55 +    // Data to test defect fix DEF078032
    1.56 +    (const TText16*) L"z:\\test\\data\\tnr_dev_otshaperdata5.dat",
    1.57 +    //created from input data provided by licensee
    1.58 +    (const TText16*) L"z:\\test\\data\\shaperkannadadata1.dat",
    1.59 +    // created from Kannada sample text
    1.60 +    (const TText16*) L"z:\\test\\data\\shaperkannadadata2.dat",
    1.61 +    // created from Kannada sample text
    1.62 +    (const TText16*) L"z:\\test\\data\\shaperkannadadata3.dat",
    1.63 +    // created from Gujarati sample text taken from the web
    1.64 +    (const TText16*) L"z:\\test\\data\\shapergujaratidata1.dat",
    1.65 +    // created from Gujarati sample text taken from the web
    1.66 +    (const TText16*) L"z:\\test\\data\\shapergujaratidata2.dat",
    1.67 +    // created from Gujarati sample text given by the licensee
    1.68 +    (const TText16*) L"z:\\test\\data\\shapergujaratidata3.dat",
    1.69 +    // created from Bengali sample text given by the licensee
    1.70 +    (const TText16*) L"z:\\test\\data\\shaperbengalidata1.dat",
    1.71 +    // created from Bengali sample text given by the licensee
    1.72 +    (const TText16*) L"z:\\test\\data\\shaperbengalidata2.dat",
    1.73 +    // created from Bengali sample text given by the licensee
    1.74 +    (const TText16*) L"z:\\test\\data\\shaperbengalidata3.dat",
    1.75 +    // created from Tamil sample text given by the licensee
    1.76 +    (const TText16*) L"z:\\test\\data\\shapertamildata1.dat",
    1.77 +    // created from Tamil sample text given by the licensee
    1.78 +    (const TText16*) L"z:\\test\\data\\shapertamildata2.dat",
    1.79 +    // created from Tamil sample text given by the licensee
    1.80 +    (const TText16*) L"z:\\test\\data\\shapertamildata3.dat",
    1.81 +    // created from Telugu sample text given by the licensee
    1.82 +    (const TText16*) L"z:\\test\\data\\shapertelugudata1.dat",
    1.83 +    // created from Telugu sample text given by the licensee
    1.84 +    (const TText16*) L"z:\\test\\data\\shapertelugudata2.dat",
    1.85 +    // created from Telugu sample text given by the licensee
    1.86 +    (const TText16*) L"z:\\test\\data\\shapertelugudata3.dat",
    1.87 +    //  Test for Gurmukhi digit
    1.88 +    (const TText16*) L"z:\\test\\data\\shapergurmukhi1.dat",
    1.89 +    (const TText16*) L"z:\\test\\data\\shapergurmukhi2.dat",
    1.90 +    (const TText16*) L"z:\\test\\data\\shapergurmukhi3.dat",
    1.91 +    (const TText16*) L"z:\\test\\data\\shapergurmukhi4.dat",
    1.92 +    (const TText16*) L"z:\\test\\data\\shapergurmukhi5.dat",
    1.93 +    //  Test for Malayalam digit
    1.94 +    (const TText16*) L"z:\\test\\data\\shapermalayalam1.dat",
    1.95 +    (const TText16*) L"z:\\test\\data\\shapermalayalam2.dat",
    1.96 +    (const TText16*) L"z:\\test\\data\\shapermalayalam3.dat",
    1.97 +    (const TText16*) L"z:\\test\\data\\shapermalayalam4.dat",
    1.98 +    (const TText16*) L"z:\\test\\data\\shapermalayalam5.dat"
    1.99 +    };
   1.100 +
   1.101 +/**
   1.102 +Number of test data files of each of the scripts/languages bein tests.
   1.103 +Must change these if KTestFilnames[] above is changed
   1.104 +*/
   1.105 +const TInt KHindiTestDataIndex = 0;
   1.106 +const TInt KNumberOfHindiTestDataFiles = 5;
   1.107 +const TInt KKannadaTestDataIndex = 5;
   1.108 +const TInt KNumberOfKannadaTestDataFiles = 3;
   1.109 +const TInt KGujaratiTestDataIndex = 8;
   1.110 +const TInt KNumberOfGujaratiTestDataFiles = 3;
   1.111 +const TInt KBengaliTestDataIndex = 11;
   1.112 +const TInt KNumberOfBengaliTestDataFiles = 3;
   1.113 +const TInt KTamilTestDataIndex = 14;
   1.114 +const TInt KNumberOfTamilTestDataFiles = 3;
   1.115 +const TInt KTeluguTestDataIndex = 17;
   1.116 +const TInt KNumberOfTeluguTestDataFiles = 3;
   1.117 +const TInt KGurmukhiTestDataIndex = 20;
   1.118 +const TInt KNumberOfGurmukhiTestDataFiles = 5;
   1.119 +const TInt KMalayalamTestDataIndex = 25;
   1.120 +const TInt KNumberOfMalayalamTestDataFiles = 5;
   1.121 +    
   1.122 +const TUint32 KDevanagariScriptCode = 0x64657661;
   1.123 +const TUint32 KKannadaScriptCode = 0x6B6E6461;
   1.124 +const TUint32 KHindiLanguageCode = 0x48494E20;
   1.125 +const TUint32 KKannadaLanguageCode = 0x4B414E20;
   1.126 +const TUint32 KGujaratiScriptCode = 0x67756A72;
   1.127 +const TUint32 KGujaratiLanguageCode = 0x47554A20;
   1.128 +const TUint32 KBengaliScriptCode = 0x62656E67;
   1.129 +const TUint32 KBengaliLanguageCode = 0x42454E20;
   1.130 +const TUint32 KTamilScriptCode = 0x74616D6C;
   1.131 +const TUint32 KTamilLanguageCode = 0x54414D20;
   1.132 +const TUint32 KTeluguScriptCode = 0x74656C75;
   1.133 +const TUint32 KTeluguLanguageCode = 0x54454C20;
   1.134 +const TUint32 KGurmukhiScriptCode = 0x67757275;
   1.135 +const TUint32 KGurmukhiLanguageCode = 0;
   1.136 +const TUint32 KMalayalamScriptCode = 0x6d6c796d;
   1.137 +const TUint32 KMalayalamLanguageCode = 0x4d4c5220;
   1.138 +
   1.139 +_LIT(KTestStep_Hindi, "Hindi");
   1.140 +_LIT(KTestStep_Kannada, "Kannada");
   1.141 +_LIT(KTestStep_Gujarati, "Gujarati");
   1.142 +_LIT(KTestStep_Bengali, "Bengali");
   1.143 +_LIT(KTestStep_Tamil, "Tamil");
   1.144 +_LIT(KTestStep_Telugu, "Telugu");
   1.145 +_LIT(KTestStep_Gurmukhi, "Gurmukhi");
   1.146 +_LIT(KTestStep_Malayalam, "Malayalam");
   1.147 +
   1.148 +_LIT16(KHindi1,"\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020\x0909\x0926\x094D\x0926\x0947\x0936\x094D\x0020\x0915\x094D\x0937\x093F\x092A\x094D\x0930");
   1.149 +_LIT16(KHindi2,"\x092d\x0942\x0930\x094d\x092d\x0941\x0935\x0903\x0020\x0938\x094d\x0935\x0903\x0020\x0924\x0924\x094d\x0938\x0935\x093f\x0924\x0941\x0930\x094d\x0935\x0930\x0947\x0923\x094d\x092f\x0902");
   1.150 +_LIT16(KHindi3,"\x092d\x0930\x094d\x0917\x094b\x0020\x0926\x0947\x0935\x0938\x094d\x092f\x0020\x0927\x0940\x092e\x0939\x093f\x0020\x0927\x093f\x092f\x094b\x0020\x092f\x094b\x0928\x0903\x0020\x092a\x094d\x0930\x091a\x094b\x0926\x092f\x093e\x0924\x094d\x0020");
   1.151 +
   1.152 +_LIT16(KKannada1,"\x0CB6\x0CCD\x0CB0\x0CC0\x0020\x0CAD\x0C97\x0CB5\x0CBE\x0CA8\x0CC1\x0CB5\x0CBE\x0C9A\x0C95\x0CC1\x0CA4\x0CB8\x0CCD\x0CA4\x0CCD\x0CB5\x0CBE\x0020\x0C95\x0CB6\x0CCD\x0CAE\x0CB2\x0CAE\x0CBF\x0CA6\x0C82\x0020\x0CB5\x0CBF\x0CB7\x0CAE\x0020\x0CB8\x0CAE\x0CC1\x0CAA\x0CB8\x0CCD\x0CA5\x0CBF\x0CA4\x0CAE\x0CCD");
   1.153 +_LIT16(KKannada2,"\x0C85\x0CA8\x0CBE\x0CB0\x0CCD\x0CAF\x0C9C\x0CC1\x0CB7\x0CCD\x0CA0\x0CAE\x0CB8\x0CCD\x0CB5\x0CB0\x0CCD\x0C97\x0CCD\x0CAF\x0CAE\x0C95\x0CC0\x0CB0\x0CCD\x0CA4\x0CBF\x0C95\x0CB0\x0CAE\x0CB0\x0CCD\x0C9C\x0CC1\x0CA8");
   1.154 +_LIT16(KKannada3,"\x0C95\x0CCD\x0CB2\x0CC8\x0CAC\x0CCD\x0CAF\x0C82\x0020\x0CAE\x0CBE\x0020\x0CB8\x0CCD\x0CAE\x0020\x0C97\x0CAE\x0C83\x0020\x0CAA\x0CBE\x0CB0\x0CCD\x0CA5\x0020\x0CA8\x0CC8\x0CA4\x0CA4\x0CCD\x0CA4\x0CCD\x0CB5\x0CAF\x0CCD\x0CAF\x0CC1\x0CAA\x0CAA\x0CA7\x0CCD\x0CAF\x0CA4\x0CC7");
   1.155 +
   1.156 +_LIT16(KGujarati1,"\x0AAD\x0ABE\x0AB5\x0ABE\x0AA4\x0ACD\x0AAE\x0A95\x0020\x0AAA\x0AA6\x0ACD\x0AAF\x0ABE\x0AA8\x0AC1\x0AB5\x0ABE\x0AA6\x0020\x0020\x002D\x0020\x0AB6\x0ACD\x0AB0\x0AC0\x0020\x0AAF\x0ACB\x0A97\x0AC7\x0AB6\x0ACD\x0AB5\x0AB0\x0A9C\x0AC0");
   1.157 +_LIT16(KGujarati2,"\x0AB5\x0ABF\x0AA8\x0ACD\x0AA1\x0ACB\x0A9D\x0020\x0AB5\x0ABF\x0AB8\x0ACD\x0A9F\x0ABE\x0020\x002D\x0020\x0A86\x0A82\x0AA4\x0AB0\x0AB0\x0ABE\x0AB7\x0ACD\x0A9F\x0ACD\x0AB0\x0ABF\x0AAF\x0A95\x0AB0\x0AA3\x0020\x0AB5\x0ABF\x0AB6\x0AC7\x0AA8\x0AC0\x0020\x0A9C\x0ABE\x0AA3\x0A95\x0ABE\x0AB0\x0AC0");
   1.158 +_LIT16(KGujarati3,"\x0AAE\x0ABE\x0A88\x0A95\x0ACD\x0AB0\x0ACB\x0AB8\x0ACB\x0AAB\x0ACD\x0A9F\x0AA8\x0ABE\x0020\x0A86\x0020\x0A86\x0A82\x0AA4\x0AB0\x0AB0\x0ABE\x0AB7\x0ACD\x0A9F\x0ACD\x0AB0\x0ABF\x0AAF\x0020\x0AAA\x0ACB\x0AB0\x0ACD\x0A9F\x0AB2\x0020\x0AB5\x0ABF\x0AB6\x0AC7\x0020\x0AB5\x0AA7\x0AC1\x0020\x0A9C\x0ABE\x0AA3\x0ACB\x002E\x0020\x0AB5\x0ABF\x0AB8\x0ACD\x0A9F\x0ABE\x0A8F\x0020\x0AA6\x0AC1\x0AA8\x0ABF\x0AAF\x0ABE\x0AAD\x0AB0\x0AA8\x0AC0\x0020\x0AAD\x0ABE\x0AB7\x0ABE\x0A93\x0020\x0AAE\x0ABE\x0A9F\x0AC7\x0020\x0AA6\x0ACD\x0AB5\x0ABE\x0AB0\x0020\x0A96\x0ACB\x0AB2\x0AC0\x0020\x0AA8\x0ABE\x0A96\x0ACD\x0AAF\x0ABE\x0020\x0A9B\x0AC7");
   1.159 +
   1.160 +_LIT16(KBengali1,"\x099C\x09A8\x0997\x09A3\x09AE\x09A8\x0020\x0985\x09A7\x09BF\x09A8\x09BE\x09AF\x09BC\x0995\x0020\x099C\x09AF\x09BC\x0020\x09B9\x09C7\x0020\x09AD\x09BE\x09B0\x09A4\x0020\x09AD\x09BE\x0997\x09CD\x09AF\x0020\x09AC\x09BF\x09A7\x09BE\x09A4\x09BE\x0020\x09AA\x099E\x09CD\x099C\x09BE\x09AC\x0020\x09B8\x09BF\x09A8\x09CD\x09A7\x09C1\x0020");
   1.161 +_LIT16(KBengali2,"\x0997\x09C1\x099C\x09B0\x09BE\x099F\x0020\x09AE\x09B0\x09BE\x09A0\x09BE\x0020\x09A6\x09CD\x09B0\x09BE\x09AC\x09BF\x09A1\x09BC\x0020\x0989\x09A4\x09CD\x0995\x09B2\x0020\x09AC\x0999\x09CD\x0997\x0020\x09AC\x09BF\x09A8\x09CD\x09A7\x09CD\x09AF\x0020\x09B9\x09BF\x09AE\x09BE\x099A\x09B2\x0020\x09AF\x09AE\x09C1\x09A8\x09BE\x0020\x0997\x0999\x09CD\x0997\x09BE\x0020");
   1.162 +_LIT16(KBengali3,"\x0989\x099A\x09CD\x099B\x09B2\x0020\x099C\x09B2\x09A7\x09BF\x0020\x09A4\x09B0\x0999\x09CD\x0997\x0020\x09A4\x09AC\x0020\x09B6\x09C1\x09AD\x0020\x09A8\x09BE\x09AE\x09C7\x0020\x099C\x09BE\x0997\x09C7\x0020\x09A4\x09AC\x0020\x09B6\x09C1\x09AD\x0020\x0986\x09B6\x09BF\x09B8\x0020\x09AE\x09BE\x0997\x09C7\x0020\x0997\x09BE\x09B9\x09C7\x0020\x09A4\x09AC\x0020\x099C\x09AF\x09BC\x0020");
   1.163 +
   1.164 +_LIT16(KTamil1,"\x0B89\x0BA3\x0BCD\x0BA3\x0020\x0BAE\x0BC1\x0B9F\x0BBF\x0BAF\x0BBE\x0BA4\x0020\x0BB5\x0BCB\x0BA4\x0BA8\x0BC0\x0BB0\x0BCD\x0020\x0BB5\x0BBE\x0BA9\x0BCD\x0BB5\x0BBE\x0BAF\x0BCD\x0BAA\x0BCD\x0BAA\x0B9F\x0BCD\x0020");
   1.165 +_LIT16(KTamil2,"\x0B86\x0BA9\x0BCD\x0BB1\x0BB5\x0BC1\x0BAF\x0BBF\x0BB0\x0BCD\x0020\x0B88\x0BB0\x0BBE\x0BB1\x0BC1\x0BAE\x0BCD\x0020\x0B90\x0B99\x0BCD\x0B95\x0BC1\x0BB1\x0BBF\x0BB2\x0BCD\x0020\x0B8F\x0BB4\x0BCD\x0BA8\x0BC6\x0B9F\x0BBF\x0BB2\x0BBE\x0BAE\x0BCD\x0020");
   1.166 +_LIT16(KTamil3,"\x0BAE\x0BC1\x0BAE\x0BCD\x0BAE\x0BC8\x0BAF\x0BBF\x0B9F\x0BA4\x0BCD\x0020\x0BA4\x0BC8\x0BAF\x0BCC\x0BB5\x0BC1\x0B99\x0BCD\x0020\x0B95\x0BC1\x0BA9\x0BCD\x0BB1\x0BC1\x0BAE\x0BC1\x0BA9\x0BCD\x0020\x0BA9\x0BCA\x0BB1\x0BCD\x0BB1\x0BC1\x0BA3\x0BCD\x0B9F\x0BC7\x0BB1\x0BCD");
   1.167 +
   1.168 +_LIT16(KTelugu1,"\x0C05\x0C2A\x0C4D\x0C30\x0C15\x0C3E\x0C36\x0C4B\x093D\x0C2A\x0C4D\x0C30\x0C35\x0C43\x0C24\x0C4D\x0C24\x0C3F\x0C36\x0C4D\x0C1A\x0020\x0C2A\x0C4D\x0C30\x0C2E\x0C3E\x0C26\x0C4B\x0020\x0C0A\x0C30\x0C4D\x0C27\x0C4D\x0C35\x0C02");
   1.169 +_LIT16(KTelugu2,"\x0C15\x0C48\x0C30\x0C4D\x0C32\x0C3F\x0C19\x0C4D\x0C17\x0C48\x0C38\x0C4D\x0C24\x0C4D\x0C30\x0C40\x0C28\x0C4D\x0C17\x0C41\x0C23\x0C3E\x0C28\x0C47\x0C24\x0C3E\x0C28\x0C24\x0C40\x0C24\x0C4B\x0020\x0C17\x0C41\x0C23\x0C48\x0C30\x0C4D\x0C2F");
   1.170 +_LIT16(KTelugu3,"\x0020\x0C2C\x0C4D\x0C30\x0C39\x0C4D\x0C2E\x0C23\x0C4B\x0020\x0C39\x0C3F\x0020\x0C2A\x0C4D\x0C30\x0C24\x0C3F\x0C37\x0C4D\x0C20\x0C3E\x0C39\x0C2E\x0C2E\x0C43\x0C24\x0C38\x0C4D\x0C2F\x0C3E\x0C35\x0C4D\x0C2F\x0C2F\x0C38\x0C4D\x0C2F");
   1.171 +
   1.172 +_LIT16(KGurmukhi1,"\x0a28\x0a2e\x0a38\x0a15\x0a3e\x0a30\x0a26\x0a\x3e\x0a28\x0a3f\x0a1a\x0a3f\x0a70\x0a26\x0a41\x0020\x0a28\x0a3f\x0a17\x0a4d\x0a30\x0a39\x0a3f\x0a2a\x0a70\x0a16\x0a40\x0a05\x0a32\x0a4b\x0a2a\x0a70\x0a16\x0a40\x0a05\x0a32\x0a4b\x0a2a\x0a30\x0a09\x0a2a\x0a15\x0a3e\x0a30\x0a3f\x0a06\x0a2a\x0a4d\x0a30\x0a24\x0a3e\x0a2a\x0a3f");
   1.173 +_LIT16(KGurmukhi2,"\x0a2a\x0a4d\x0a30\x0a24\x0a3f\x0a2a\x0a3e\x0a32\x0a47\x0020\x0a2a\x0a4d\x0a30\x0a2c\x0a32\x0a1a\x0a70\x0a21\x0a2b\x0a3f\x0a30\x0a70\x0a28\x0a4d\x0a39\x0a4d\x0a39\x0a3f\x0020\x0a2b\x0a41\x0a32\x0a35\x0a24\x0a2c\x0a4d\x0a30\x0a3f\x0a25\x0a3e\x0a2c\x0a4d\x0a30\x0a39\x0a2e\x0a3e\x0a26\x0a3f\x0020\x0a2c\x0a3e\x0a1b\x0a30\x0a2c\x0a3f\x0a38\x0a4d\x0a35\x0a70\x0a2d\x0a30\x0a2d\x0a4d\x0a30\x0a2e\x0a39\x0a41\x0a2d\x0a2f\x0a4b\x0a2d\x0a17\x0a35\x0a70\x0a24");
   1.174 +_LIT16(KGurmukhi3,"\x0a2e\x0a3e\x0a23\x0a40\x0a06\x0a2e\x0a4b\x0a24\x0a38\x0a30\x0a40\x0a06\x0a2f\x0a3e\x0a28\x0a5c\x0a40\x0a0f\x0a2f\x0a15\x0a40\x0a28\x0a3e\x0a30\x0a35\x0a3f\x0a70\x0a26\x0a41\x0020\x0a30\x0a2a\x0a38\x0a40\x0a32\x0a17\x0a3e\x0a35\x0a23\x0a3f\x0a06\x0a32\x0a4b\x0a5c\x0a40\x0a05\x0a39\x0a3f\x0a35\x0a30\x0a28\x0a41\x0a35\x0a40\x0a06\x0a39\x0a3f\x0a06\x0a5c\x0a5c\x0a15\x0a3f\x0a28\x0a2e\x0a38\x0a15\x0a3e\x0a30\x0a26\x0a3e\x0a28\x0a3f\x0a1a\x0a3f\x0a70\x0a26\x0a41\x0020");
   1.175 +
   1.176 +_LIT16(KMalayalam1,"\xd09\xd28\xd4d\xd28\xd2f\xd3f\xd1a\xd4d\xd1a\xd4d\x200c\xd26\xd47\xd36\xd40\xd2f\xd07\xd1f\xd24\xd41\xd2a\xd15\xd4d\xd37\xd1f\xd4d\xd30\xd47\xd21\xd4d\x200c\xd2f\xd42\xd23\xd3f\xd2f\xd28\xd4d\x200d\xd05\xd2d\xd3f\xd28\xd28\xd4d");
   1.177 +_LIT16(KMalayalam2,"\xd2a\xd23\xd3f\xd2e\xd41\xd1f\xd15\xd4d\xd15\xd4d\x200c\xd2a\xd42\xd30\xd4d\x200d");
   1.178 +_LIT16(KMalayalam3,"\xd23\xd02\xd24\xd40\xd35\xd23\xd4d\xd1f\xd3f\xd15\xd33\xd4d\x200d\xd31\xd26\xd4d\xd26\xd3e\xd15\xd4d\xd15\xd3f\xd15\xd4b\xd34\xd3f\xd15\xd4d\xd15\xd4b\xd1f\xd4d\x200c\xd35\xd3f\xd35\xd3f\xd27\xd06\xd35\xd36\xd4d\xd2f\xd19\xd4d\xd19\xd33\xd4d\x200d");
   1.179 +
   1.180 +CShapeTestStep::CShapeTestStep(TInt aTestDataIndex, TInt aNumberOfTestDataFiles, 
   1.181 +        TUint32 aScript, TUint32 aLang, const TDesC& aScriptName, const TDesC& aTestID)
   1.182 +    : iTestDataIndex(aTestDataIndex), iNumberOfTestDataFiles(aNumberOfTestDataFiles), 
   1.183 +      iScript(aScript), iLang(aLang), iScriptName(aScriptName), iTestID(aTestID)
   1.184 +    {
   1.185 +    SetTestStepName(aScriptName);
   1.186 +    }
   1.187 +
   1.188 +// Convenience methods
   1.189 +//**************************************************************************************
   1.190 +
   1.191 +/* 
   1.192 +Used for cleanup of RImplInfoArray implementationArray below 
   1.193 +This method is stolen from FbsTop.cpp
   1.194 +*/
   1.195 +LOCAL_C void ResetAndDestroyRImplInfoPtrArray(TAny* aPtr)
   1.196 +    {
   1.197 +    RImplInfoPtrArray* array = reinterpret_cast <RImplInfoPtrArray*> (aPtr);
   1.198 +    array->ResetAndDestroy();
   1.199 +    }
   1.200 +    
   1.201 +/*
   1.202 +Load all ECOM implemented rasterizer DLLs. 
   1.203 +This method is stolen from CFbTop::LoadOpenFontLibraries()
   1.204 +*/
   1.205 +LOCAL_C void LoadOpenFontLibraries(CFontStore* aFontStore)
   1.206 +    {
   1.207 +    RImplInfoPtrArray implementationArray;
   1.208 +    TCleanupItem cleanup(ResetAndDestroyRImplInfoPtrArray, &implementationArray);
   1.209 +    CleanupStack::PushL(cleanup);
   1.210 +    TInt error;
   1.211 +    TInt ecomerror;
   1.212 +    TInt ecomnotready;
   1.213 +    TUid uid = {KUidOpenFontRasterizerPlunginInterface};
   1.214 +
   1.215 +    // Making sure that no race situation arises
   1.216 +    // If ECom is not ready, give it another chance and try again. if it still doesn't work 
   1.217 +    // after the third try, then it just carries on quietly and fails... 
   1.218 +    for (ecomnotready =0; ecomnotready <3; ecomnotready++)
   1.219 +        {
   1.220 +        TRAP(ecomerror,REComSession::ListImplementationsL(uid,implementationArray));
   1.221 +        if (!ecomerror)
   1.222 +            {
   1.223 +            break;
   1.224 +            }
   1.225 +        else
   1.226 +            {
   1.227 +            ecomerror = 0;  
   1.228 +            User::After(0);
   1.229 +            }
   1.230 +        }
   1.231 +
   1.232 +    const TInt availCount = implementationArray.Count();
   1.233 +    for (TInt count=0;count<availCount;++count)
   1.234 +        {
   1.235 +        const CImplementationInformation* info = implementationArray[count];
   1.236 +        TUid rasterizerUid = info->ImplementationUid();
   1.237 +        // Create a rasterizer
   1.238 +        COpenFontRasterizer* rasterizer=0;
   1.239 +        TRAP(error,rasterizer = COpenFontRasterizer::NewL(rasterizerUid));
   1.240 +        if (!error)
   1.241 +            {
   1.242 +            // Install it in the font store.
   1.243 +            TRAP(error,aFontStore->InstallRasterizerL(rasterizer));
   1.244 +            if (error)
   1.245 +                delete rasterizer;
   1.246 +            }
   1.247 +        }
   1.248 +    CleanupStack::PopAndDestroy(&implementationArray);
   1.249 +    }
   1.250 +    
   1.251 +void CShapeTestStep::SetupTestDataL()    
   1.252 +    {
   1.253 +    //set up the testData variables
   1.254 +    CDesC16ArrayFlat* testDataFilenames = new CDesC16ArrayFlat(2);
   1.255 +    CleanupStack::PushL(testDataFilenames);
   1.256 +    
   1.257 +    for (TInt i = 0; i != sizeof(KTestFilenames)/sizeof(KTestFilenames[0]); ++i)
   1.258 +        {
   1.259 +        TPtrC16 d(KTestFilenames[i]);
   1.260 +        testDataFilenames->AppendL(d);
   1.261 +        }
   1.262 +    
   1.263 +    for (TInt i = 0; i<testDataFilenames->Count(); i++)
   1.264 +        {
   1.265 +        CTestData* temp = new(ELeave) CTestData;
   1.266 +        temp->Internalize((*testDataFilenames)[i]);
   1.267 +        iTestDataArr.AppendL(temp);
   1.268 +        }
   1.269 +    
   1.270 +    CleanupStack::PopAndDestroy(1);     //testDataFilenames
   1.271 +    }
   1.272 +    
   1.273 +    
   1.274 +// test methods
   1.275 +//**************************************************************************************
   1.276 +
   1.277 +/**
   1.278 +@file
   1.279 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-1479
   1.280 +@SYMTestCaseDesc            Simple test of the shaper
   1.281 +@SYMTestPriority            High
   1.282 +@SYMTestActions             Simple test to shape some text using the shaper, and test that the output is as expected. Does not perform any OOM testing.
   1.283 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.284 +@SYMPREQ                    PREQ18
   1.285 +*/
   1.286 +void CShapeTestStep::doShapeText(CBitmapFont* font, CTestData& aTestData, TBool aCheckOutput)
   1.287 +    {
   1.288 +    INFO_PRINTF1(_L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-1479 "));
   1.289 +
   1.290 +    //set up the shaper
   1.291 +    CShaper* theShaper = NULL;
   1.292 +    CShaperFactory* shaperFactory = NULL;
   1.293 +
   1.294 +    RImplInfoPtrArray implementationArray;
   1.295 +    TCleanupItem cleanup(ResetAndDestroyRImplInfoPtrArray, &implementationArray);
   1.296 +    CleanupStack::PushL(cleanup);
   1.297 +    TInt ecomerror;
   1.298 +    TInt ecomnotready;
   1.299 +    TUid uid = {KUidShaperFactoryPlunginInterface};
   1.300 +
   1.301 +    // Making sure that no race situation arises between FBserv and Ecom
   1.302 +    // If ECom is not ready, give it another chance and try again. if it still doesn't work 
   1.303 +    // after the third try, then it just carries on quietly and fails... 
   1.304 +    for (ecomnotready =0; ecomnotready <3; ecomnotready++)
   1.305 +        {
   1.306 +
   1.307 +        TRAP(ecomerror,REComSession::ListImplementationsL(uid,implementationArray));
   1.308 +        if (!ecomerror)
   1.309 +            {
   1.310 +            break;
   1.311 +            }
   1.312 +        else
   1.313 +            {
   1.314 +            ecomerror = 0;  
   1.315 +            User::After(0);
   1.316 +            }
   1.317 +        }
   1.318 +
   1.319 +    const TInt availCount = implementationArray.Count();
   1.320 +    for (TInt count=0;count<availCount;++count)
   1.321 +        {
   1.322 +        const CImplementationInformation* info = implementationArray[count];
   1.323 +        TUid shaperFactoryUid = info->ImplementationUid();
   1.324 +        // Create a shaper factory
   1.325 +        TInt error;
   1.326 +        TRAP(error,shaperFactory = CShaperFactory::NewL(shaperFactoryUid));
   1.327 +        test(error == KErrNone);
   1.328 +        // Create a shaper
   1.329 +        TRAP(error, theShaper = shaperFactory->NewShaperL(font, iScript, iLang, &User::Heap()));
   1.330 +        if (error != KErrNone)
   1.331 +            {
   1.332 +            delete shaperFactory;
   1.333 +            shaperFactory = NULL;
   1.334 +            }
   1.335 +        test(error == KErrNone);
   1.336 +        break; // have got valid shaper here
   1.337 +        }
   1.338 +    CleanupStack::PopAndDestroy(&implementationArray);
   1.339 +
   1.340 +    CleanupStack::PushL(shaperFactory);
   1.341 +    CleanupStack::PushL(theShaper);
   1.342 +
   1.343 +    // create the data to be shaped
   1.344 +    // this uses hindiTestData, defined in testData.h
   1.345 +    CShaper::TInput input;
   1.346 +    input.iText = aTestData.iTextInput;
   1.347 +    input.iStart = aTestData.iStart;
   1.348 +    input.iEnd = aTestData.iEnd;
   1.349 +
   1.350 +    TInt textLength = input.iText->Length();
   1.351 +
   1.352 +    //create shape header, and shape the text
   1.353 +    TShapeHeader* output = NULL;
   1.354 +    TInt err = theShaper->ShapeText(output, input, &User::Heap());
   1.355 +    test(err == KErrNone);
   1.356 +    CleanupStack::PopAndDestroy(theShaper);
   1.357 +    CleanupStack::PopAndDestroy(shaperFactory);
   1.358 +    REComSession::FinalClose();
   1.359 +
   1.360 +    CleanupStack::PushL(output);    
   1.361 +    
   1.362 +    if (aCheckOutput)
   1.363 +        {
   1.364 +        // check the contents of output
   1.365 +        TEST(output->iGlyphCount == aTestData.iGlyphCount);
   1.366 +        TEST(output->iCharacterCount == aTestData.iCharacterCount);
   1.367 +
   1.368 +        // First iGlyphCount * 4 bytes of the output buffer contain the glyph codes as 2byte values
   1.369 +        // Compare against expected.
   1.370 +        TInt i=0;
   1.371 +        TUint32* shapePtr32 = (reinterpret_cast<TUint32*>(&output->iBuffer[0]));
   1.372 +        for (i=0; i < output->iGlyphCount; i++)
   1.373 +            {
   1.374 +            TEST(*shapePtr32 == (*aTestData.iGlyphs)[i]);
   1.375 +            shapePtr32++;
   1.376 +            }
   1.377 +
   1.378 +        // next iGlyphCount * 4 bytes contain the postions in which the glyphs should be drawn, x and y axes.
   1.379 +        // Compare against expected
   1.380 +        TUint16* shapePtr16 = (reinterpret_cast<TUint16*>(shapePtr32));
   1.381 +        for (i=0; i < output->iGlyphCount*2; i++)
   1.382 +            {
   1.383 +            //check X or Y position
   1.384 +            TEST(*shapePtr16 == (*aTestData.iPositions)[i]);
   1.385 +            shapePtr16++;
   1.386 +            }
   1.387 +
   1.388 +        // check advance
   1.389 +        TEST(*shapePtr16 == aTestData.iAdvance.iX);
   1.390 +        shapePtr16++;
   1.391 +        TEST(*shapePtr16 == aTestData.iAdvance.iY);
   1.392 +        shapePtr16++;
   1.393 +
   1.394 +        // next iGlyphCount * 2 bytes contain the coresponding indices of this character in the original string.
   1.395 +        // Compare against expected
   1.396 +        for (i=0; i < output->iGlyphCount; i++)
   1.397 +            {
   1.398 +            TEST(*shapePtr16 == (*aTestData.iIndices)[i]);
   1.399 +            shapePtr16++;
   1.400 +            }
   1.401 +        }
   1.402 +    
   1.403 +    CleanupStack::PopAndDestroy(output);
   1.404 +    }
   1.405 +
   1.406 +void CShapeTestStep::shapeText(CBitmapFont* font, CTestData& aTestData, TBool aCheckOutput)
   1.407 +    {
   1.408 +    __UHEAP_MARK;
   1.409 +    TInt heapSizeAtStart = 0;
   1.410 +    User::Heap().AllocSize(heapSizeAtStart);
   1.411 +    
   1.412 +    INFO_PRINTF2(_L("Heap memory utilized is now %d\n"), heapSizeAtStart);
   1.413 +
   1.414 +    doShapeText(font, aTestData, aCheckOutput);
   1.415 +    // check the heap used by the shaper
   1.416 +    RHeap* heap = &User::Heap();
   1.417 +    heap->Check();
   1.418 +    TInt heapSizeAtEnd = 0;
   1.419 +    TInt heapCellsUsed = heap->AllocSize(heapSizeAtEnd);
   1.420 +    if (heapCellsUsed)
   1.421 +        {
   1.422 +        INFO_PRINTF2(_L("This test leaked %d\n"), heapSizeAtEnd - heapSizeAtStart);
   1.423 +        }
   1.424 +    __UHEAP_MARKEND;    
   1.425 +    }
   1.426 +
   1.427 +/**
   1.428 +@file
   1.429 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-1480
   1.430 +@SYMTestCaseDesc            Simple OOM test of shaper
   1.431 +@SYMTestPriority            High
   1.432 +@SYMTestActions             OOM testing for the shaper. Also ensures no leaks.
   1.433 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.434 +@SYMPREQ                    PREQ18
   1.435 +*/
   1.436 +void CShapeTestStep::oomShapeText(CBitmapFont* font, CTestData& aTestData)
   1.437 +    {
   1.438 +    __UHEAP_MARK;
   1.439 +    INFO_PRINTF1(_L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-1480 "));
   1.440 +    doOomShapeText(font,aTestData);     
   1.441 +    __UHEAP_MARKEND;
   1.442 +    }
   1.443 +
   1.444 +void CShapeTestStep::doOomShapeText(CBitmapFont* font, CTestData& aTestData)
   1.445 +    {
   1.446 +    TInt count = 0;
   1.447 +    TInt err = KErrNone;
   1.448 +    TInt heapCellsUsed, heapSizeAtEnd, heapSizeAtStart;
   1.449 +    CShaper* theShaper = NULL;  
   1.450 +    CShaperFactory* shaperFactory = NULL;
   1.451 +    TShapeHeader* output = NULL;
   1.452 +        
   1.453 +    User::Heap().AllocSize(heapSizeAtStart);
   1.454 +
   1.455 +    // create the data to be shaped
   1.456 +    CShaper::TInput input;
   1.457 +    input.iText = aTestData.iTextInput;
   1.458 +    input.iStart = aTestData.iStart;
   1.459 +    input.iEnd = aTestData.iEnd;
   1.460 +
   1.461 +    //set up shaper, shape, delete shaper in oom loop
   1.462 +    RImplInfoPtrArray implementationArray;
   1.463 +    TCleanupItem cleanup(ResetAndDestroyRImplInfoPtrArray, &implementationArray);
   1.464 +    CleanupStack::PushL(cleanup);
   1.465 +    TInt error;
   1.466 +    TInt ecomerror;
   1.467 +    TInt ecomnotready;
   1.468 +    TUid uid = {KUidShaperFactoryPlunginInterface};
   1.469 +
   1.470 +    // Making sure that no race situation arises between FBserv and Ecom
   1.471 +    // If ECom is not ready, give it another chance and try again. if it still doesn't work 
   1.472 +    // after the third try, then it just carries on quietly and fails... 
   1.473 +    for (ecomnotready =0; ecomnotready <3; ecomnotready++)
   1.474 +        {
   1.475 +
   1.476 +        TRAP(ecomerror,REComSession::ListImplementationsL(uid,implementationArray));
   1.477 +        if (!ecomerror)
   1.478 +            {
   1.479 +            break;
   1.480 +            }
   1.481 +        else
   1.482 +            {
   1.483 +            ecomerror = 0;  
   1.484 +            User::After(0);
   1.485 +            }
   1.486 +        }
   1.487 +
   1.488 +    const TInt availCount = implementationArray.Count();
   1.489 +    for (TInt count=0;count<availCount;++count)
   1.490 +        {
   1.491 +        const CImplementationInformation* info = implementationArray[count];
   1.492 +        TUid shaperFactoryUid = info->ImplementationUid();
   1.493 +        // Create a shaper factory
   1.494 +        //CShaperFactory* shaperFactory = 0;
   1.495 +        TRAP(error,shaperFactory = CShaperFactory::NewL(shaperFactoryUid));
   1.496 +        test(error == KErrNone);
   1.497 +        //CleanupStack::PushL(shaperFactory);
   1.498 +        }
   1.499 +    CleanupStack::PopAndDestroy(&implementationArray);
   1.500 +
   1.501 +    do
   1.502 +        {
   1.503 +        count += 1;
   1.504 +        __UHEAP_FAILNEXT(count);
   1.505 +    
   1.506 +        // Create a shaper
   1.507 +        TRAPD(err, theShaper = shaperFactory->NewShaperL(font, iScript, iLang, &User::Heap()));
   1.508 +        
   1.509 +        //shape text
   1.510 +        if (theShaper)
   1.511 +            {
   1.512 +            err = theShaper->ShapeText(output, input, &User::Heap());
   1.513 +            TEST(err == KErrNone);
   1.514 +            }
   1.515 +
   1.516 +        //free output; to be done by the caller of ShapeText
   1.517 +        delete output;
   1.518 +        output = NULL;      
   1.519 +            
   1.520 +        //does not check the output for now
   1.521 +        delete theShaper;
   1.522 +        delete shaperFactory;
   1.523 +        REComSession::FinalClose();
   1.524 +        
   1.525 +        }while ((err==KErrNoMemory)||(err==KErrGeneral));
   1.526 +    __UHEAP_RESET;
   1.527 +
   1.528 +    // check the heap used by the shaper
   1.529 +    RHeap* heap = &User::Heap();
   1.530 +    heap->Check();
   1.531 +    heapCellsUsed = heap->AllocSize(heapSizeAtEnd);
   1.532 +    if (heapCellsUsed)
   1.533 +        {
   1.534 +        INFO_PRINTF2(_L("This test leaked %d.\n"), heapSizeAtEnd - heapSizeAtStart);
   1.535 +        }
   1.536 +    }
   1.537 +
   1.538 +/**
   1.539 +@file
   1.540 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-1481
   1.541 +@SYMTestCaseDesc            Tests that the shaper can handle multiple calls to ShapeText
   1.542 +@SYMTestPriority            High
   1.543 +@SYMTestActions             Makes multiple calls to CShaper::ShapeText with small amounts of text to be shaped
   1.544 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.545 +@SYMPREQ                    PREQ18
   1.546 +*/
   1.547 +void CShapeTestStep::repeatShapeText(CBitmapFont* aFont, CTestData& aTestData)
   1.548 +    {
   1.549 +    __UHEAP_MARK;
   1.550 +    INFO_PRINTF1(_L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-1481 "));
   1.551 +    doRepeatShapeText(aFont, aTestData);
   1.552 +    __UHEAP_MARKEND;
   1.553 +    }
   1.554 +
   1.555 +void CShapeTestStep::doRepeatShapeText(CBitmapFont* font, CTestData& aTestData)
   1.556 +    {
   1.557 +    //set up the shaper
   1.558 +    CShaper* theShaper = NULL;
   1.559 +    CShaperFactory* shaperFactory = NULL;
   1.560 +
   1.561 +    RImplInfoPtrArray implementationArray;
   1.562 +    TCleanupItem cleanup(ResetAndDestroyRImplInfoPtrArray, &implementationArray);
   1.563 +    CleanupStack::PushL(cleanup);
   1.564 +    
   1.565 +    TInt ecomerror;
   1.566 +    TInt ecomnotready;
   1.567 +    TUid uid = {KUidShaperFactoryPlunginInterface};
   1.568 +
   1.569 +    // Making sure that no race situation arises between FBserv and Ecom
   1.570 +    // If ECom is not ready, give it another chance and try again. if it still doesn't work 
   1.571 +    // after the third try, then it just carries on quietly and fails... 
   1.572 +    for (ecomnotready =0; ecomnotready <3; ecomnotready++)
   1.573 +        {
   1.574 +
   1.575 +        TRAP(ecomerror,REComSession::ListImplementationsL(uid,implementationArray));
   1.576 +        if (!ecomerror)
   1.577 +            {
   1.578 +            break;
   1.579 +            }
   1.580 +        else
   1.581 +            {
   1.582 +            ecomerror = 0;  
   1.583 +            User::After(0);
   1.584 +            }
   1.585 +        }
   1.586 +
   1.587 +    const TInt availCount = implementationArray.Count();
   1.588 +    for (TInt count=0;count<availCount;++count)
   1.589 +        {
   1.590 +        const CImplementationInformation* info = implementationArray[count];
   1.591 +        TUid shaperFactoryUid = info->ImplementationUid();
   1.592 +        // Create a shaper factory
   1.593 +        TInt error;
   1.594 +        TRAP(error,shaperFactory = CShaperFactory::NewL(shaperFactoryUid));
   1.595 +        test(error == KErrNone);
   1.596 +        
   1.597 +        // Create a shaper
   1.598 +        TRAP(error, theShaper = shaperFactory->NewShaperL(font, iScript, iLang, &User::Heap()));
   1.599 +        if (error != KErrNone)
   1.600 +            {
   1.601 +            delete shaperFactory; 
   1.602 +            shaperFactory = NULL;
   1.603 +            }
   1.604 +        test(error == KErrNone);
   1.605 +        break; // have got valid shaper here
   1.606 +        }
   1.607 +    CleanupStack::PopAndDestroy(&implementationArray);
   1.608 +
   1.609 +    CleanupStack::PushL(shaperFactory);
   1.610 +    CleanupStack::PushL(theShaper);
   1.611 +
   1.612 +    // create the data to be shaped
   1.613 +    // this uses CTestData, defined in testData.h
   1.614 +    CShaper::TInput input;
   1.615 +    input.iText = aTestData.iTextInput;
   1.616 +
   1.617 +    //create shape header, and shape the text
   1.618 +    TShapeHeader* output = NULL;
   1.619 +
   1.620 +    for(TInt i=aTestData.iStart; i<aTestData.iEnd -10; i++)
   1.621 +        {
   1.622 +        //indicate which 10 chars to be shaped
   1.623 +        input.iStart = i;
   1.624 +        input.iEnd = i + 10;
   1.625 +        
   1.626 +        //shape text
   1.627 +        TInt err = theShaper->ShapeText(output, input, &User::Heap());
   1.628 +        test(err == KErrNone);
   1.629 +
   1.630 +        //free output; to be done by the caller of ShapeText
   1.631 +        delete(output);
   1.632 +        output = NULL;      
   1.633 +        
   1.634 +        //does not check the output for now
   1.635 +        }
   1.636 +
   1.637 +    //cleanup the shaper
   1.638 +    CleanupStack::PopAndDestroy(theShaper);
   1.639 +    CleanupStack::PopAndDestroy(shaperFactory);
   1.640 +    REComSession::FinalClose();
   1.641 +    }
   1.642 +    
   1.643 +/*
   1.644 +@file
   1.645 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-3401
   1.646 +@SYMTestCaseDesc            Tests that the shaper can handle calls to shapeText with multiple font sizes
   1.647 +@SYMTestPriority            High
   1.648 +@SYMTestActions             Makes multiple calls to CShaper::ShapeText with small amounts of text to be shaped and incremental font sizes
   1.649 +@SYMTestExpectedResults     The test must not show a memory leak at any font size
   1.650 +@SYMPREQ                    DEF103042: TC_SHAP_shapeText test failing with alloc failure
   1.651 +**/ 
   1.652 +void CShapeTestStep::doRepeatShapeUsingVariousFontSizesTest(CFontStore* aFontStore, const TDesC aTypefaceName, const TDesC &aText1, 
   1.653 +                                                const TDesC &aText2, const TDesC &aText3)
   1.654 +    {
   1.655 +    INFO_PRINTF1(_L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-3401 "));
   1.656 +    TInt heapCellsUsed, heapSizeAtEnd, heapSizeAtStart;
   1.657 +    User::Heap().AllocSize(heapSizeAtStart);
   1.658 +    
   1.659 +    // Set up shaper factory
   1.660 +    // Set up the shaper
   1.661 +    CShaper* theShaper = NULL;
   1.662 +    CShaperFactory* shaperFactory = NULL;
   1.663 +
   1.664 +    RImplInfoPtrArray implementationArray;
   1.665 +    TCleanupItem cleanup(ResetAndDestroyRImplInfoPtrArray, &implementationArray);
   1.666 +    CleanupStack::PushL(cleanup);
   1.667 +    TInt err;
   1.668 +    TInt ecomerror;
   1.669 +    TInt ecomnotready;
   1.670 +    TUid uid = {KUidShaperFactoryPlunginInterface};
   1.671 +
   1.672 +    // Making sure that no race situation arises between FBserv and Ecom
   1.673 +    // If ECom is not ready, give it another chance and try again. if it still doesn't work 
   1.674 +    // after the third try, then it just carries on quietly and fails... 
   1.675 +    for (ecomnotready =0; ecomnotready <3; ecomnotready++)
   1.676 +        {
   1.677 +        TRAP(ecomerror,REComSession::ListImplementationsL(uid,implementationArray));
   1.678 +        if (!ecomerror)
   1.679 +            {
   1.680 +            break;
   1.681 +            }
   1.682 +        else
   1.683 +            {
   1.684 +            ecomerror = 0;  
   1.685 +            User::After(0);
   1.686 +            }
   1.687 +        }
   1.688 +
   1.689 +    const TInt availCount = implementationArray.Count();
   1.690 +    for (TInt count=0;count<availCount;++count)
   1.691 +        {
   1.692 +        const CImplementationInformation* info = implementationArray[count];
   1.693 +        TUid shaperFactoryUid = info->ImplementationUid();
   1.694 +        // Create a shaper factory
   1.695 +        TRAPD(error,shaperFactory = CShaperFactory::NewL(shaperFactoryUid));
   1.696 +        test(error == KErrNone);
   1.697 +        }
   1.698 +    
   1.699 +    CleanupStack::PopAndDestroy(&implementationArray);
   1.700 +    
   1.701 +    CleanupStack::PushL(shaperFactory);
   1.702 +    
   1.703 +    // create the data to be shaped
   1.704 +    // this explicitely uses hindiTestData, defined in testData.h
   1.705 +    CShaper::TInput input;
   1.706 +    input.iStart = 0;
   1.707 +    
   1.708 +    //create shape header, and shape the text
   1.709 +    TShapeHeader* output = NULL;
   1.710 +    
   1.711 +    CBitmapFont* font;
   1.712 +    
   1.713 +    // Test shaping for the Hindi texts for various font sizes
   1.714 +    INFO_PRINTF1(_L("Generating a random initial font size between 0 and 1 for this test\n"));
   1.715 +    TInt random = (Math::Random()>>11)%2;
   1.716 +    INFO_PRINTF2(_L("Random initial font size is %d. Testing upto size 300 with increments of 2\n"), random);
   1.717 +    for (TInt i = random; i <= 300; i+=2)
   1.718 +        {
   1.719 +        INFO_PRINTF2(_L("Font Size: %d\n"), i);
   1.720 +        if (i == 294 || i == 295)
   1.721 +            {
   1.722 +        INFO_PRINTF2(_L("Font Size: %d\n"), i);
   1.723 +            }
   1.724 +        TFontSpec fontSpec(aTypefaceName,i*20); 
   1.725 +        aFontStore->GetNearestFontInTwips((CFont*&)font, fontSpec); 
   1.726 +        CleanupStack::PushL(font);  
   1.727 +
   1.728 +        TRAP(err, theShaper = shaperFactory->NewShaperL(font, iScript, iLang, &User::Heap()));
   1.729 +        test(err == KErrNone);
   1.730 +        CleanupStack::PushL(theShaper);
   1.731 +        
   1.732 +        // Call the shaper twice because the first time the rasterizer uses memory to cache the tables
   1.733 +        // We can then check the heap in the second call
   1.734 +        input.iText = &aText1;
   1.735 +        input.iEnd = aText1.Length();
   1.736 +        err = theShaper->ShapeText(output, input, &User::Heap());
   1.737 +        delete output;
   1.738 +        TEST(err == KErrNone);
   1.739 +        __UHEAP_MARK;
   1.740 +        err = theShaper->ShapeText(output, input, &User::Heap());
   1.741 +        delete output;
   1.742 +        __UHEAP_MARKEND;
   1.743 +        TEST(err == KErrNone);
   1.744 +                
   1.745 +        input.iText = &aText2;
   1.746 +        input.iEnd = aText2.Length();
   1.747 +        err = theShaper->ShapeText(output, input, &User::Heap());
   1.748 +        delete output;
   1.749 +        TEST(err == KErrNone);
   1.750 +        __UHEAP_MARK;
   1.751 +        err = theShaper->ShapeText(output, input, &User::Heap());
   1.752 +        delete output;
   1.753 +        __UHEAP_MARKEND;
   1.754 +        TEST(err == KErrNone);
   1.755 +        
   1.756 +        input.iText = &aText3;
   1.757 +        input.iEnd = aText3.Length();
   1.758 +        err = theShaper->ShapeText(output, input, &User::Heap());
   1.759 +        delete output;
   1.760 +        TEST(err == KErrNone);
   1.761 +//        __UHEAP_MARK;
   1.762 +        err = theShaper->ShapeText(output, input, &User::Heap());
   1.763 +        delete output;
   1.764 +//        __UHEAP_MARKEND;
   1.765 +        TEST(err == KErrNone);
   1.766 +        
   1.767 +        CleanupStack::PopAndDestroy(theShaper);
   1.768 +        CleanupStack::Pop(font);   
   1.769 +        aFontStore->ReleaseFont(font);
   1.770 +        }
   1.771 +        
   1.772 +    CleanupStack::PopAndDestroy(shaperFactory);
   1.773 +
   1.774 +    //close the ecom session opened by LoadOpenFontLibraries()
   1.775 +    REComSession::FinalClose();
   1.776 +    
   1.777 +    // check the heap used by the shaper
   1.778 +    RHeap* heap = &User::Heap();
   1.779 +    heap->Check();
   1.780 +    heapCellsUsed = heap->AllocSize(heapSizeAtEnd);
   1.781 +    if (heapCellsUsed)
   1.782 +        {
   1.783 +        INFO_PRINTF2(_L("This test utilised %d bytes\n"), heapSizeAtEnd - heapSizeAtStart);
   1.784 +        }
   1.785 +    }
   1.786 +
   1.787 +/**
   1.788 +@file
   1.789 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-3403
   1.790 +@SYMTestCaseDesc            Tests the shaper using Devanagari Unicode. Test include OOM tests (oomShapeText), repeated 
   1.791 +                            calls to the shaper (repeatShapeText), simple shaping tests (shapeText), and repeatedly 
   1.792 +                            calling the shaper with incremental font sizes.
   1.793 +@SYMTestPriority            High
   1.794 +@SYMTestActions             Performs various tests of the the shaper, calling CShaper::ShapeText in various use cases
   1.795 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.796 +@SYMPREQ                    PREQ19
   1.797 +*/
   1.798 +/**
   1.799 +@file
   1.800 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-3383-0001
   1.801 +@SYMTestCaseDesc            Tests the shaper using Kannada Unicode. Test include OOM tests (oomShapeText), repeated 
   1.802 +                            calls to the shaper (repeatShapeText), simple shaping tests (shapeText), and repeatedly 
   1.803 +                            calling the shaper with incremental font sizes.
   1.804 +@SYMTestPriority            High
   1.805 +@SYMTestActions             Performs various tests of the the shaper, calling CShaper::ShapeText in various use cases
   1.806 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.807 +@SYMPREQ                    PREQ19
   1.808 +*/  
   1.809 +/**
   1.810 +@file
   1.811 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-3383-0002
   1.812 +@SYMTestCaseDesc            Tests the shaper using Gujarati Unicode. Test include OOM tests (oomShapeText), repeated 
   1.813 +                            calls to the shaper (repeatShapeText), simple shaping tests (shapeText), and repeatedly 
   1.814 +                            calling the shaper with incremental font sizes.
   1.815 +@SYMTestPriority            High
   1.816 +@SYMTestActions             Performs various tests of the the shaper, calling CShaper::ShapeText in various use cases
   1.817 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.818 +@SYMPREQ                    PREQ19
   1.819 +*/  
   1.820 +/**
   1.821 +@file
   1.822 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-4001
   1.823 +@SYMTestCaseDesc            Tests the shaper using Bengali Unicode. Test include OOM tests (oomShapeText), repeated 
   1.824 +                            calls to the shaper (repeatShapeText), simple shaping tests (shapeText), and repeatedly 
   1.825 +                            calling the shaper with incremental font sizes.
   1.826 +@SYMTestPriority            High
   1.827 +@SYMTestActions             Performs various tests of the the shaper, calling CShaper::ShapeText in various use cases
   1.828 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.829 +@SYMPREQ                    PREQ1766
   1.830 +@SYMREQ                     REQ8741
   1.831 +*/  
   1.832 +/**
   1.833 +@file
   1.834 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-4002
   1.835 +@SYMTestCaseDesc            Tests the shaper using Tamil Unicode. Test include OOM tests (oomShapeText), repeated 
   1.836 +                            calls to the shaper (repeatShapeText), simple shaping tests (shapeText), and repeatedly 
   1.837 +                            calling the shaper with incremental font sizes.
   1.838 +@SYMTestPriority            High
   1.839 +@SYMTestActions             Performs various tests of the the shaper, calling CShaper::ShapeText in various use cases
   1.840 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.841 +@SYMPREQ                    PREQ1766
   1.842 +@SYMREQ                     REQ8742
   1.843 +*/  
   1.844 +/**
   1.845 +@file
   1.846 +@SYMTestCaseID              GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-4003
   1.847 +@SYMTestCaseDesc            Tests the shaper using Telugu Unicode. Test include OOM tests (oomShapeText), repeated 
   1.848 +                            calls to the shaper (repeatShapeText), simple shaping tests (shapeText), and repeatedly 
   1.849 +                            calling the shaper with incremental font sizes.
   1.850 +@SYMTestPriority            High
   1.851 +@SYMTestActions             Performs various tests of the the shaper, calling CShaper::ShapeText in various use cases
   1.852 +@SYMTestExpectedResults     The test must exit cleanly and there should not be any User:84 errors, KERN-EXEC's or any memory leaks.
   1.853 +@SYMPREQ                    PREQ1766
   1.854 +@SYMREQ                     REQ8743
   1.855 +*/
   1.856 +/**
   1.857 +@SYMTestCaseID              GRAPHICS-TI18N-ICULAYOUTENGINE-CT-4007
   1.858 +@SYMTestCaseDesc            Case to do Gurmukhi component test
   1.859 +                            It covers all Iculayout components cases
   1.860 +@SYMTestPriority            High
   1.861 +@SYMTestActions             Iterate Gurmukhi test data, each test data corresponds with a case
   1.862 +@SYMTestExpectedResults     No error returned
   1.863 +@SYMPREQ                    1922: Gurmukhi support
   1.864 +*/
   1.865 +/**
   1.866 +@SYMTestCaseID              GRAPHICS-TI18N-ICULAYOUTENGINE-CT-4008
   1.867 +@SYMTestCaseDesc            Case to do Malayalam component test
   1.868 +                            It covers all Iculayout components cases
   1.869 +@SYMTestPriority            High
   1.870 +@SYMTestActions             Iterate Malayalam test data, each test data corresponds with a case
   1.871 +@SYMTestExpectedResults     No error returned
   1.872 +@SYMPREQ                    1922: Malayalam support
   1.873 +*/
   1.874 +void CShapeTestStep::ShapeTestL()
   1.875 +    {
   1.876 +    INFO_PRINTF1(iTestID);
   1.877 +
   1.878 +    CBitmapFont* font;
   1.879 +    TInt err=KErrNone;  
   1.880 +    //the font store can use the normal user heap
   1.881 +    CFontStore* fontStore = CFontStore::NewL(&User::Heap());    
   1.882 +    fontStore->iKPixelWidthInTwips = 11860;
   1.883 +    fontStore->iKPixelHeightInTwips = 11860;
   1.884 +    CleanupStack::PushL(fontStore);
   1.885 +
   1.886 +    //load all ecom implemented rasterizer dlls. installs the rasterizer.
   1.887 +    LoadOpenFontLibraries(fontStore);
   1.888 +    
   1.889 +    //add the required font file
   1.890 +    TRAP(err,fontStore->AddFileL(iTestDataArr[iTestDataIndex]->iFilename));
   1.891 +    test(err == KErrNone);        
   1.892 +    
   1.893 +    
   1.894 +    //run all tests for TNR_Dev_OT test, which is at position 0 in the aTestDataArr
   1.895 +    TFontSpec fontSpec(iTestDataArr[iTestDataIndex]->iTypeFaceName,12);    
   1.896 +    fontStore->GetNearestFontToDesignHeightInPixels((CFont*&)font, fontSpec);   
   1.897 +    CleanupStack::PushL(font);  
   1.898 +    
   1.899 +    INFO_PRINTF2(_L("Repeat %S text shaping test\n"), &iScriptName);
   1.900 +    doRepeatShapeText(font, *iTestDataArr[iTestDataIndex]);
   1.901 +    repeatShapeText(font, *iTestDataArr[iTestDataIndex]);
   1.902 +    
   1.903 +    INFO_PRINTF2(_L("OOM %S text shaping test\n"), &iScriptName);
   1.904 +#if defined(_DEBUG)
   1.905 +    doOomShapeText(font, *iTestDataArr[iTestDataIndex]);
   1.906 +    oomShapeText(font, *iTestDataArr[iTestDataIndex]);
   1.907 +#else
   1.908 +    INFO_PRINTF1(_L("This test is ignored for release version\n"));
   1.909 +#endif
   1.910 +    
   1.911 +    INFO_PRINTF2(_L("Run simple %S shape test\n"), &iScriptName);
   1.912 +    doShapeText(font, *iTestDataArr[iTestDataIndex], ETrue);
   1.913 +    shapeText(font, *iTestDataArr[iTestDataIndex], ETrue);
   1.914 +
   1.915 +    CleanupStack::Pop(font);   
   1.916 +    fontStore->ReleaseFont(font);
   1.917 +
   1.918 +    //for any other test data we have, run the simple shape text test only
   1.919 +    for(TInt i=iTestDataIndex+1; i<iTestDataIndex+iNumberOfTestDataFiles; i++)
   1.920 +        {
   1.921 +        TFontSpec fontSpec(iTestDataArr[i]->iTypeFaceName,12);  
   1.922 +        fontStore->GetNearestFontToDesignHeightInPixels((CFont*&)font, fontSpec);   
   1.923 +        CleanupStack::PushL(font);
   1.924 +        
   1.925 +        // First run does not check heap... this ensures that any memory
   1.926 +        // stashed by the rasterizer does not show up as a leak.
   1.927 +        doShapeText(font, *iTestDataArr[i], ETrue);
   1.928 +        shapeText(font, *iTestDataArr[i], ETrue);
   1.929 +
   1.930 +        CleanupStack::Pop(font);
   1.931 +        fontStore->ReleaseFont(font);
   1.932 +        }
   1.933 +        
   1.934 +    // Now do the last test, the shaping test using various font sizes
   1.935 +    INFO_PRINTF2(_L("Repeat %S shaping test using font sizes 20 to 6000\n"), &iScriptName);    
   1.936 +    if(iScriptName == KTestStep_Hindi)
   1.937 +        {
   1.938 +        doRepeatShapeUsingVariousFontSizesTest(fontStore, iTestDataArr[0]->iTypeFaceName, KHindi1, KHindi2, KHindi3);
   1.939 +        }
   1.940 +    else if(iScriptName == KTestStep_Kannada)
   1.941 +        {
   1.942 +        doRepeatShapeUsingVariousFontSizesTest(fontStore, iTestDataArr[0]->iTypeFaceName, KKannada1, KKannada2, KKannada3);
   1.943 +        }
   1.944 +    else if(iScriptName == KTestStep_Gujarati)
   1.945 +        {
   1.946 +        doRepeatShapeUsingVariousFontSizesTest(fontStore, iTestDataArr[0]->iTypeFaceName, KGujarati1, KGujarati2, KGujarati3);
   1.947 +        }
   1.948 +    else if(iScriptName == KTestStep_Bengali)
   1.949 +        {
   1.950 +        doRepeatShapeUsingVariousFontSizesTest(fontStore, iTestDataArr[0]->iTypeFaceName, KBengali1, KBengali2, KBengali3);
   1.951 +        }
   1.952 +    else if(iScriptName == KTestStep_Tamil)
   1.953 +        {
   1.954 +        doRepeatShapeUsingVariousFontSizesTest(fontStore, iTestDataArr[0]->iTypeFaceName, KTamil1, KTamil2, KTamil3);
   1.955 +        }
   1.956 +    else if(iScriptName == KTestStep_Telugu)
   1.957 +        {
   1.958 +        doRepeatShapeUsingVariousFontSizesTest(fontStore, iTestDataArr[0]->iTypeFaceName, KTelugu1, KTelugu2, KTelugu3);
   1.959 +        }
   1.960 +    else if(iScriptName == KTestStep_Gurmukhi)
   1.961 +        {
   1.962 +        doRepeatShapeUsingVariousFontSizesTest(fontStore, iTestDataArr[0]->iTypeFaceName, KGurmukhi1, KGurmukhi2, KGurmukhi3);
   1.963 +        }
   1.964 +    else if(iScriptName == KTestStep_Malayalam)
   1.965 +        {
   1.966 +        doRepeatShapeUsingVariousFontSizesTest(fontStore, iTestDataArr[0]->iTypeFaceName, KMalayalam1, KMalayalam2, KMalayalam3);
   1.967 +        }
   1.968 +
   1.969 +    CleanupStack::PopAndDestroy(fontStore);
   1.970 +    REComSession::FinalClose(); //close the ecom session opened by LoadOpenFontLibraries()
   1.971 +    }
   1.972 +    
   1.973 +TVerdict CShapeTestStep::doTestStepL()
   1.974 +    {
   1.975 +    SetTestStepResult(EFail);
   1.976 +
   1.977 +    __UHEAP_MARK;
   1.978 +
   1.979 +    TRAPD(error0, SetupTestDataL());
   1.980 +    
   1.981 +    if(error0 == KErrNone)
   1.982 +        {
   1.983 +        TRAPD(error1, ShapeTestL());
   1.984 +        
   1.985 +        if(error1 == KErrNone)
   1.986 +            {
   1.987 +            SetTestStepResult(EPass);
   1.988 +            }
   1.989 +        }
   1.990 +    else
   1.991 +        {
   1.992 +        ERR_PRINTF1(_L("Failed to setup test data."));
   1.993 +        }
   1.994 +    
   1.995 +    iTestDataArr.ResetAndDestroy(); // close the iTestDataArr opened by SetupTestData()        
   1.996 +
   1.997 +    __UHEAP_MARKEND;
   1.998 +
   1.999 +    return TestStepResult();
  1.1000 +    }
  1.1001 +
  1.1002 +CTestStep * CShapeTestStep::CreateShapeTestStep(const TDesC& aStepName)
  1.1003 +    {
  1.1004 +    if(aStepName == KTestStep_Hindi)
  1.1005 +        {
  1.1006 +        return new CShapeTestStep(KHindiTestDataIndex, KNumberOfHindiTestDataFiles, KDevanagariScriptCode, KHindiLanguageCode,
  1.1007 +                aStepName, _L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-3403 "));
  1.1008 +        }
  1.1009 +    else if(aStepName == KTestStep_Kannada)
  1.1010 +        {
  1.1011 +        return new CShapeTestStep(KKannadaTestDataIndex, KNumberOfKannadaTestDataFiles, KKannadaScriptCode, KKannadaLanguageCode,
  1.1012 +                aStepName, _L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-3383-0001"));
  1.1013 +        }
  1.1014 +    else if(aStepName == KTestStep_Gujarati)
  1.1015 +        {
  1.1016 +        return new CShapeTestStep(KGujaratiTestDataIndex, KNumberOfGujaratiTestDataFiles, KGujaratiScriptCode, KGujaratiLanguageCode,
  1.1017 +                aStepName, _L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-3383-0002"));
  1.1018 +        }
  1.1019 +    else if(aStepName == KTestStep_Bengali)
  1.1020 +        {
  1.1021 +        return new CShapeTestStep(KBengaliTestDataIndex, KNumberOfBengaliTestDataFiles, KBengaliScriptCode, KBengaliLanguageCode,
  1.1022 +                aStepName, _L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-4001"));
  1.1023 +        }
  1.1024 +    else if(aStepName == KTestStep_Tamil)
  1.1025 +        {
  1.1026 +        return new CShapeTestStep(KTamilTestDataIndex, KNumberOfTamilTestDataFiles, KTamilScriptCode, KTamilLanguageCode,
  1.1027 +                aStepName, _L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-4002"));
  1.1028 +        }
  1.1029 +    else if(aStepName == KTestStep_Telugu)
  1.1030 +        {
  1.1031 +        return new CShapeTestStep(KTeluguTestDataIndex, KNumberOfTeluguTestDataFiles, KTeluguScriptCode, KTeluguLanguageCode,
  1.1032 +                aStepName, _L("GRAPHICS-SYSLIB-ICULAYOUTENGINE-CT-4003"));
  1.1033 +        }
  1.1034 +    else if(aStepName == KTestStep_Gurmukhi)
  1.1035 +        {
  1.1036 +        return new CShapeTestStep(KGurmukhiTestDataIndex, KNumberOfGurmukhiTestDataFiles, KGurmukhiScriptCode, KGurmukhiLanguageCode,
  1.1037 +                aStepName, _L("GRAPHICS-TI18N-ICULAYOUTENGINE-CT-4007"));
  1.1038 +        }
  1.1039 +    else if(aStepName == KTestStep_Malayalam)
  1.1040 +        {
  1.1041 +        return new CShapeTestStep(KMalayalamTestDataIndex, KNumberOfMalayalamTestDataFiles, KMalayalamScriptCode, KMalayalamLanguageCode,
  1.1042 +                aStepName, _L("GRAPHICS-TI18N-ICULAYOUTENGINE-CT-4007"));
  1.1043 +        }
  1.1044 +    return NULL;    
  1.1045 +    }