• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
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 
17 package com.android.ide.eclipse.adt.internal.launch.junit.runtime;
18 
19 import org.eclipse.jdt.internal.junit.runner.IVisitsTestTrees;
20 
21 import java.util.List;
22 import java.util.ArrayList;
23 
24 /**
25  * Reference for an Android test suite aka class.
26  */
27 @SuppressWarnings("restriction")
28 class TestSuiteReference extends AndroidTestReference {
29 
30     private final String mClassName;
31     private List<TestCaseReference> mTests;
32 
33     /**
34      * Creates a TestSuiteReference
35      *
36      * @param className the fully qualified name of the test class
37      */
TestSuiteReference(String className)38     TestSuiteReference(String className) {
39          mClassName = className;
40          mTests = new ArrayList<TestCaseReference>();
41     }
42 
43     /**
44      * Returns a count of the number of test cases included in this suite.
45      */
countTestCases()46     public int countTestCases() {
47         return mTests.size();
48     }
49 
50     /**
51      * Sends test identifier and test count information for this test class, and all its included
52      * test methods.
53      *
54      * @param notified the {@link IVisitsTestTrees} to send test info too
55      */
sendTree(IVisitsTestTrees notified)56     public void sendTree(IVisitsTestTrees notified) {
57         notified.visitTreeEntry(getIdentifier(), true, countTestCases());
58         for (TestCaseReference ref : mTests) {
59             ref.sendTree(notified);
60         }
61     }
62 
63     /**
64      * Return the name of this test class.
65      */
getName()66     public String getName() {
67         return mClassName;
68     }
69 
70     /**
71      * Adds a test method to this suite.
72      *
73      * @param testRef the {@link TestCaseReference} to add
74      */
addTest(TestCaseReference testRef)75     void addTest(TestCaseReference testRef) {
76         mTests.add(testRef);
77     }
78 }
79