|
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: Test title resolver. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef ONLY_MENU_TESTCASES |
|
19 |
|
20 #include "t_hsutils.h" |
|
21 #include "hstitleresolver.h" |
|
22 |
|
23 |
|
24 const QString KTestingOperatorName = QString("Testing"); |
|
25 const QString KTestingOperatorName2 = QString("Testing2"); |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 void t_hsUtils::testTitleResolver() |
|
31 { |
|
32 HsTitleResolver *titleResolver = new HsTitleResolver(); |
|
33 QCOMPARE(titleResolver->title(), titleResolver->mNoServiceText); |
|
34 |
|
35 titleResolver->mDeviceInfoListener->mNetworkInfo->setProperty("testNetworkMode", QVariant((int)QSystemNetworkInfo::GsmMode)); |
|
36 titleResolver->mDeviceInfoListener->mNetworkInfo->setProperty("testNetworkStatus", QVariant(QSystemNetworkInfo::Roaming)); |
|
37 titleResolver->mDeviceInfoListener->updateCurrentNetworkMode(); |
|
38 titleResolver->mDeviceInfoListener->updateStatus(); |
|
39 |
|
40 QCOMPARE(titleResolver->title(), KTestingOperatorName); |
|
41 |
|
42 titleResolver->mOperatorName.clear(); |
|
43 titleResolver->mDeviceInfoListener->updateCurrentNetworkMode(); |
|
44 titleResolver->mDeviceInfoListener->updateStatus(); |
|
45 QCOMPARE(titleResolver->title(), KTestingOperatorName); |
|
46 |
|
47 delete titleResolver; |
|
48 |
|
49 } |
|
50 |
|
51 void t_hsUtils::testTitleResolverOnStatusChanged() |
|
52 { |
|
53 HsTitleResolver *titleResolver = new HsTitleResolver(); |
|
54 |
|
55 qRegisterMetaType<HsDeviceInfoListener::HsDeviceInfoStatus>( |
|
56 "HsDeviceInfoListener::HsDeviceInfoStatus"); |
|
57 QSignalSpy spy(titleResolver, SIGNAL(titleChanged(const QString &))); |
|
58 |
|
59 titleResolver->onStatusChanged(HsDeviceInfoListener::ServiceAvailable); |
|
60 QCOMPARE(spy.count(), 1); |
|
61 QList<QVariant> arguments = spy.takeFirst(); |
|
62 QCOMPARE(arguments.at(0).toString(), KTestingOperatorName); |
|
63 QCOMPARE(titleResolver->title(), KTestingOperatorName); |
|
64 spy.clear(); |
|
65 titleResolver->onStatusChanged(HsDeviceInfoListener::ServiceAvailable); |
|
66 QCOMPARE(spy.count(), 0); |
|
67 |
|
68 titleResolver->onStatusChanged(HsDeviceInfoListener::OfflineProfile); |
|
69 QCOMPARE(spy.count(), 1); |
|
70 arguments = spy.takeFirst(); |
|
71 QCOMPARE(arguments.at(0).toString(), titleResolver->mOfflineText); |
|
72 QCOMPARE(titleResolver->title(), titleResolver->mOfflineText); |
|
73 |
|
74 delete titleResolver; |
|
75 } |
|
76 |
|
77 void t_hsUtils::testTitleResolverOnNetworkNameChanged() |
|
78 { |
|
79 HsTitleResolver *titleResolver = new HsTitleResolver(); |
|
80 QCOMPARE(titleResolver->title(), titleResolver->mNoServiceText); |
|
81 |
|
82 qRegisterMetaType<HsDeviceInfoListener::HsDeviceInfoStatus>( |
|
83 "HsDeviceInfoListener::HsDeviceInfoStatus"); |
|
84 QSignalSpy spy(titleResolver, SIGNAL(titleChanged(const QString &))); |
|
85 |
|
86 titleResolver->onNetworkNameChanged(KTestingOperatorName); |
|
87 // this should not emit anything because UnknownMode |
|
88 QCOMPARE(spy.count(), 0); |
|
89 |
|
90 titleResolver->mCurrentStatus = HsDeviceInfoListener::ServiceAvailable; |
|
91 titleResolver->onNetworkNameChanged(KTestingOperatorName2); |
|
92 QCOMPARE(spy.count(), 1); |
|
93 QList<QVariant> arguments = spy.takeFirst(); |
|
94 QCOMPARE(arguments.at(0).toString(), KTestingOperatorName2); |
|
95 |
|
96 spy.clear(); |
|
97 titleResolver->onNetworkNameChanged(KTestingOperatorName); |
|
98 QCOMPARE(spy.count(), 1); |
|
99 arguments = spy.takeFirst(); |
|
100 QCOMPARE(arguments.at(0).toString(), KTestingOperatorName); |
|
101 |
|
102 spy.clear(); |
|
103 titleResolver->onNetworkNameChanged(KTestingOperatorName); |
|
104 QCOMPARE(spy.count(), 0); |
|
105 |
|
106 delete titleResolver; |
|
107 } |
|
108 |
|
109 #endif //ONLY_MENU_TESTCASES |