2 * Copyright 2000-2009 JetBrains s.r.o.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package com
.intellij
.execution
.testframework
;
18 import com
.intellij
.execution
.configurations
.ModuleBasedConfiguration
;
19 import com
.intellij
.openapi
.util
.InvalidDataException
;
20 import com
.intellij
.openapi
.util
.JDOMExternalizable
;
21 import com
.intellij
.openapi
.util
.WriteExternalException
;
22 import org
.jdom
.Element
;
23 import org
.jetbrains
.annotations
.NonNls
;
28 public interface TestSearchScope
{
29 SourceScope
getSourceScope(ModuleBasedConfiguration configuration
);
31 TestSearchScope WHOLE_PROJECT
= new TestSearchScope() {
32 public SourceScope
getSourceScope(final ModuleBasedConfiguration configuration
) {
33 return SourceScope
.wholeProject(configuration
.getProject());
36 @SuppressWarnings({"HardCodedStringLiteral"})
37 public String
toString() {
38 return "WHOLE_PROJECT";
42 TestSearchScope SINGLE_MODULE
= new TestSearchScope() {
43 public SourceScope
getSourceScope(final ModuleBasedConfiguration configuration
) {
44 return SourceScope
.modules(configuration
.getModules());
47 @SuppressWarnings({"HardCodedStringLiteral"})
48 public String
toString() {
49 return "SINGLE_MODULE";
53 TestSearchScope MODULE_WITH_DEPENDENCIES
= new TestSearchScope() {
54 public SourceScope
getSourceScope(final ModuleBasedConfiguration configuration
) {
55 return SourceScope
.modulesWithDependencies(configuration
.getModules());
58 @SuppressWarnings({"HardCodedStringLiteral"})
59 public String
toString() {
60 return "MODULE_WITH_DEPENDENCIES";
66 class Wrapper
implements JDOMExternalizable
{
67 @NonNls private static final String DEFAULT_NAME
= "defaultName";
68 private TestSearchScope myScope
= MODULE_WITH_DEPENDENCIES
;
69 @NonNls private static final String WHOLE_PROJECT_NAE
= "wholeProject";
70 @NonNls private static final String SINGLE_MODULE_NAME
= "singleModule";
71 @NonNls private static final String MODULE_WITH_DEPENDENCIES_NAME
= "moduleWithDependencies";
73 public void readExternal(final Element element
) throws InvalidDataException
{
74 final String value
= element
.getAttributeValue(DEFAULT_NAME
);
75 if (SINGLE_MODULE_NAME
.equals(value
)) myScope
= SINGLE_MODULE
;
76 else if (MODULE_WITH_DEPENDENCIES_NAME
.equals(value
)) myScope
= MODULE_WITH_DEPENDENCIES
;
77 else myScope
= WHOLE_PROJECT
;
80 public void writeExternal(final Element element
) throws WriteExternalException
{
81 String name
= WHOLE_PROJECT_NAE
;
82 if (myScope
== SINGLE_MODULE
) name
= SINGLE_MODULE_NAME
;
83 else if (myScope
== MODULE_WITH_DEPENDENCIES
) name
= MODULE_WITH_DEPENDENCIES_NAME
;
84 element
.setAttribute(DEFAULT_NAME
, name
);
87 public TestSearchScope
getScope() {
91 public void setScope(final TestSearchScope scope
) {