Home | History | Annotate | Download | only in util
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.compatibility.common.util;
     17 
     18 import java.util.List;
     19 
     20 /**
     21  * Data structure for a Compatibility test module result.
     22  */
     23 public interface IModuleResult extends Comparable<IModuleResult> {
     24 
     25     String getId();
     26 
     27     String getName();
     28 
     29     String getAbi();
     30 
     31     void addRuntime(long elapsedTime);
     32 
     33     void resetRuntime();
     34 
     35     long getRuntime();
     36 
     37     /**
     38      * Get the estimate of not-executed tests for this module. This estimate is a maximum
     39      * not-executed count, assuming all test runs have been started.
     40      * @return estimate of not-executed tests
     41      */
     42     int getNotExecuted();
     43 
     44     /**
     45      * Set the estimate of not-executed tests for this module. This estimate is a maximum
     46      * not-executed count, assuming all test runs have been started.
     47      * @param estimate of not-executed tests
     48      */
     49     void setNotExecuted(int numTests);
     50 
     51     /**
     52      * Whether all expected tests have been executed and all expected test runs have been seen
     53      * and completed.
     54      *
     55      * @return the comprehensive completeness status of the module
     56      */
     57     boolean isDone();
     58 
     59     /**
     60      * Whether all expected tests have been executed for the test runs seen so far.
     61      *
     62      * @return the completeness status of the module so far
     63      */
     64     boolean isDoneSoFar();
     65 
     66     /**
     67      * Explicitly sets the "done" status for this module. To be used when constructing this
     68      * instance from an XML report. The done status for an {@link IModuleResult} can be changed
     69      * indiscriminately by method setDone(boolean) immediately after a call to initializeDone,
     70      * whereas the status may only be switched to false immediately after a call to setDone.
     71      *
     72      * @param done the initial completeness status of the module
     73      */
     74     void initializeDone(boolean done);
     75 
     76     /**
     77      * Sets the "done" status for this module. To be used after each test run for the module.
     78      * After setDone is used once, subsequent calls to setDone will AND the given value with the
     79      * existing done status value. Thus a module with "done" already set to false cannot be marked
     80      * done unless re-initialized (see initializeDone).
     81      *
     82      * @param done the completeness status of the module for a test run
     83      */
     84     void setDone(boolean done);
     85 
     86     /**
     87      * Sets the "in-progress" status for this module. Useful for tracking completion of the module
     88      * in the case that a test run begins but never ends.
     89      *
     90      * @param inProgress whether the module is currently in progress
     91      */
     92     void inProgress(boolean inProgress);
     93 
     94     /**
     95      * @return the number of expected test runs for this module in this invocation
     96      */
     97     int getExpectedTestRuns();
     98 
     99     /**
    100      * @param the number of expected test runs for this module in this invocation
    101      */
    102     void setExpectedTestRuns(int numRuns);
    103 
    104     /**
    105      * @return the number of test runs seen for this module in this invocation
    106      */
    107     int getTestRuns();
    108 
    109     /**
    110      * Adds to the count of test runs seen for this module in this invocation
    111      */
    112     void addTestRun();
    113 
    114     /**
    115      * Reset the count of test runs seen for this module in this invocation. Should be performed
    116      * after merging the module into another module, so that future merges do not double-count the
    117      * same test runs.
    118      */
    119     void resetTestRuns();
    120 
    121     /**
    122      * Gets a {@link ICaseResult} for the given testcase, creating it if it doesn't exist.
    123      *
    124      * @param caseName the name of the testcase eg &lt;package-name&gt;&lt;class-name&gt;
    125      * @return the {@link ICaseResult} or <code>null</code>
    126      */
    127     ICaseResult getOrCreateResult(String caseName);
    128 
    129     /**
    130      * Gets the {@link ICaseResult} result for given testcase.
    131      *
    132      * @param caseName the name of the testcase eg &lt;package-name&gt;&lt;class-name&gt;
    133      * @return the {@link ITestResult} or <code>null</code>
    134      */
    135     ICaseResult getResult(String caseName);
    136 
    137     /**
    138      * Gets all results sorted by name.
    139      */
    140     List<ICaseResult> getResults();
    141 
    142     /**
    143      * Counts the number of results which have the given status.
    144      */
    145     int countResults(TestStatus status);
    146 
    147     /**
    148      * Merge the module results from otherModuleResult into this moduleResult.
    149      */
    150     void mergeFrom(IModuleResult otherModuleResult);
    151 }
    152