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
;
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 private void doTestForSelectWord(int count
) throws Exception
{
47 myFixture
.configureByFile(getTestName(false) + ".groovy");
48 myFixture
.getEditor().getSettings().setCamelWords(true);
49 for (int i
= 0; i
< count
; i
++) {
50 performEditorAction(IdeActions
.ACTION_EDITOR_SELECT_WORD_AT_CARET
);
52 myFixture
.checkResultByFile(getTestName(false) + "_after.groovy");
55 private void performEditorAction(final String actionId
) {
56 final EditorActionHandler handler
= EditorActionManager
.getInstance().getActionHandler(actionId
);
57 final Editor editor
= myFixture
.getEditor();
58 handler
.execute(editor
, DataManager
.getInstance().getDataContext(editor
.getContentComponent()));