|
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 //USER |
|
19 #include "ut_logscomponentrepository.h" |
|
20 #include "logsrecentcallsview.h" |
|
21 #include "logsdetailsview.h" |
|
22 #include "logsmatchesview.h" |
|
23 #include "logscomponentrepository.h" |
|
24 #include "logsdefs.h" |
|
25 |
|
26 //SYSTEM |
|
27 #include <QtTest/QtTest> |
|
28 #include <hbmainwindow.h> |
|
29 |
|
30 void UT_LogsComponentRepository::initTestCase() |
|
31 { |
|
32 mMainWindow = new HbMainWindow(); |
|
33 mViewManager = new LogsViewManagerStub(*mMainWindow); |
|
34 } |
|
35 |
|
36 void UT_LogsComponentRepository::cleanupTestCase() |
|
37 { |
|
38 delete mMainWindow; |
|
39 delete mViewManager; |
|
40 } |
|
41 |
|
42 |
|
43 void UT_LogsComponentRepository::init() |
|
44 { |
|
45 mRepository = new LogsComponentRepository(*mViewManager); |
|
46 } |
|
47 |
|
48 void UT_LogsComponentRepository::cleanup() |
|
49 { |
|
50 delete mRepository; |
|
51 mRepository = 0; |
|
52 } |
|
53 |
|
54 void UT_LogsComponentRepository::testConstructor() |
|
55 { |
|
56 QVERIFY( !mRepository->mRecentCallsView ); |
|
57 QVERIFY( !mRepository->mDetailsView ); |
|
58 QVERIFY( !mRepository->mMatchesView ); |
|
59 QVERIFY( !mRepository->mDialpad ); |
|
60 QVERIFY( !mRepository->mDialpadKeyHandler ); |
|
61 QVERIFY( mRepository->mModel ); |
|
62 } |
|
63 |
|
64 void UT_LogsComponentRepository::testRecentCallsView() |
|
65 { |
|
66 //loading view |
|
67 QVERIFY( !mRepository->mRecentCallsView ); |
|
68 QVERIFY( mRepository->mRecentViewComponents.count() == 0 ); |
|
69 LogsRecentCallsView* view = mRepository->recentCallsView(); |
|
70 QVERIFY( view ); |
|
71 QCOMPARE( view->objectName(), QString( logsRecentCallsViewId ) ); |
|
72 |
|
73 //view already loaded |
|
74 LogsRecentCallsView* view2 = mRepository->recentCallsView(); |
|
75 QVERIFY( view == view2 ); |
|
76 delete view; |
|
77 } |
|
78 |
|
79 void UT_LogsComponentRepository::testDetailsView() |
|
80 { |
|
81 //loading view |
|
82 QVERIFY( !mRepository->mDetailsView ); |
|
83 QVERIFY( mRepository->mDetailsViewComponents.count() == 0 ); |
|
84 LogsDetailsView* view = mRepository->detailsView(); |
|
85 QVERIFY( view ); |
|
86 QCOMPARE( view->objectName(), QString( logsDetailsViewId ) ); |
|
87 |
|
88 //view already loaded |
|
89 LogsDetailsView* view2 = mRepository->detailsView(); |
|
90 QVERIFY( view == view2 ); |
|
91 delete view; |
|
92 } |
|
93 |
|
94 void UT_LogsComponentRepository::testMatchesView() |
|
95 { |
|
96 //loading view |
|
97 QVERIFY( !mRepository->mMatchesView ); |
|
98 QVERIFY( mRepository->mMatchesViewComponents.count() == 0 ); |
|
99 LogsMatchesView* view = mRepository->matchesView(); |
|
100 QVERIFY( view ); |
|
101 QCOMPARE( view->objectName(), QString( logsMatchesViewId ) ); |
|
102 |
|
103 //view already loaded |
|
104 LogsMatchesView* view2 = mRepository->matchesView(); |
|
105 QVERIFY( view == view2 ); |
|
106 delete view; |
|
107 } |
|
108 |
|
109 void UT_LogsComponentRepository::testDialpad() |
|
110 { |
|
111 //first call, dialpad and dialpadkeyhandler created as a result of the call |
|
112 QVERIFY( !mRepository->mDialpad ); |
|
113 QVERIFY( !mRepository->mDialpadKeyHandler ); |
|
114 Dialpad* dialpad = mRepository->dialpad(); |
|
115 QVERIFY( dialpad ); |
|
116 QVERIFY( dialpad == mRepository->mDialpad ); |
|
117 QVERIFY( mRepository->mDialpadKeyHandler ); |
|
118 DialpadKeyHandler* prevKeyHandler = mRepository->mDialpadKeyHandler; |
|
119 //all the next calls, return the same instance of the dialer |
|
120 QVERIFY( dialpad == mRepository->dialpad() ); |
|
121 QVERIFY( prevKeyHandler == mRepository->mDialpadKeyHandler ); |
|
122 } |
|
123 |
|
124 void UT_LogsComponentRepository::testLoadSection() |
|
125 { |
|
126 //Unknow viewId, section is not loaded |
|
127 QVERIFY( !mRepository->loadSection(LogsUnknownViewId, "default") ); |
|
128 |
|
129 //loading of non-existing section |
|
130 QVERIFY( mRepository->loadSection(LogsDetailsViewId, "dummy") ); |
|
131 |
|
132 //loading of existing section is ok |
|
133 mRepository->matchesView(); |
|
134 QVERIFY( mRepository->loadSection(LogsMatchesViewId, "default") ); |
|
135 mRepository->recentCallsView(); |
|
136 QVERIFY( mRepository->loadSection(LogsRecentViewId, "default") ); |
|
137 } |
|
138 |
|
139 void UT_LogsComponentRepository::testAddToolbarToObjectList() |
|
140 { |
|
141 //toolbar widget not found in docml |
|
142 QVERIFY( mRepository->mRecentViewComponents.count() == 0 ); |
|
143 mRepository->addToolbarToObjectList( mRepository->mRecentViewComponents ); |
|
144 QVERIFY( mRepository->mRecentViewComponents.count() == 0 ); |
|
145 |
|
146 //toolbar found and added to object list |
|
147 LogsRecentCallsView* view = mRepository->recentCallsView(); |
|
148 mRepository->mRecentViewComponents.clear(); |
|
149 mRepository->addToolbarToObjectList( mRepository->mRecentViewComponents ); |
|
150 QVERIFY( mRepository->mRecentViewComponents.count() == 1 ); |
|
151 QVERIFY( mRepository->mRecentViewComponents.at(0)->objectName() == logsToolbarId ); |
|
152 delete view; |
|
153 } |