|
1 /* |
|
2 * Copyright (c) 2010 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 #include <QObject> |
|
19 #include <QString> |
|
20 #include <QFile> |
|
21 |
|
22 #include "t_hsdomainmodel.h" |
|
23 #include "hswallpaperloaderthread.h" |
|
24 |
|
25 void TestHsDomainModel::testHsWallpaperLoaderThreadConstruction() |
|
26 { |
|
27 { |
|
28 HsWallpaperLoaderThread thread; |
|
29 QVERIFY(!thread.parent()); |
|
30 } |
|
31 |
|
32 { |
|
33 QObject parent; |
|
34 HsWallpaperLoaderThread thread(&parent); |
|
35 QVERIFY(thread.parent() == &parent); |
|
36 } |
|
37 |
|
38 HsWallpaperLoaderThread *thread = new HsWallpaperLoaderThread; |
|
39 QVERIFY(thread); |
|
40 QVERIFY(!thread->parent()); |
|
41 delete thread; |
|
42 |
|
43 QObject *parent = new QObject(); |
|
44 thread = new HsWallpaperLoaderThread(parent); |
|
45 QVERIFY(thread); |
|
46 QVERIFY(thread->parent() == parent); |
|
47 delete parent; |
|
48 } |
|
49 |
|
50 void TestHsDomainModel::testHsWallpaperLoaderThreadRun() |
|
51 { |
|
52 //Test preparation |
|
53 cleanupTargetWallpaperFiles(); |
|
54 |
|
55 HsWallpaperLoaderThread *thread = new HsWallpaperLoaderThread; |
|
56 |
|
57 //TEST OF FILE WHICH DOES NOT EXIST |
|
58 QVERIFY(!QFile::exists(notExistingTestWallpaper())); |
|
59 thread->setSourcePath(notExistingTestWallpaper()); |
|
60 thread->setTargetSize(QSize(360, 640)); |
|
61 thread->setTargetPath(tempTestWallpaper()); |
|
62 thread->run(); |
|
63 //Check that temp file is not created and result is false |
|
64 QVERIFY(!thread->result()); |
|
65 QVERIFY(!QFile::exists(tempTestWallpaper())); |
|
66 |
|
67 //TEST OF FILE WHICH EXISTS |
|
68 //Check that test file exist |
|
69 QVERIFY(QFile::exists(sourceTestWallpaper())); |
|
70 thread->setSourcePath(sourceTestWallpaper()); |
|
71 thread->setTargetSize(QSize(360, 640)); |
|
72 thread->setTargetPath(tempTestWallpaper()); |
|
73 thread->run(); |
|
74 //Check that temp file is created and result is true |
|
75 QVERIFY(thread->result()); |
|
76 QVERIFY(QFile::exists(tempTestWallpaper())); |
|
77 //Clear created temp file |
|
78 cleanupTargetWallpaperFiles(); |
|
79 |
|
80 delete thread; |
|
81 } |