blob: b97bb92ab78d1f21f19fd300eddf84aefbc30dff [file] [log] [blame]
Di Qian38c02a72019-11-18 19:14:07 -08001/*
2 * Copyright (C) 2019 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 */
16package com.android.tradefed.cluster;
17
18import org.json.JSONException;
19import org.json.JSONObject;
20
21/**
22 * A class to store status of a test group.
23 *
24 * <p>A test group corresponds to a group of test cases reported under a same test run name.
25 */
26public class TestGroupStatus {
27
28 private String mName;
29 private int mTotalTestCount;
30 private int mCompletedTestCount;
31 private int mFailedTestCount;
Daniel Peykov0cb492a2019-12-13 10:49:35 -080032 private int mPassedTestCount;
Di Qian38c02a72019-11-18 19:14:07 -080033 private boolean mIsComplete;
34 private long mElapsedTime;
Di Qian38c02a72019-11-18 19:14:07 -080035
36 public TestGroupStatus(
37 final String name,
38 final int totalTestCount,
39 final int completedTestCount,
40 final int failedTestCount,
Daniel Peykov0cb492a2019-12-13 10:49:35 -080041 final int passedTestCount,
Di Qian38c02a72019-11-18 19:14:07 -080042 final boolean isComplete,
Moon Kimd15525e2020-04-28 16:49:10 -070043 final long elapsedTime) {
Di Qian38c02a72019-11-18 19:14:07 -080044 mName = name;
45 mTotalTestCount = totalTestCount;
46 mCompletedTestCount = completedTestCount;
47 mFailedTestCount = failedTestCount;
Daniel Peykov0cb492a2019-12-13 10:49:35 -080048 mPassedTestCount = passedTestCount;
Di Qian38c02a72019-11-18 19:14:07 -080049 mIsComplete = isComplete;
50 mElapsedTime = elapsedTime;
Di Qian38c02a72019-11-18 19:14:07 -080051 }
52
53 public String getName() {
54 return mName;
55 }
56
57 public int getTotalTestCount() {
58 return mTotalTestCount;
59 }
60
61 public int getCompletedTestCount() {
62 return mCompletedTestCount;
63 }
64
65 public int getFailedTestCount() {
66 return mFailedTestCount;
67 }
68
Daniel Peykov0cb492a2019-12-13 10:49:35 -080069 public int getPassedTestCount() {
70 return mPassedTestCount;
71 }
72
Di Qian38c02a72019-11-18 19:14:07 -080073 public boolean isComplete() {
74 return mIsComplete;
75 }
76
77 public long getElapsedTime() {
78 return mElapsedTime;
79 }
80
Di Qian38c02a72019-11-18 19:14:07 -080081 public JSONObject toJSON() throws JSONException {
82 final JSONObject json = new JSONObject();
83 json.put("name", mName);
84 json.put("total_test_count", mTotalTestCount);
85 json.put("completed_test_count", mCompletedTestCount);
86 json.put("failed_test_count", mFailedTestCount);
Daniel Peykov0cb492a2019-12-13 10:49:35 -080087 json.put("passed_test_count", mPassedTestCount);
Di Qian38c02a72019-11-18 19:14:07 -080088 json.put("is_complete", mIsComplete);
89 json.put("elapsed_time", mElapsedTime);
Di Qian38c02a72019-11-18 19:14:07 -080090 return json;
91 }
92}