Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6bdcce66d36753019d8c4fe8ad837226d6d11169 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*******************************************************************************
 * Copyright (c) 2011, 2012 Anton Gorenkov 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Anton Gorenkov - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.testsrunner.internal.model;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.cdt.testsrunner.model.IModelVisitor;
import org.eclipse.cdt.testsrunner.model.ITestSuite;

/**
 * Represents the test suite of the tests hierarchy.
 */
public class TestSuite extends TestItem implements ITestSuite {

	/**
	 * Stores child test suites and test cases.
	 * 
	 * @note Children order is important.
	 */
	private List<TestItem> children = new ArrayList<TestItem>();
	
	
	public TestSuite(String name, TestSuite parent) {
		super(name, parent);
	}

	@Override
	public Status getStatus() {
		Status result = Status.NotRun;
		for (TestItem testItem : children) {
			Status childStatus = testItem.getStatus();
			if (result.compareTo(childStatus) < 0) {
				result = childStatus;
			}
		}
		return result;
	}

	@Override
	public int getTestingTime() {
		int result = 0;
		for (TestItem testItem : children) {
			result += testItem.getTestingTime();
		}
		return result;
	}
	
	@Override
	public boolean hasChildren() {
		return !children.isEmpty();
	}

	@Override
	public TestItem[] getChildren() {
		return children.toArray(new TestItem[children.size()]);
	}

	@Override
	public void visit(IModelVisitor visitor) {
		visitor.visit(this);
		for (TestItem testItem : children) {
			testItem.visit(visitor);
		}
		visitor.leave(this);
	}

	/**
	 * Returns list of children for the test suite.
	 * 
	 * @return children list
	 */
	public List<TestItem> getChildrenList() {
		return children;
	}
	
}

Back to the top