textrendering/texthandling/ttext/t_fmt1.cpp
author hgs
Thu, 26 Aug 2010 11:46:18 +0800
changeset 53 11e2bb0d14ba
parent 0 1fb32624e06b
child 55 336bee5c2d35
permissions -rw-r--r--
201028_05
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
     2
* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: 
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
* T_FMT.CPP
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*/
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <txtfmlyr.h>
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <txtrich.h>
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <txtfrmat.h>
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <gdi.h>
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    24
#include "../stext/TXTSTD.H"
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    25
#include "T_FMT1.h"
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    27
#define test(cond)											\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    28
	{														\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    29
	TBool __bb = (cond);									\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    30
	pTestStep->TEST(__bb);									\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    31
	if (!__bb)												\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    32
		{													\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    33
		pTestStep->ERR_PRINTF1(_L("ERROR: Test Failed"));	\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    34
		User::Leave(1);										\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    35
		}													\
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    36
	}
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    38
void CT_FMT1::TestDEF047316L()
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
// Test CParaFormat stack definition leave protection
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
//
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
	{
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    42
    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-t_fmt1-0001 CParaFormat - DEF047316 - stack definition leave protection "));
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
	CParaFormat paraFormat;
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
	
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
	// Allocate resources for paraFormat
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
	TTabStop tabStop;
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
	paraFormat.StoreTabL(tabStop);
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
	
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
	TParaBorder border;
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
	paraFormat.SetParaBorderL(CParaFormat::EParaBorderTop,border);
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
	paraFormat.iBullet=new(ELeave)TBullet;
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
	
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
	// Push cleanup method for paraFormat
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
	ResetOnCleanupL( &paraFormat);
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
	
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
	// Force cleanup method to be called
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
	CleanupStack::PopAndDestroy();
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
	// Note that test end is when paraFormat's destructor is called when 
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
	// this function terminates. The destructor should not cause any problems
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
	// even though we have already called the cleanup method
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
	}
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    65
CT_FMT1::CT_FMT1()
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    66
    {
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    67
    SetTestStepName(KTestStep_T_FMT1);
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    68
    }
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    69
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    70
TVerdict CT_FMT1::doTestStepL()
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    71
    {
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    72
    SetTestStepResult(EFail);
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    74
    CTrapCleanup* cleanup=CTrapCleanup::New();
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    75
    INFO_PRINTF1(_L("TFormat Test Code for DEF047316"));
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    76
    
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    77
    __UHEAP_MARK;
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    78
    TRAPD(error1, TestDEF047316L());
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    80
    __UHEAP_MARKEND;
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    81
    delete cleanup;
0
1fb32624e06b Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
53
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    83
    if(error1 == KErrNone)
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    84
        {
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    85
        SetTestStepResult(EPass);
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    86
        }
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    87
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    88
    return TestStepResult();
11e2bb0d14ba 201028_05
hgs
parents: 0
diff changeset
    89
    }