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 |
|
19 #ifndef T_RADIOSTATION_H_ |
|
20 #define T_RADIOSTATION_H_ |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <QtTest/QtTest> |
|
25 |
|
26 #include "radioenginewrapperobserver.h" |
|
27 #include "radiostation.h" |
|
28 |
|
29 class RadioUiEngine; |
|
30 class RadioStationModel; |
|
31 class RadioHistoryModel; |
|
32 class RadioPresetStorage; |
|
33 class RadioEngineWrapper; |
|
34 class RadioEngineWrapperObserver; |
|
35 |
|
36 class TestRadioUiEngine : public QObject, RadioEngineWrapperObserver |
|
37 { |
|
38 Q_OBJECT |
|
39 |
|
40 /** |
|
41 * Flags to indicate which slots have been entered since calling API method. |
|
42 * Declared to use QFlags<> to ease flag usage and to enforce type safety. |
|
43 */ |
|
44 enum SlotEnteredFlag |
|
45 { |
|
46 NoSlotsEntered = 0 |
|
47 ,StationDataChanged = 1 << 0 |
|
48 ,FavoriteChanged = 1 << 1 |
|
49 ,StationAdded = 1 << 2 |
|
50 ,DataChanged = 1 << 3 |
|
51 ,ItemAdded = 1 << 4 |
|
52 }; |
|
53 Q_DECLARE_FLAGS( Slots, SlotEnteredFlag ) |
|
54 |
|
55 public: |
|
56 |
|
57 TestRadioUiEngine(); |
|
58 ~TestRadioUiEngine(); |
|
59 |
|
60 public slots: |
|
61 void dataChanged(const QModelIndex topLeft, const QModelIndex bottomRight); |
|
62 void stationAdded( RadioStation addedStation ); |
|
63 void stationDataChanged( RadioStation station ); |
|
64 void favoriteChanged( RadioStation station ); |
|
65 void itemAdded(); |
|
66 |
|
67 private slots: |
|
68 // test framework called slots |
|
69 void initTestCase(); |
|
70 void init(); |
|
71 void cleanup(); |
|
72 void cleanupTestCase(); |
|
73 void testImplicitSharing(); |
|
74 void testChangeFlags(); |
|
75 void TestCallSignChar(); |
|
76 void testPICodeToCallSign(); |
|
77 void testRadioStationModel(); |
|
78 void testhistoryModel(); |
|
79 void testHistoryModelItem(); |
|
80 |
|
81 private: |
|
82 |
|
83 // from base class RadioEngineWrapperObserver |
|
84 void tunedToFrequency( uint frequency, int commandSender ); |
|
85 void seekingStarted( Seeking::Direction direction ); |
|
86 void radioStatusChanged( bool radioIsOn ); |
|
87 void rdsAvailabilityChanged( bool available ); |
|
88 void volumeChanged( int volume ); |
|
89 void muteChanged( bool muted ); |
|
90 void audioRouteChanged( bool loudspeaker ); |
|
91 void scanAndSaveFinished(); |
|
92 void headsetStatusChanged( bool connected ); |
|
93 void skipPrevious(); |
|
94 void skipNext(); |
|
95 // subfunctions used by the test framework called slots |
|
96 void testRadioStationModelInit(); |
|
97 void testAddStation1(); |
|
98 void testSaveStation1(); |
|
99 void testAddStation2(); |
|
100 void testSaveStation2(); |
|
101 void testAddStation3(); |
|
102 void testSaveStation3(); |
|
103 void testSortByFrequency(); |
|
104 void testFindPresetIndex(); |
|
105 void testRemoveByFrequency(); |
|
106 void testRemoveByPresetIndex(); |
|
107 void testRemoveStation(); |
|
108 |
|
109 void testSetFavorite(); |
|
110 |
|
111 void testRenameStation(); |
|
112 void testSetRadioTextPlus(); |
|
113 void testHistoryModelInit(); |
|
114 void testHistoryModelAddItem(); |
|
115 void testHistoryModelFindItem(); |
|
116 void testHistoryModelUpdateItem(); |
|
117 void testHistoryModelSetData(); |
|
118 void testAddRadioTextPlus(); |
|
119 void testClearRadioTextPlus(); |
|
120 void testRadioHistoryItem(); |
|
121 |
|
122 private: |
|
123 RadioUiEngine* mUiEngine; |
|
124 QScopedPointer<RadioEngineWrapper> mEngineWrapper; |
|
125 RadioStationModel* mRadioStationModel; |
|
126 RadioHistoryModel* mhistoryModel; |
|
127 QScopedPointer<RadioPresetStorage> mPresetStorage; |
|
128 int mExpectedStationCount; |
|
129 /** |
|
130 * Internal book keeping used to determine which slots have been entered since calling RadioStationModel |
|
131 * API method. Used to conclude if the correct signals from RadioStationModel have been received. |
|
132 */ |
|
133 Slots mEnteredSlots; |
|
134 QString mStationToBeAdded; |
|
135 QString mStationToBeSaved; |
|
136 }; |
|
137 |
|
138 #endif /* T_RADIOSTATION_H_ */ |
|