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_cpphonelocalisation.h" |
|
19 #include "qtestmains60.h" |
|
20 #include <smcmockclassincludes.h> |
|
21 #define private public |
|
22 #include "cpphonelocalisation.h" |
|
23 |
|
24 void QCoreApplication::installTranslator(QTranslator * messageFile) |
|
25 { |
|
26 SMC_MOCK_METHOD1( void, QTranslator *, messageFile) |
|
27 } |
|
28 |
|
29 /*! |
|
30 UT_cpphonelocalisation::UT_cpphonelocalisation |
|
31 */ |
|
32 UT_cpphonelocalisation::UT_cpphonelocalisation() |
|
33 { |
|
34 |
|
35 } |
|
36 |
|
37 /*! |
|
38 UT_cpphonelocalisation::~UT_cpphonelocalisation |
|
39 */ |
|
40 UT_cpphonelocalisation::~UT_cpphonelocalisation() |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 /*! |
|
46 UT_cpphonelocalisation::init |
|
47 */ |
|
48 void UT_cpphonelocalisation::init() |
|
49 { |
|
50 initialize(); |
|
51 |
|
52 m_phoneLocalisation.reset(new PhoneLocalisation); |
|
53 } |
|
54 |
|
55 /*! |
|
56 UT_cpphonelocalisation::cleanup |
|
57 */ |
|
58 void UT_cpphonelocalisation::cleanup() |
|
59 { |
|
60 reset(); |
|
61 delete m_phoneLocalisation.take(); |
|
62 } |
|
63 |
|
64 /*! |
|
65 UT_cpphonelocalisation::t_memleak |
|
66 */ |
|
67 void UT_cpphonelocalisation::t_memleak() |
|
68 { |
|
69 |
|
70 } |
|
71 |
|
72 /*! |
|
73 UT_cpphonelocalisation::t_installTranslator |
|
74 */ |
|
75 void UT_cpphonelocalisation::t_installTranslator() |
|
76 { |
|
77 |
|
78 // Test: successfull load |
|
79 expect("QTranslator::load"). |
|
80 returns(true); |
|
81 expect("QCoreApplication::installTranslator").times(1); |
|
82 |
|
83 m_phoneLocalisation->installTranslator( |
|
84 PhoneLocalisation::TranslationFileCommon); |
|
85 QVERIFY(m_phoneLocalisation->m_translators.count() == 1); |
|
86 QVERIFY(verify()); |
|
87 |
|
88 // Test: failing load |
|
89 expect("QTranslator::load"). |
|
90 returns(false); |
|
91 expect("QCoreApplication::installTranslator").times(0); |
|
92 m_phoneLocalisation->installTranslator( |
|
93 PhoneLocalisation::TranslationFileCommon); |
|
94 QVERIFY(m_phoneLocalisation->m_translators.count() == 1); |
|
95 |
|
96 // Test: Unknown enum value |
|
97 QVERIFY(verify()); |
|
98 expect("QCoreApplication::installTranslator").times(0); |
|
99 m_phoneLocalisation->installTranslator( |
|
100 (PhoneLocalisation::TranslationFileId)2); |
|
101 QVERIFY(m_phoneLocalisation->m_translators.count() == 1); |
|
102 QVERIFY(verify()); |
|
103 |
|
104 // Test: telephone_cp translator load |
|
105 expect("QTranslator::load"). |
|
106 returns(false); |
|
107 expect("QCoreApplication::installTranslator").times(0); |
|
108 m_phoneLocalisation->installTranslator( |
|
109 PhoneLocalisation::TranslationFileTelephoneCp); |
|
110 QVERIFY(verify()); |
|
111 |
|
112 } |
|
113 |
|
114 /*! |
|
115 UT_cpphonelocalisation::t_removeTranslators |
|
116 */ |
|
117 void UT_cpphonelocalisation::t_removeTranslators() |
|
118 { |
|
119 expect("QTranslator::load"). |
|
120 returns(true); |
|
121 |
|
122 m_phoneLocalisation->installTranslator( |
|
123 PhoneLocalisation::TranslationFileCommon); |
|
124 m_phoneLocalisation->installTranslator( |
|
125 PhoneLocalisation::TranslationFileTelephoneCp); |
|
126 |
|
127 m_phoneLocalisation->removeTranslators(); |
|
128 QVERIFY(m_phoneLocalisation->m_translators.count() == 0); |
|
129 QVERIFY(verify()); |
|
130 } |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 QTEST_MAIN_S60(UT_cpphonelocalisation) |
|