groovy select word now selects list/map literals and method arguments before qualifie...
[fedora-idea.git] / plugins / groovy / test / org / jetbrains / plugins / groovy / GroovyActionsTest.groovy
blob4cde1e0857867ea60330531aa0d9c16bcb68ab54
1 /*
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 org.jetbrains.plugins.groovy;
18 import com.intellij.ide.DataManager;
19 import com.intellij.openapi.actionSystem.IdeActions;
20 import com.intellij.openapi.editor.Editor;
21 import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
22 import com.intellij.openapi.editor.actionSystem.EditorActionManager;
23 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
24 import org.jetbrains.plugins.groovy.util.TestUtils;
26 /**
27 * @author peter
29 public class GroovyActionsTest extends LightCodeInsightFixtureTestCase {
31 protected String getBasePath() {
32 return TestUtils.getTestDataPath() + "groovy/actions/";
35 public void testSelectWordBeforeMethod() throws Throwable {
36 doTestForSelectWord(1);
39 public void testSWInGString1() throws Exception {doTestForSelectWord(1);}
40 public void testSWInGString2() throws Exception {doTestForSelectWord(2);}
41 public void testSWInGString3() throws Exception {doTestForSelectWord(3);}
42 public void testSWInGString4() throws Exception {doTestForSelectWord(4);}
43 public void testSWInGString5() throws Exception {doTestForSelectWord(5);}
44 public void testSWInParameterList() throws Exception {doTestForSelectWord(3);}
46 public void testSWListLiteralArgument() throws Exception {
47 doTestForSelectWord 2,
48 "foo([a<caret>], b)",
49 "foo(<selection>[a<caret>]</selection>, b)"
52 public void testSWMethodParametersBeforeQualifier() throws Exception {
53 doTestForSelectWord 2,
54 "a.fo<caret>o(b)",
55 "a.<selection>foo(b)</selection>"
58 private void doTestForSelectWord(int count, String input, String expected) throws Exception {
59 myFixture.configureByText("a.groovy", input);
60 selectWord(count)
61 myFixture.checkResult(expected);
64 private void doTestForSelectWord(int count) throws Exception {
65 myFixture.configureByFile(getTestName(false) + ".groovy");
66 selectWord(count)
67 myFixture.checkResultByFile(getTestName(false) + "_after.groovy");
70 private def selectWord(int count) {
71 myFixture.getEditor().getSettings().setCamelWords(true);
72 for (int i = 0; i < count; i++) {
73 performEditorAction(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
77 private void performEditorAction(final String actionId) {
78 final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(actionId);
79 final Editor editor = myFixture.getEditor();
80 handler.execute(editor, DataManager.getInstance().getDataContext(editor.getContentComponent()));