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 "ut_logsforegroundwatcher.h" |
|
18 #include "logsforegroundwatcher.h" |
|
19 |
|
20 #include <QtTest/QtTest> |
|
21 #include <coemain.h> |
|
22 |
|
23 CCoeEnv* testEnv = 0; |
|
24 |
|
25 CCoeEnv* CCoeEnv::Static() |
|
26 { |
|
27 testEnv = new CCoeEnv(); |
|
28 return testEnv; |
|
29 } |
|
30 |
|
31 CCoeEnv::CCoeEnv() : CActive(EPriorityNormal) |
|
32 { |
|
33 |
|
34 } |
|
35 |
|
36 CCoeEnv::~CCoeEnv() |
|
37 { |
|
38 } |
|
39 |
|
40 void CCoeEnv::AddForegroundObserverL(MCoeForegroundObserver& /*aForegroundObserver*/) |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 void UT_LogsForegroundWatcher::initTestCase() |
|
46 { |
|
47 } |
|
48 |
|
49 void UT_LogsForegroundWatcher::cleanupTestCase() |
|
50 { |
|
51 delete testEnv; |
|
52 testEnv = 0; |
|
53 } |
|
54 |
|
55 void UT_LogsForegroundWatcher::init() |
|
56 { |
|
57 mWatcher = new LogsForegroundWatcher(); |
|
58 } |
|
59 |
|
60 void UT_LogsForegroundWatcher::cleanup() |
|
61 { |
|
62 delete mWatcher; |
|
63 } |
|
64 |
|
65 void UT_LogsForegroundWatcher::testConstructor() |
|
66 { |
|
67 QVERIFY( mWatcher ); |
|
68 } |
|
69 |
|
70 void UT_LogsForegroundWatcher::testHandleLosingForeground() |
|
71 { |
|
72 QSignalSpy spyGaining( mWatcher, SIGNAL(gainingForeground()) ); |
|
73 QSignalSpy spyLosing( mWatcher, SIGNAL(losingForeground()) ); |
|
74 mWatcher->HandleLosingForeground(); |
|
75 QVERIFY( spyGaining.count() == 0 ); |
|
76 QVERIFY( spyLosing.count() == 1 ); |
|
77 } |
|
78 |
|
79 void UT_LogsForegroundWatcher::testHandleGainingForeground() |
|
80 { |
|
81 QSignalSpy spyGaining( mWatcher, SIGNAL(gainingForeground()) ); |
|
82 QSignalSpy spyLosing( mWatcher, SIGNAL(losingForeground()) ); |
|
83 mWatcher->HandleGainingForeground(); |
|
84 QVERIFY( spyGaining.count() == 1 ); |
|
85 QVERIFY( spyLosing.count() == 0 ); |
|
86 } |
|
87 |
|