devicediagnostics/devdiagapp/inc/devdiagexecutionresults.h
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2007 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:  This is the declaration of the execution results class used
       
    15 *                by the Device Diagnostics Application to present a common interface
       
    16 *                for results information to the application.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef DEVDIAGEXECUTIONRESULTS_H
       
    22 #define DEVDIAGEXECUTIONRESULTS_H
       
    23 
       
    24 // System Include Files
       
    25 #include <e32base.h>                // CBase
       
    26 #include <e32cmn.h>                 // RPointerArray, TUid
       
    27 
       
    28 // Forward Declarations
       
    29 class MDiagEngineCommon;
       
    30 class MDiagPlugin;
       
    31 class MPDResultsObserver;
       
    32 class CDiagResultsDatabaseItem;
       
    33 class CDiagPluginPool;
       
    34 class RDiagResultsDatabase;
       
    35 
       
    36 /**
       
    37  *  Device Diagnostics Execution Results Class.
       
    38  *  This class presents a common interface to the application for results from
       
    39  *  both live test runs as well as from the results database.
       
    40  *
       
    41  *  @lib diagresultsdatabase.lib
       
    42  *  @lib diagframework.lib
       
    43  */
       
    44 class CDevDiagExecResults : public CBase
       
    45     {
       
    46 
       
    47 public: // Nested Classes
       
    48 
       
    49     /**
       
    50      *  Device Diagnostics Execution Results Information Class.
       
    51      *  This class provides a common interface to individual results
       
    52      *  information from either live execution or the results database.
       
    53      */
       
    54     class CResult : public CBase
       
    55         {
       
    56 
       
    57     public: // New Functions
       
    58 
       
    59         /**
       
    60          * Two-phased constructor.
       
    61          *
       
    62          * @param aPlugin The plugin that this result corresponds to.
       
    63          * @return A pointer to the newly-created instance of CResult.
       
    64          */
       
    65         static CResult* NewL( const MDiagPlugin& aPlugin );
       
    66 
       
    67         /**
       
    68          * Two-phased constructor.
       
    69          *
       
    70          * @param aPlugin The plugin that this result corresponds to.
       
    71          * @return A pointer to the newly-created instance of CResult.
       
    72          */
       
    73         static CResult* NewLC( const MDiagPlugin& aPlugin );
       
    74 
       
    75         /**
       
    76          * Destructor.
       
    77          */
       
    78         virtual ~CResult();
       
    79 
       
    80         /**
       
    81          * Returns the pointer to the test result.  This may be NULL if the
       
    82          * item is a suite or has not been run yet.  The client must not
       
    83          * delete this pointer.
       
    84          *
       
    85          * @return A pointer to the test result for this item, or NULL.
       
    86          */
       
    87         const CDiagResultsDatabaseItem* Result() const;
       
    88 
       
    89         /**
       
    90          * Returns a reference to the plugin that corresponds to this item.
       
    91          *
       
    92          * @return A reference to the plugin that corresponds to this item.
       
    93          */
       
    94         const MDiagPlugin& Plugin() const;
       
    95 
       
    96         /**
       
    97          * Returns the execution status (error value) for this plugin.  This
       
    98          * will only contain meaningful data for live test executions.
       
    99          *
       
   100          * @return The execution status (error value) for this plugin
       
   101          */
       
   102         TInt ExecStatus() const;
       
   103 
       
   104         /**
       
   105          * Returns the current execution step for this plugin.  This will only
       
   106          * contain meaningful data for live test executions.
       
   107          *
       
   108          * @return The current execution step for this plugin.
       
   109          */
       
   110         TUint CurrentStep() const;
       
   111 
       
   112         /**
       
   113          * Returns the total number of execution steps for this plugin.
       
   114          *
       
   115          * @return The total number of execution steps for this plugin.
       
   116          */
       
   117         TUint TotalSteps() const;
       
   118 
       
   119         /**
       
   120          * Sets the result information for this plugin.  Ownership of the
       
   121          * result is transferred.  If the result was previously set, it will
       
   122          * be deleted and replaced with the new data.
       
   123          *
       
   124          * @param aResult The test result.
       
   125          * @param aError The execution status error value.
       
   126          */
       
   127         void SetResult( CDiagResultsDatabaseItem* aResult, TInt aError );
       
   128 
       
   129         /**
       
   130          * Sets the test progress information.
       
   131          *
       
   132          * @param aCurrentStep The current execution step for this plugin.
       
   133          * @param aCurrentStep The total number of execution steps for this
       
   134          *                     plugin.
       
   135          */
       
   136         void SetProgress( TUint aCurrentStep, TUint aTotalSteps );
       
   137 
       
   138 
       
   139     private: // New Functions
       
   140 
       
   141         /**
       
   142          * Default constructor.
       
   143          *
       
   144          * @param aPlugin The plugin that this result corresponds to.
       
   145          */
       
   146         CResult( const MDiagPlugin& aPlugin );
       
   147 
       
   148         /**
       
   149          * Two-phased constructor.
       
   150          */
       
   151         void ConstructL();
       
   152 
       
   153 
       
   154     private: // Data
       
   155 
       
   156         /**
       
   157          * The test results information.
       
   158          * Own.
       
   159          */
       
   160         CDiagResultsDatabaseItem* iResult;
       
   161 
       
   162         /**
       
   163          * A reference to the plugin that this result corresponds to.
       
   164          */
       
   165         const MDiagPlugin& iPlugin;
       
   166 
       
   167         /**
       
   168          * The test execution status (error value).
       
   169          */
       
   170         TInt iExecStatus;
       
   171 
       
   172         /**
       
   173          * The current step in the execution of this plugin.
       
   174          */
       
   175         TUint iCurrentStep;
       
   176 
       
   177         /**
       
   178          * The total number of steps in the execution of this plugin.
       
   179          */
       
   180         TUint iTotalSteps;
       
   181 
       
   182         };
       
   183 
       
   184 
       
   185 public: // New Functions
       
   186 
       
   187     /**
       
   188      * Two-phased constructor.  This creates an execution results object by
       
   189      * loading test results from the Results Database (logged results).
       
   190      *
       
   191      * @param aRecordId The unique record identifier from the results database
       
   192      *                  for this set of results.
       
   193      * @param aPluginPool A reference to the plugin pool, which is used for
       
   194      *                    getting plugin information.
       
   195      * @param aDbSession A reference to an open session with the results
       
   196      *                   database server.
       
   197      * @return A pointer to the newly-created instance of CDevDiagExecResults.
       
   198      */
       
   199     static CDevDiagExecResults* NewL( TUid aRecordId,
       
   200                                       CDiagPluginPool& aPluginPool,
       
   201                                       RDiagResultsDatabase& aDbSession );
       
   202 
       
   203     /**
       
   204      * Two-phased constructor.  This creates an execution results object by
       
   205      * getting test results from live execution.  The results objects are
       
   206      * created from the diagnostics engine's execution plan, and updated as
       
   207      * tests complete.
       
   208      *
       
   209      * @param aRecordId The unique record identifier from the results database
       
   210      *                  for this set of results.
       
   211      * @param aPluginPool A reference to the plugin pool, which is used for
       
   212      *                    getting plugin information.
       
   213      * @param aDbSession A reference to an open session with the results
       
   214      *                   database server.
       
   215      * @param aExecutedUid The uid of the plugin that was executed to produce
       
   216      *                     these test results.
       
   217      * @param aDiagEngine A pointer to the diagnostics engine, which is only
       
   218      *                    used to get the execution plan during live test
       
   219      *                    runs.
       
   220      * @return A pointer to the newly-created instance of CDevDiagExecResults.
       
   221      */
       
   222     static CDevDiagExecResults* NewL( TUid aRecordId,
       
   223                                       CDiagPluginPool& aPluginPool,
       
   224                                       RDiagResultsDatabase& aDbSession,
       
   225                                       TUid aExecutedUid,
       
   226                                       MDiagEngineCommon* aDiagEngine );
       
   227 
       
   228     /**
       
   229      * Destructor.
       
   230      */
       
   231     virtual ~CDevDiagExecResults();
       
   232 
       
   233     /**
       
   234      * This function is used to set the result for the current execution plan
       
   235      * index.  It is only valid for live test executions.  Ownership of the
       
   236      * result is transferred.  If called multiple times for the same plugin,
       
   237      * each suqsequent call deletes and overwrites the previous result data.
       
   238      *
       
   239      * @param aResult The test result.
       
   240      * @param aStatus The execution status error value.
       
   241      */
       
   242     void AddEntryL( CDiagResultsDatabaseItem* aResult, TInt aStatus );
       
   243 
       
   244     /**
       
   245      * Sets the test progress information for the current execution plan
       
   246      * index.
       
   247      *
       
   248      * @param aCurrentStep The current execution step for this plugin.
       
   249      * @param aCurrentStep The total number of execution steps for this
       
   250      *                     plugin.
       
   251      */
       
   252     void SetProgressL( TUint aCurrentStep, TUint aTotalSteps );
       
   253 
       
   254     /**
       
   255      * Retrieves the CResult reference at the specified index.
       
   256      *
       
   257      * @param aIndex The index of the result to retrieve.
       
   258      * @return A reference to the CResult object at the index.
       
   259      */
       
   260     CResult& operator[] ( TInt aIndex );
       
   261     const CResult& operator[] ( TInt aIndex ) const;
       
   262 
       
   263     /**
       
   264      * Retrieves the CResult reference at the current index.  For live
       
   265      * execution runs, this is determined from the test execution plan.  For
       
   266      * logged results, this is always the last item.
       
   267      *
       
   268      * @return A reference to the CResult object.
       
   269      */
       
   270     CResult& CurrentItemL();
       
   271     const CResult& CurrentItemL() const;
       
   272 
       
   273     /**
       
   274      * Returns the number of result items.
       
   275      *
       
   276      * @return The number of result items.
       
   277      */
       
   278     TInt Count() const;
       
   279 
       
   280     /**
       
   281      * Returns the index of the current result item.  For live execution runs,
       
   282      * this is determined from the test execution plan.  For logged results,
       
   283      * this is always the last item.
       
   284      *
       
   285      * @return The index of the current execution item.
       
   286      */
       
   287     TUint CurrentIndexL() const;
       
   288 
       
   289     /**
       
   290      * Checks if the diagnostics engine has finished the last test.
       
   291      *
       
   292      * @return ETrue if the last test has finished and the diagnostics engine
       
   293      *         is cleaning up.
       
   294      */
       
   295     TBool LastTestFinishedL() const;
       
   296 
       
   297     /**
       
   298      * Returns whether or not the item specified by the argument is (or was)
       
   299      * executed as a dependency test.
       
   300      *
       
   301      * @param aIndex The index of the item to check for dependency execution.
       
   302      * @return ETrue if the item is (or was) a dependency, EFalse otherwise.
       
   303      */
       
   304     TBool IsDependencyL( TInt aIndex ) const;
       
   305 
       
   306     /**
       
   307      * Returns whether or not the results are from a completed test record.
       
   308      *
       
   309      * @return ETrue if the results are from a completed test record, EFalse
       
   310      *         otherwise.
       
   311      */
       
   312     TBool IsRecordCompleted() const;
       
   313 
       
   314     /**
       
   315      * Finalizes live execution results so that they may not be updated.
       
   316      *
       
   317      * @param aTestingComplete Indicates if all tests in the record were
       
   318      *                         executed.
       
   319      */
       
   320     void Finalize( TBool aTestingComplete );
       
   321 
       
   322     /**
       
   323      * Returns the total number of steps for all items in the execution
       
   324      * results.
       
   325      *
       
   326      * @return The total number of steps for all items in the execution
       
   327      *         results.
       
   328      */
       
   329     TInt TotalExecutionSteps() const;
       
   330 
       
   331     /**
       
   332      * Returns the current execution step based on all items in the execution
       
   333      * results.
       
   334      *
       
   335      * @return The current execution step based on all items in the execution
       
   336      *         results.
       
   337      */
       
   338     TInt CurrentExecutionStep() const;
       
   339 
       
   340     /**
       
   341      * Returns a reference to the plugin that the engine was asked to execute.
       
   342      * The engine must be executing plugins for this to be valid.
       
   343      *
       
   344      * @return A reference to the plugin that the engine was asked to execute.
       
   345      */
       
   346     const MDiagPlugin& ExecutedPluginL() const;
       
   347 
       
   348     /**
       
   349      * Returns whether or not the execution is for a single plugin.
       
   350      *
       
   351      * @return ETrue if the execution is for a single plugin.
       
   352      */
       
   353     TBool SinglePluginExecutionL() const;
       
   354 
       
   355     /**
       
   356      * Returns the number of failed tests in this set of results.
       
   357      *
       
   358      * @return The number of failed tests in this set of results.
       
   359      */
       
   360     TInt FailedResultsCount() const;
       
   361     
       
   362     /**
       
   363      * Returns the number of passed tests in this set of results.
       
   364      *
       
   365      * @return The number of passed tests in this set of results.
       
   366      */
       
   367     TInt PassedResultsCount() const;
       
   368 
       
   369     /**
       
   370      * Returns whether or not the execution plan's resume index has been
       
   371      * reached.  This value indicates if the diagnostics engine is still
       
   372      * updating the application with cached test results.
       
   373      *
       
   374      * @return ETrue if the execution plan's resume index has been reached.
       
   375      */
       
   376     TBool ResumeIndexReachedL() const;
       
   377 
       
   378     /**
       
   379      * Returns the UID of the record associated with this set of results.
       
   380      *
       
   381      * @return The UID of the record associated with this set of results.
       
   382      */
       
   383     const TUid& RecordId() const;
       
   384     
       
   385 // ADO & Platformization Changes   
       
   386     const CDiagResultsDatabaseItem* GetSinglepluginExecutionResult() const;
       
   387 
       
   388 
       
   389 private: // Data Types
       
   390 
       
   391     /**  Enum to indicate what type of results data this object contains. */
       
   392     enum TResultsType
       
   393         {
       
   394         ETypeExecution,
       
   395         ETypeLog
       
   396         };
       
   397 
       
   398 
       
   399 private: // New Functions
       
   400 
       
   401     /**
       
   402      * Default constructor.
       
   403      *
       
   404      * @param aRecordId The unique record identifier from the results database
       
   405      *                  for this set of results.
       
   406      * @param aPluginPool A reference to the plugin pool, which is used for
       
   407      *                    getting plugin information.
       
   408      * @param aExecutedUid The uid of the plugin that was executed to produce
       
   409      *                     these test results.  This is ignored for logged
       
   410      *                     test results.
       
   411      * @param aDiagEngine A pointer to the diagnostics engine, which is only
       
   412      *                    used to get the execution plan during live test
       
   413      *                    runs.  This must be NULL for logged test results.
       
   414      */
       
   415     CDevDiagExecResults( TUid aRecordId,
       
   416                          CDiagPluginPool& aPluginPool,
       
   417                          RDiagResultsDatabase& aDbSession,
       
   418                          TUid aExecutedUid = KNullUid,
       
   419                          MDiagEngineCommon* aDiagEngine = NULL );
       
   420 
       
   421     /**
       
   422      * Two-phased constructor.
       
   423      */
       
   424     void ConstructL();
       
   425 
       
   426 
       
   427 private: // Data
       
   428 
       
   429     /**
       
   430      * The type of results data contained by this object.
       
   431      */
       
   432     TResultsType iType;
       
   433 
       
   434     /**
       
   435      * The array of results data.
       
   436      */
       
   437     RPointerArray< CResult > iResults;
       
   438 
       
   439     /**
       
   440      * The results database UID that corresponds to this test record.
       
   441      */
       
   442     TUid iRecordId;
       
   443 
       
   444     /**
       
   445      * The plugin pool, used to get information about test plugins.
       
   446      */
       
   447     CDiagPluginPool& iPluginPool;
       
   448 
       
   449     /**
       
   450      * A reference to an open database session.  This object does not close
       
   451      * the database session; it may only use it and create subsessions.
       
   452      */
       
   453     RDiagResultsDatabase& iDbSession;
       
   454 
       
   455     /**
       
   456      * A pointer to the diagnostics engine, used only to get the execution
       
   457      * plan for live test exections.
       
   458      * Not own.
       
   459      */
       
   460     MDiagEngineCommon* iDiagEngine;
       
   461 
       
   462     /**
       
   463      * The total number of test steps in the entire execution.
       
   464      */
       
   465     TInt iTotalSteps;
       
   466 
       
   467     /**
       
   468      * The total number of test steps in the entire execution.
       
   469      */
       
   470     TInt iCompletedSteps;
       
   471 
       
   472     /**
       
   473      * The test step that the currently-executing plugin is on.  This is not
       
   474      * combined with "iCompletedSteps" because plugins may be suspended and
       
   475      * restarted before they finally complete.
       
   476      */
       
   477     TInt iCurrentPluginStep;
       
   478 
       
   479     /**
       
   480      * The UID of the plugin executed to produce these results.  This is
       
   481      * obtained from the test record during construction.
       
   482      */
       
   483     TUid iExecutedPlugin;
       
   484 
       
   485     /**
       
   486      * The status of the record that corresponds to these test results.  A
       
   487      * record is fully completed only when all tests in it have been executed,
       
   488      * or the user decides not to resume it after suspending it.  This data is
       
   489      * obtained from the Finalize() function for live executions and from the
       
   490      * database for logged results.
       
   491      */
       
   492     TBool iCompleted;
       
   493 
       
   494     /**
       
   495      * The number of failed tests in these test results.  This data is
       
   496      * obtained from the AddEntryL() function for live executions and from the
       
   497      * database for logged results.
       
   498      */
       
   499     TInt iFailedCount;
       
   500     
       
   501     /**
       
   502       * The number of passed tests in these test results.  This data is
       
   503       * obtained from the AddEntryL() function for live executions and from the
       
   504       * database for logged results.
       
   505       */
       
   506      TInt iPassedCount;
       
   507 
       
   508     /**
       
   509      * The index value of the last test plugin in the results array.  This is
       
   510      * used to check if the last test has finished.
       
   511      */
       
   512     TInt iLastTestIndex;
       
   513 
       
   514     };
       
   515 
       
   516 #endif // PDEXECUTIONRESULTS_H