OSDN Git Service

android-2.1_r1 snapshot
[android-x86/sdk.git] / eclipse / plugins / com.android.ide.eclipse.adt / src / com / android / ide / eclipse / adt / internal / launch / junit / runtime / AndroidTestReference.java
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.ITestIdentifier;
20 import org.eclipse.jdt.internal.junit.runner.ITestReference;
21 import org.eclipse.jdt.internal.junit.runner.TestExecution;
22
23 /**
24  * Base implementation of the Eclipse {@link ITestReference} and {@link ITestIdentifier} interfaces
25  * for Android tests.
26  * <p/>
27  * Provides generic equality/hashcode services
28  */
29 @SuppressWarnings("restriction")  //$NON-NLS-1$
30 abstract class AndroidTestReference implements ITestReference, ITestIdentifier {
31
32     /**
33      * Gets the {@link ITestIdentifier} for this test reference.
34      */
35     public ITestIdentifier getIdentifier() {
36         // this class serves as its own test identifier
37         return this;
38     }
39
40     /**
41      * Not supported.
42      */
43     public void run(TestExecution execution) {
44         throw new UnsupportedOperationException();
45     }
46
47     /**
48      * Compares {@link ITestIdentifier} using names
49      */
50     @Override
51     public boolean equals(Object obj) {
52         if (obj instanceof ITestIdentifier) {
53             ITestIdentifier testid = (ITestIdentifier) obj;
54             return getName().equals(testid.getName());
55         }
56         return false;
57     }
58
59     @Override
60     public int hashCode() {
61         return getName().hashCode();
62     }
63 }