|
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 #include <QTest> |
|
18 #include <QString> |
|
19 |
|
20 #include "unittest_cxestate.h" |
|
21 #include "cxestate.h" |
|
22 |
|
23 // ----------------------------------- |
|
24 // CxsState |
|
25 // ----------------------------------- |
|
26 UnitTestCxeState::UnitTestCxeState() : |
|
27 mStateA(NULL), mStateB(NULL), mStateC(NULL), mStateD(NULL) |
|
28 { |
|
29 } |
|
30 |
|
31 UnitTestCxeState::~UnitTestCxeState() |
|
32 { |
|
33 } |
|
34 |
|
35 // Run before testcases |
|
36 void UnitTestCxeState::initTestCase() |
|
37 { |
|
38 mStateA = new CxeState(-1, "", 1); |
|
39 mStateB = new CxeState(0, "Test B", -1); |
|
40 mStateC = new CxeState(3, "TestC", 0); |
|
41 mStateD = new CxeState(0x08, "TestD", 0x02 | 0x04); |
|
42 } |
|
43 |
|
44 // Run after last testcase |
|
45 void UnitTestCxeState::cleanupTestCase() |
|
46 { |
|
47 delete mStateA; |
|
48 mStateA = NULL; |
|
49 |
|
50 delete mStateB; |
|
51 mStateB = NULL; |
|
52 |
|
53 delete mStateC; |
|
54 mStateC = NULL; |
|
55 |
|
56 delete mStateD; |
|
57 mStateD = NULL; |
|
58 } |
|
59 |
|
60 void UnitTestCxeState::testStateId() |
|
61 { |
|
62 // test that id is returned correctly |
|
63 |
|
64 QVERIFY(mStateA->stateId() == -1); |
|
65 QVERIFY(mStateB->stateId() == 0); |
|
66 QVERIFY(mStateC->stateId() == 3); |
|
67 QVERIFY(mStateD->stateId() == 0x08); |
|
68 |
|
69 } |
|
70 |
|
71 void UnitTestCxeState::testAllowedNextStates() |
|
72 { |
|
73 // test that return value is same as input |
|
74 |
|
75 QVERIFY(mStateA->allowedNextStates() == 1); |
|
76 QVERIFY(mStateB->allowedNextStates() == -1); |
|
77 QVERIFY(mStateC->allowedNextStates() == 0); |
|
78 QVERIFY(mStateD->allowedNextStates() == 0x02|0x04); |
|
79 |
|
80 } |
|
81 |
|
82 void UnitTestCxeState::testName() |
|
83 { |
|
84 // test that return value is same as imput |
|
85 // possible values: empty string, normal string |
|
86 |
|
87 QString name; |
|
88 name = mStateA->name(); |
|
89 QVERIFY(name.isEmpty()); |
|
90 |
|
91 name = mStateB->name(); |
|
92 QVERIFY(name == "Test B"); |
|
93 |
|
94 name = mStateC->name(); |
|
95 QVERIFY(name == "TestC"); |
|
96 |
|
97 name = mStateD->name(); |
|
98 QVERIFY(name == "TestD"); |
|
99 } |
|
100 |
|
101 // main() function non-GUI testing |
|
102 QTEST_APPLESS_MAIN(UnitTestCxeState) |
|
103 ; |