add android find usages test

This commit is contained in:
Mikhail Mutcianko
2014-09-18 15:44:21 +04:00
committed by Yan Zhulanow
parent 947e1b7f5b
commit 2643866e31
13 changed files with 252 additions and 1 deletions
@@ -149,6 +149,7 @@ import org.jetbrains.jet.android.AbstractAndroidCompletionTest
import org.jetbrains.jet.android.AbstractAndroidGotoTest
import org.jetbrains.jet.jps.build.android.AbstractAndroidJpsTestCase
import org.jetbrains.jet.android.AbstractAndroidRenameTest
import org.jetbrains.jet.android.AbstractAndroidFindUsagesTest
fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
@@ -726,6 +727,10 @@ fun main(args: Array<String>) {
testClass(javaClass<AbstractAndroidRenameTest>()) {
model("android/rename", recursive = false, extension = null)
}
testClass(javaClass<AbstractAndroidFindUsagesTest>()) {
model("android/findUsages", recursive = false, extension = null)
}
}
testGroup("idea/tests", "compiler/testData") {
@@ -0,0 +1,9 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
val button = this.MyButton<caret>
}
@@ -0,0 +1,15 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<view
class="org.my.cool.Button"
android:id="@+id/MyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>
@@ -0,0 +1,9 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
val button = this.MyButton<caret>
}
@@ -0,0 +1,14 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<org.my.cool.Button
android:id="@+id/MyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>
@@ -0,0 +1,10 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
val button = this.login<caret>
val button1 = this.loginButton
}
@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>
@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/passwordField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/passwordCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>
@@ -0,0 +1,17 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>
@@ -0,0 +1,14 @@
package com.myapp
import android.app.Activity
import android.os.Bundle
import java.io.File
public class MyActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {}
val button = login<caret>
fun f() = login.toString()
}
@@ -0,0 +1,38 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.android
import org.jetbrains.jet.plugin.PluginTestCaseBase
import kotlin.test.assertTrue
import com.intellij.codeInsight.TargetElementUtilBase
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction
public abstract class AbstractAndroidFindUsagesTest : KotlinAndroidTestCase() {
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/android/findUsages/" + getTestName(true) + "/"
public fun doTest(path: String) {
val f = myFixture!!
f.copyDirectoryToProject(getResDir()!!, "res")
f.configureByFile(path + getTestName(true) + ".kt")
val targetElement = TargetElementUtilBase.findTargetElement(f.getEditor(), TargetElementUtilBase.ELEMENT_NAME_ACCEPTED or TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED)
val propUsages = f.findUsages(targetElement!!)
assertTrue(propUsages.notEmpty)
}
}
@@ -0,0 +1,62 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.android;
import com.intellij.testFramework.TestDataPath;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/android/findUsages")
@TestDataPath("$PROJECT_ROOT")
public class AndroidFindUsagesTestGenerated extends AbstractAndroidFindUsagesTest {
public void testAllFilesPresentInFindUsages() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/android/findUsages"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/android/findUsages/fqNameInAttr/");
doTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/android/findUsages/fqNameInTag/");
doTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/android/findUsages/multiFile/");
doTest(fileName);
}
@TestMetadata("simple")
public void testSimple() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/android/findUsages/simple/");
doTest(fileName);
}
}
@@ -58,5 +58,5 @@ public class AndroidGotoTestGenerated extends AbstractAndroidGotoTest {
String fileName = JetTestUtils.navigationMetadata("idea/testData/android/goto/simple/");
doTest(fileName);
}
}