47 |
50 |
48 void UnitTestCxeHarvesterControlSymbian::testHarvestFile() |
51 void UnitTestCxeHarvesterControlSymbian::testHarvestFile() |
49 { |
52 { |
50 CX_DEBUG_ENTER_FUNCTION(); |
53 CX_DEBUG_ENTER_FUNCTION(); |
51 |
54 |
52 QSignalSpy harvestCompleteSpy(mHarvesterControl, SIGNAL(fileHarvested(const QString&, int))); |
55 QSignalSpy harvestCompleteSpy(mHarvesterControl, SIGNAL(fileHarvested(CxeError::Id, const QString&))); |
53 QString filename; |
56 QString filename; |
|
57 QVariantList initModeArguments; |
54 |
58 |
55 QVERIFY(harvestCompleteSpy.isValid()); |
59 QVERIFY(harvestCompleteSpy.isValid()); |
56 |
60 |
57 // case 1: testing with wrong dummy file, we should get an error code with harvestcomplete |
61 // case 1: testing with wrong dummy file, we should get an error code with harvestcomplete |
58 // since filename is invalid |
62 // since filename is invalid |
59 mHarvesterControl->harvestFile(filename, 0, 0); |
63 mHarvesterControl->harvestFile(filename, 0, 0); |
60 |
|
61 QCOMPARE( harvestCompleteSpy.count(), 1 ); |
64 QCOMPARE( harvestCompleteSpy.count(), 1 ); |
62 if (harvestCompleteSpy.count() > 0) { |
65 initModeArguments = harvestCompleteSpy.takeFirst(); |
63 QList<QVariant> initModeArguments = harvestCompleteSpy.takeFirst(); |
66 // we are only interested in error code in this case 1 |
64 // we are only interested in error code in this case 1 |
67 QCOMPARE(initModeArguments.at(0).value<CxeError::Id>(), CxeError::NotFound); |
65 QCOMPARE(initModeArguments.at(1).toInt(), KErrNotFound); |
|
66 } |
|
67 |
|
68 |
68 |
69 // case 2: testing with real filename, harvesting should go fine, callback without errors |
69 // case 2: testing with real filename, harvesting should go fine, callback without errors |
70 filename = QString("test.jpg"); |
70 filename = QString("test.jpg"); |
71 mHarvesterControl->harvestFile(filename, 0, 0); |
71 mHarvesterControl->harvestFile(filename, 0, 0); |
72 |
72 |
73 QCOMPARE( harvestCompleteSpy.count(), 1 ); |
73 QCOMPARE( harvestCompleteSpy.count(), 1 ); |
74 if (harvestCompleteSpy.count() > 0) { |
74 initModeArguments = harvestCompleteSpy.takeFirst(); |
75 QList<QVariant> initModeArguments = harvestCompleteSpy.takeFirst(); |
75 // we check both the filename, since in this case harvesting should go fine |
76 // we check both the filename, since in this case harvesting should go fine |
76 // and error returned is KErrNone. |
77 // and error returned is KErrNone. |
77 QCOMPARE(initModeArguments.at(0).value<CxeError::Id>(), CxeError::None); |
78 QCOMPARE(initModeArguments.at(1).toString(), filename); |
78 QCOMPARE(initModeArguments.at(1).toString(), filename); |
79 QCOMPARE(initModeArguments.at(1).toInt(), KErrNone); |
|
80 } |
|
81 |
79 |
82 CX_DEBUG_EXIT_FUNCTION(); |
80 CX_DEBUG_EXIT_FUNCTION(); |
83 } |
81 } |
84 |
82 |
85 |
83 |