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.
21 package org
.jetbrains
.idea
.devkit
.codeInsight
;
23 import com
.intellij
.codeInsight
.daemon
.QuickFixBundle
;
24 import com
.intellij
.codeInsight
.intention
.IntentionAction
;
25 import com
.intellij
.openapi
.application
.PluginPathManager
;
26 import com
.intellij
.openapi
.util
.Comparing
;
27 import com
.intellij
.psi
.JavaPsiFacade
;
28 import com
.intellij
.testFramework
.builders
.JavaModuleFixtureBuilder
;
29 import com
.intellij
.testFramework
.fixtures
.CodeInsightTestFixture
;
30 import com
.intellij
.testFramework
.fixtures
.IdeaProjectTestFixture
;
31 import com
.intellij
.testFramework
.fixtures
.IdeaTestFixtureFactory
;
32 import com
.intellij
.testFramework
.fixtures
.TestFixtureBuilder
;
33 import org
.jetbrains
.idea
.devkit
.inspections
.RegistrationProblemsInspection
;
34 import org
.testng
.Assert
;
35 import org
.testng
.annotations
.AfterMethod
;
36 import org
.testng
.annotations
.BeforeMethod
;
37 import org
.testng
.annotations
.DataProvider
;
38 import org
.testng
.annotations
.Test
;
40 import java
.util
.List
;
42 public class CreateClassFixTest
{
43 protected CodeInsightTestFixture myFixture
;
46 public void setUp() throws Exception
{
47 final IdeaTestFixtureFactory fixtureFactory
= IdeaTestFixtureFactory
.getFixtureFactory();
48 final TestFixtureBuilder
<IdeaProjectTestFixture
> testFixtureBuilder
= fixtureFactory
.createFixtureBuilder();
49 myFixture
= fixtureFactory
.createCodeInsightFixture(testFixtureBuilder
.getFixture());
50 myFixture
.setTestDataPath(PluginPathManager
.getPluginHomePath("devkit") + "/testData");
52 testFixtureBuilder
.addModule(JavaModuleFixtureBuilder
.class)
53 .addContentRoot(myFixture
.getTempDirPath()).addSourceRoot(getSourceRoot());
54 myFixture
.enableInspections(new RegistrationProblemsInspection());
58 private String
getSourceRoot() {
63 public Object
[][] data() {
64 return new Object
[][]{{"Action", true}, {"Impl", true}, {"Intf", true}, {"Intf", false}};
67 @Test(dataProvider
= "data", enabled
= false)
68 public void test(String testName
, boolean createClass
) throws Throwable
{
69 IntentionAction resultAction
= null;
70 final String createAction
= QuickFixBundle
.message(createClass ?
"create.class.text" : "create.interface.text", testName
);
71 final List
<IntentionAction
> actions
= myFixture
.getAvailableIntentions(getSourceRoot() + "/plugin" + testName
+ ".xml");
72 for (IntentionAction action
: actions
) {
73 if (Comparing
.strEqual(action
.getText(), createAction
)) {
74 resultAction
= action
;
78 Assert
.assertNotNull(resultAction
);
79 myFixture
.launchAction(resultAction
);
80 Assert
.assertNotNull(JavaPsiFacade
.getInstance(myFixture
.getProject()).findClass(testName
));
85 public void tearDown() throws Exception
{