AbstractResult.java revision 3c8ccb384513dd9bae0f98ac516ea36fbaa3173b
1/*
2 * Copyright (C) 2010 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
17package com.android.dumprendertree2;
18
19/**
20 * A class that represent a result of the test. It is responsible for returning the result's
21 * raw data and generating its own diff in HTML format.
22 */
23public abstract class AbstractResult {
24
25    public enum TestType {
26        TEXT,
27        PIXEL
28    }
29
30    public enum ResultCode {
31        PASS("Passed"),
32        FAIL_RESULT_DIFFERS("Failed: different results"),
33        FAIL_NO_EXPECTED_RESULT("Failed: no expected result"),
34        FAIL_TIMED_OUT("Failed: timed out"),
35        FAIL_CRASHED("Failed: crashed");
36
37        private String mTitle;
38
39        private ResultCode(String title) {
40            mTitle = title;
41        }
42
43        @Override
44        public String toString() {
45            return mTitle;
46        }
47    }
48
49    /**
50     * Returns result's raw data that can be written to the disk.
51     *
52     * @return
53     *      results raw data
54     */
55    public abstract byte[] getData();
56
57    /**
58     * Returns the code of this result.
59     *
60     * @return
61     *      the code of this result
62     */
63    public abstract ResultCode getCode();
64
65    /**
66     * Return the type of the result data.
67     *
68     * @return
69     *      the type of the result data.
70     */
71    public abstract TestType getType();
72
73    /**
74     * Returns a piece of HTML code that presents a visual diff between a result and
75     * the expected result.
76     *
77     * @return
78     *      a piece of HTML code with a visual diff between the result and the expected result
79     */
80    public abstract String getDiffAsHtml();
81}