/* @file @SYMTestCaseID SYSLIB-SCHSVR-CIT-0279 @SYMTestCaseDesc Persistant schedule - UTC & Hometime @SYMTestPriority High @SYMTestActions For time and condition based test schedule task and check it fires @SYMTestExpectedResults The test must not fail. @SYMPREQ PREQ234 */ TVerdict Cpersist_mixedStep::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Our implementation only gets called if the base class doTestStepPreambleL() did * not leave. That being the case, the current test result value will be EPass. */ { SetTestStepResult(EFail); _LIT(KTestName1, "Persistant Mixed - Hometime"); _LIT(KTaskData1, "This is some really exciting task data (number 1)"); _LIT(KTestName2, "Persistant Mixed - UTC"); _LIT(KTaskData2, "This is some really exciting task data (number 2)"); // Tests with timezone set to Europe, London RTz tz; tz.Connect(); CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London CleanupStack::PushL(tzId); tz.SetTimeZoneL(*tzId); // Set the time to a known value, since this makes testing much easier (and more // repeatable). SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am // Prepare schedules describing when we want the tasks to run (10:00 am & 10.00) // Creates a hometime based daily persistant schedule TSchedulerItemRef ref1; // This is the time when we want the Hometime time-based schedule to fire TDateTime datetime1(2000, EJanuary, 1, 11, 0, 0, 0); TTsTime startTimeForSchedule1(datetime1, EFalse); // 11:00 am { CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); CleanupStack::PushL(entryList); TScheduleEntryInfo2 entry1 (startTimeForSchedule1, EDaily, 1, 30); entryList->AppendL(entry1); TInt res = TheScheduler.CreatePersistentSchedule(ref1, *entryList); TESTL(res==KErrNone); CleanupStack::PopAndDestroy(); // entryList } // Disable the schedule whilst we set it up User::LeaveIfError(TheScheduler.DisableSchedule(ref1.iHandle)); // Creates a UTC based daily persistant schedule TSchedulerItemRef ref2; // This is the time when we want the UTC time-based schedule to fire TDateTime datetime2(2000, EJanuary, 1, 10, 0, 0, 0); TTsTime startTimeForSchedule2(datetime2, ETrue); // 10:00 am { CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); CleanupStack::PushL(entryList); TScheduleEntryInfo2 entry1 (startTimeForSchedule2, EDaily, 1, 30); entryList->AppendL(entry1); TInt res = TheScheduler.CreatePersistentSchedule(ref2, *entryList); TESTL(res==KErrNone); CleanupStack::PopAndDestroy(); // entryList } // Disable the schedule whilst we set it up User::LeaveIfError(TheScheduler.DisableSchedule(ref2.iHandle)); // Kill the server to check if persisted schedules have been stored // Need to turn off JIT dubugging as we are panicking server and we // want test to keep running. TBool jit = User::JustInTime(); User::SetJustInTime(EFalse); TheScheduler.__FaultServer(); // Change UTC Offset whilst server is down // Set UTC offset to +1Hr by moving to Europe, Paris tzId = CTzId::NewL(2656); //set the timezone to Europe/Paris tz.SetTimeZoneL(*tzId); User::After(1000000); // Turn on JIT again. User::SetJustInTime(jit); // Connect to the server again TInt res = TheScheduler.Connect(); TESTL(res==KErrNone); // Re-register TESTL(SchSvrHelpers::RegisterClientL(TheScheduler)==KErrNone); // Associate a task with the time-based schedule TTaskInfo taskInfo1; taskInfo1.iName = KTestName1; taskInfo1.iPriority = 2; taskInfo1.iRepeat = 0; // Create some data associated with this task HBufC* taskData1 = KTaskData1().AllocLC(); User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData1, ref1.iHandle)); CleanupStack::PopAndDestroy(); // taskData1 // Associate a task with the condition-based schedule TTaskInfo taskInfo2; taskInfo2.iName = KTestName2; taskInfo2.iPriority = 2; taskInfo2.iRepeat = 0; // Create some data associated with this task HBufC* taskData2 = KTaskData2().AllocLC(); User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo2, *taskData2, ref2.iHandle)); CleanupStack::PopAndDestroy(); // taskData2 // Set the UTC time such that both schedules fire at the same time SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 59, 50, 0))); // 9:59.50 am User::LeaveIfError(TheScheduler.EnableSchedule(ref1.iHandle)); User::LeaveIfError(TheScheduler.EnableSchedule(ref2.iHandle)); // Now wait for the time-based schedule to fire TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone); // Now wait for the condition-based schedule to fire TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone); TTime timeNow; timeNow.HomeTime(); TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, EFalse), startTimeForSchedule1)); timeNow.UniversalTime(); TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, ETrue), startTimeForSchedule2)); CleanupStack::PopAndDestroy(); // timezone ID CleanupHelpers::KillProcess(KMinimalTaskHandler); SetTestStepResult(EPass); return TestStepResult(); }
QString CriteriaEditor::getSearchCriteria() { QString searchCriteria; QString field = m_dbFields[ m_fieldCombo->currentItem() ]; QString criteria = m_criteriaCombo->currentText(); if( field.isEmpty() ) return QString::null; if ( ( field=="statistics.playcounter" || field=="statistics.rating" || field=="statistics.percentage" || field=="statistics.accessdate" || field=="statistics.createdate") ) searchCriteria += "COALESCE(" + field + ",0)"; else searchCriteria += field; QString value; switch( getValueType( m_fieldCombo->currentItem() ) ) { case String: case AutoCompletionString: value = m_lineEdit->text(); break; case Year: //fall through case Number: value = QString::number( m_intSpinBox1->value() ); if( criteria == i18n("is between") ) value += " AND " + QString::number( m_intSpinBox2->value() ); break; case Rating: { value = QString::number( indexToRating( m_comboBox->currentItem() ) ); if( criteria == i18n("is between") ) value += " AND " + QString::number( indexToRating( m_comboBox2->currentItem() ) ); break; } case Date: { if( criteria == i18n("is in the last") || criteria == i18n("is not in the last") ) { int n = m_intSpinBox1->value(); int time; if( m_dateCombo->currentItem() == 0 ) //days time=86400*n; else if( m_dateCombo->currentItem() == 1 ) //months time=86400*30*n; else time=86400*365*n; //years value += "(*CurrentTimeT*)" + QString(" - %1 AND ").arg(time) + "(*CurrentTimeT*)"; } else { QDateTime datetime1( m_dateEdit1->date() ); value += QString::number( datetime1.toTime_t() ); if( criteria == i18n("is between") ) { QDateTime datetime2( m_dateEdit2->date() ); value += " AND " + QString::number( datetime2.toTime_t() ); } else value += " AND " + QString::number( datetime1.addDays( 1 ).toTime_t() ); } break; } default: ; }; if( criteria == i18n("contains") ) searchCriteria += CollectionDB::likeCondition( value, true, true ); else if( criteria == i18n("does not contain") ) searchCriteria += " NOT " + CollectionDB::likeCondition( value, true, true ); else if( criteria == i18n("is") ) { if( m_currentValueType == Date ) searchCriteria += " BETWEEN "; else searchCriteria += " = "; if( m_currentValueType == String || m_currentValueType == AutoCompletionString ) value.prepend("'").append("'"); searchCriteria += value; } else if( criteria == i18n("is not") ) { if( m_currentValueType == Date ) searchCriteria += " NOT BETWEEN "; else searchCriteria += " <> "; if( m_currentValueType == String || m_currentValueType == AutoCompletionString ) value.prepend("'").append("'"); searchCriteria += value; } else if( criteria == i18n("starts with") ) searchCriteria += CollectionDB::likeCondition( value, false, true ); else if( criteria == i18n("ends with") ) searchCriteria += CollectionDB::likeCondition( value, true, false ); else if( criteria == i18n("is greater than") || criteria == i18n("is after") ) searchCriteria += " > " + value; else if( criteria == i18n("is smaller than") || criteria == i18n("is before" ) ) searchCriteria += " < " + value; else if( criteria == i18n("is between") || criteria == i18n("is in the last") ) searchCriteria += " BETWEEN " + value; else if( criteria == i18n("is not in the last") ) searchCriteria += " NOT BETWEEN " + value; return searchCriteria; }
TVerdict CInitialiseStep::doTestStepL() { SetTestStepResult(EFail); INFO_PRINTF1(_L("Scheduler BUR test Init")); TSchedulerItemRef ref,ref2; _LIT(KBackupCondition, "AddCondition"); TPtrC data; if (!GetStringFromConfig(ConfigSection(), KBackupCondition, data)) { ERR_PRINTF1(KMissingInputParam); SetTestStepResult(EFail); User::Leave(KErrCorrupt); } _LIT(KTimeStr, "Time"); _LIT(KTestStr, "Test"); _LIT(KBackupStr, "Backup"); _LIT(KRestoreStr, "Restore"); _LIT(KRestoreStr1, "Restore1"); if (data == KTimeStr) { // Creates a time based schedule _LIT(KSchTestName, "Persistent Schedule Test (Time)"); // This is the time when we want the time-based schedule to fire TDateTime datetime1(2000, EJanuary, 1, 10, 0, 0, 0); TTsTime dueTime(datetime1, EFalse); AddTimeScheduleL(KSchTestName, dueTime, ref); _LIT(KSchTestName2, "Transient Time Schedule Test"); AddTransientTimeScheduleL(KSchTestName2, dueTime, ref2); } else { // Creates a condition based schedule _LIT(KSchTestName, "Persistent Schedule Test (Condition)"); // If condition not met, task is run one year from now. TDateTime datetime1(2001, EJanuary, 1, 10, 0, 0, 0); TTsTime dueTime(datetime1, EFalse); CSchConditionArray* conditionList = new (ELeave) CSchConditionArray(2); CleanupStack::PushL(conditionList); if (data == KTestStr) { CreatePSKeyL(KTestKey1); AddTestConditionL(*conditionList, KTestKey1); AddConditionScheduleL(KSchTestName, dueTime, ref, *conditionList); } else if (data == KBackupStr) { // Only create sema if condition not triggered by test but by SBE iSem.CreateL(); CreatePSKeyL(conn::KUidBackupRestoreKey); AddBackupConditionL(*conditionList); AddConditionScheduleL(KSchTestName, dueTime, ref, *conditionList); } else if (data == KRestoreStr || data == KRestoreStr1) { // Only create sema if condition not triggered by test but by SBE TRAPD(ignoreifalreadycreated, iSem.CreateL()); if (ignoreifalreadycreated != KErrNone && ignoreifalreadycreated != KErrAlreadyExists) { User::Leave(ignoreifalreadycreated); } CreatePSKeyL(conn::KUidBackupRestoreKey); AddRestoreConditionL(*conditionList); if (data==KRestoreStr1) { AddTransientConditionScheduleL(KSchTestName, dueTime,*conditionList); } else { AddConditionScheduleL(KSchTestName, dueTime, ref, *conditionList); } } else { SetTestStepResult(EFail); User::Leave(KErrCorrupt); } CleanupStack::PopAndDestroy(conditionList); } SetTestStepResult(EPass); return TestStepResult(); }