61
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "ut_cntdisplaytextformatter.h"
|
|
19 |
#include "cntdisplaytextformatter.h"
|
|
20 |
#include <hbcolorscheme.h>
|
|
21 |
|
|
22 |
void TestCntDisplayTextFormatter::testFormatter()
|
|
23 |
{
|
|
24 |
QColor color = HbColorScheme::color("qtc_lineedit_selected ");
|
|
25 |
QColor bg = HbColorScheme::color("qtc_lineedit_marker_normal");
|
|
26 |
QString foo = QString("<span style=\"background-color:%1;color:%2\">f</span>oo").arg(bg.name().toUpper()).arg(color.name().toUpper());
|
|
27 |
|
|
28 |
QContactDetailFilter filter;
|
|
29 |
filter.setDetailDefinitionName( QContactDisplayLabel::DefinitionName );
|
|
30 |
filter.setMatchFlags( QContactFilter::MatchStartsWith );
|
|
31 |
filter.setValue( "f" );
|
|
32 |
|
|
33 |
CntDisplayTextFormatter* format = new CntHTMLDisplayTextFormatter;
|
|
34 |
QString result = format->formattedText("foo", filter );
|
|
35 |
QVERIFY( foo == result );
|
|
36 |
QVERIFY( "" == format->formattedText("", filter) );
|
|
37 |
// invalid filter
|
|
38 |
QContactRelationshipFilter invalidFilter;
|
|
39 |
QVERIFY( "foo" == format->formattedText("foo", invalidFilter) );
|
|
40 |
QVERIFY( "" == format->formattedText("", invalidFilter) );
|
|
41 |
|
|
42 |
// dummy returns always the given text, dispite of the filter
|
|
43 |
CntDisplayTextFormatter* dummy = new CntDummyDisplayTextFormatter;
|
|
44 |
QVERIFY( "foo" == dummy->formattedText("foo", filter) );
|
|
45 |
QVERIFY( "foo" == dummy->formattedText("foo", invalidFilter) );
|
|
46 |
QVERIFY( "" == dummy->formattedText("", filter) );
|
|
47 |
}
|