Move Android IDEA plugin tests to android-idea-plugin module
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
@@ -13,6 +14,7 @@
|
||||
<orderEntry type="library" exported="" scope="TEST" name="android_tests" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="idea-full" level="project" />
|
||||
<orderEntry type="module" module-name="idea" scope="PROVIDED" />
|
||||
<orderEntry type="module" module-name="compiler-tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="cli" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
@@ -0,0 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.myapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
|
||||
class MyActivity: Activity() {
|
||||
val button = this.MyBu<caret>
|
||||
}
|
||||
|
||||
// EXIST: MyButton
|
||||
+15
@@ -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,10 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
|
||||
class MyActivity: Activity() {
|
||||
val button = this.MyBu<caret>
|
||||
}
|
||||
|
||||
// EXIST: MyButton
|
||||
+14
@@ -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.log<caret>
|
||||
}
|
||||
|
||||
// EXIST: login, loginButton
|
||||
+29
@@ -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>
|
||||
+29
@@ -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>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
|
||||
class MyActivity: Activity() {
|
||||
val button = this.login<caret>
|
||||
}
|
||||
|
||||
// EXIST: login
|
||||
+17
@@ -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,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.myapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
|
||||
</manifest>
|
||||
+15
@@ -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>
|
||||
+14
@@ -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>
|
||||
+29
@@ -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>
|
||||
+29
@@ -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,25 @@
|
||||
<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" >
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Enter your password" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="textPassword" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sign in" />
|
||||
|
||||
</FrameLayout>
|
||||
+29
@@ -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,9 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
|
||||
class MyActivity: Activity() {
|
||||
val button = this.MyButton<caret>
|
||||
}
|
||||
|
||||
+15
@@ -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>
|
||||
}
|
||||
|
||||
+14
@@ -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
|
||||
}
|
||||
|
||||
+29
@@ -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>
|
||||
+29
@@ -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,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,12 @@
|
||||
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>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
|
||||
class MyActivity: Activity() {
|
||||
val button = this.MyButton<caret>
|
||||
}
|
||||
|
||||
+15
@@ -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,12 @@
|
||||
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>
|
||||
}
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 com.intellij.openapi.application.PathManager
|
||||
import com.intellij.codeInsight.completion.CompletionType
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import java.io.File
|
||||
import org.jetbrains.jet.completion.util.testCompletion
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
|
||||
import com.intellij.openapi.startup.StartupManager
|
||||
import org.jetbrains.jet.JetTestCaseBuilder
|
||||
import org.jetbrains.jet.plugin.actions.internal.KotlinInternalMode
|
||||
import com.intellij.psi.impl.PsiManagerEx
|
||||
import com.intellij.psi.PsiManager
|
||||
import org.jetbrains.jet.plugin.references.BuiltInsReferenceResolver
|
||||
import com.android.SdkConstants
|
||||
import com.intellij.codeInsight.CodeInsightSettings
|
||||
|
||||
public abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() {
|
||||
private var kotlinInternalModeOriginalValue: Boolean = false
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
setAutoCompleteSetting(false)
|
||||
}
|
||||
|
||||
private fun setAutoCompleteSetting(value: Boolean): Boolean {
|
||||
val settings = CodeInsightSettings.getInstance()
|
||||
val oldValue: Boolean
|
||||
if (completionType() == CompletionType.SMART) {
|
||||
oldValue = settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION
|
||||
settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = value
|
||||
}
|
||||
else {
|
||||
oldValue = settings.AUTOCOMPLETE_COMMON_PREFIX
|
||||
settings.AUTOCOMPLETE_ON_CODE_COMPLETION = value
|
||||
}
|
||||
return oldValue
|
||||
}
|
||||
|
||||
private fun completionType() = CompletionType.BASIC
|
||||
|
||||
fun doTest(testPath: String?) {
|
||||
myFixture!!.copyDirectoryToProject(getResDir()!!, "res")
|
||||
myFixture!!.configureByFile(testPath!! + getTestName(true) + ".kt");
|
||||
val fileText = FileUtil.loadFile(File(testPath + getTestName(true) + ".kt"), true)
|
||||
testCompletion(fileText, TargetPlatform.JVM, {
|
||||
count -> myFixture!!.complete(completionType())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
override fun getTestDataPath(): String {
|
||||
return KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/completion/" + getTestName(true) + "/"
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -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() = KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/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)
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.openapi.application.PathManager
|
||||
import com.android.SdkConstants
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase
|
||||
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction
|
||||
import kotlin.test.fail
|
||||
import kotlin.test.assertEquals
|
||||
import org.jetbrains.jet.lang.psi.JetProperty
|
||||
|
||||
public abstract class AbstractAndroidGotoTest : KotlinAndroidTestCase() {
|
||||
|
||||
override fun getTestDataPath(): String {
|
||||
return KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/goto/" + getTestName(true) + "/"
|
||||
}
|
||||
|
||||
public fun doTest(path: String) {
|
||||
val f = myFixture!!
|
||||
f.copyDirectoryToProject(getResDir()!!, "res")
|
||||
f.configureByFile(path + getTestName(true) + ".kt");
|
||||
|
||||
val resolved = GotoDeclarationAction.findTargetElement(f.getProject(), f.getEditor(), f.getCaretOffset())
|
||||
if (f.getElementAtCaret() !is JetProperty) fail("element at caret must be a property, not a ${f.getElementAtCaret().javaClass}")
|
||||
assertEquals("\"@+id/${(f.getElementAtCaret() as JetProperty).getName()}\"", resolved?.getText())
|
||||
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.openapi.command.WriteCommandAction
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil
|
||||
import com.intellij.codeInsight.TargetElementUtilBase
|
||||
import com.intellij.refactoring.rename.RenamePsiElementProcessor
|
||||
import com.intellij.refactoring.rename.RenameProcessor
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase
|
||||
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction
|
||||
import kotlin.test.assertEquals
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.psi.JetProperty
|
||||
|
||||
public abstract class AbstractAndroidRenameTest : KotlinAndroidTestCase() {
|
||||
|
||||
private val NEW_NAME = "NEWNAME"
|
||||
private val OLD_NAME = "OLDNAME"
|
||||
|
||||
public fun doTest(path: String) {
|
||||
val f = myFixture!!
|
||||
f.copyDirectoryToProject(getResDir()!!, "res")
|
||||
f.configureByFile(path + getTestName(true) + ".kt")
|
||||
val editor = f.getEditor()
|
||||
val file = f.getFile()
|
||||
val completionEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file)
|
||||
val element = TargetElementUtilBase.findTargetElement(completionEditor, TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED or TargetElementUtilBase.ELEMENT_NAME_ACCEPTED)
|
||||
assert(element != null)
|
||||
|
||||
// rename xml attribute by property
|
||||
renameElementWithTextOccurences(element!!, NEW_NAME)
|
||||
val resolved = GotoDeclarationAction.findTargetElement(f.getProject(), f.getEditor(), f.getCaretOffset())
|
||||
assertEquals("\"@+id/$NEW_NAME\"", resolved?.getText())
|
||||
|
||||
// rename property by attribute
|
||||
renameElementWithTextOccurences(resolved!!, "@+id/$OLD_NAME")
|
||||
assertEquals(OLD_NAME, (f.getElementAtCaret() as JetProperty).getName())
|
||||
}
|
||||
|
||||
private fun renameElementWithTextOccurences(element: PsiElement, newName: String) {
|
||||
val f = myFixture!!
|
||||
object : WriteCommandAction.Simple<Unit>(f.getProject()) {
|
||||
protected override fun run() {
|
||||
val editor = f.getEditor()
|
||||
val substitution = RenamePsiElementProcessor.forElement(element).substituteElementToRename(element, editor)
|
||||
RenameProcessor(f.getProject(), substitution, newName, false, true).run()
|
||||
}
|
||||
}.execute().throwException()
|
||||
}
|
||||
|
||||
override fun getTestDataPath() = KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/rename/" + getTestName(true) + "/"
|
||||
}
|
||||
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.cli.jvm.compiler.JetCoreEnvironment
|
||||
import org.jetbrains.jet.lang.resolve.android.CliAndroidUIXmlProcessor
|
||||
import org.jetbrains.jet.JetTestUtils
|
||||
import org.jetbrains.jet.ConfigurationKind
|
||||
import org.jetbrains.jet.TestJdkKind
|
||||
import org.jetbrains.jet.plugin.android.IDEAndroidUIXmlProcessor
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
|
||||
import kotlin.test.assertEquals
|
||||
import org.jetbrains.jet.plugin.android.TestConst
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.android.AndroidConfigurationKeys
|
||||
|
||||
public abstract class AbstractCrossParserTest : KotlinAndroidTestCase() {
|
||||
public fun doTest(path: String) {
|
||||
val project = myFixture!!.getProject()
|
||||
project.putUserData(TestConst.TESTDATA_PATH, path)
|
||||
myFixture!!.copyDirectoryToProject(getResDir()!!, "res")
|
||||
val cliParser = CliAndroidUIXmlProcessor(project, path + getResDir() + "/layout/", path + "../AndroidManifest.xml")
|
||||
val ideParser = IDEAndroidUIXmlProcessor(project)
|
||||
|
||||
val cliResult = cliParser.parseToPsi(project)!!.getText()
|
||||
val ideResult = ideParser.parseToPsi(project)!!.getText()
|
||||
|
||||
assertEquals(cliResult, ideResult)
|
||||
}
|
||||
|
||||
private fun getEnvironment(testPath: String): JetCoreEnvironment {
|
||||
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
|
||||
configuration.put<String>(AndroidConfigurationKeys.ANDROID_RES_PATH, testPath + "/layout")
|
||||
configuration.put<String>(AndroidConfigurationKeys.ANDROID_MANIFEST, testPath + "/AndroidManifest.xml")
|
||||
return JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration)
|
||||
}
|
||||
|
||||
override fun getTestDataPath(): String? {
|
||||
return KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/crossParser/" + getTestName(true) + "/"
|
||||
}
|
||||
}
|
||||
+62
@@ -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 org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
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("plugins/android-idea-plugin/testData/android/completion")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class AndroidCompletionTestGenerated extends AbstractAndroidCompletionTest {
|
||||
public void testAllFilesPresentInCompletion() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-idea-plugin/testData/android/completion"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/completion/fqNameInAttr/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/completion/fqNameInTag/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/completion/multiFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("propertiesSimple")
|
||||
public void testPropertiesSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/completion/propertiesSimple/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
+62
@@ -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 org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
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("plugins/android-idea-plugin/testData/android/findUsages")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class AndroidFindUsagesTestGenerated extends AbstractAndroidFindUsagesTest {
|
||||
public void testAllFilesPresentInFindUsages() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-idea-plugin/testData/android/findUsages"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/findUsages/fqNameInAttr/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/findUsages/fqNameInTag/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/findUsages/multiFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/findUsages/simple/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
+62
@@ -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 org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
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("plugins/android-idea-plugin/testData/android/goto")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class AndroidGotoTestGenerated extends AbstractAndroidGotoTest {
|
||||
public void testAllFilesPresentInGoto() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-idea-plugin/testData/android/goto"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/goto/fqNameInAttr/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/goto/fqNameInTag/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/goto/multiFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/goto/simple/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
+62
@@ -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 org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
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("plugins/android-idea-plugin/testData/android/rename")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class AndroidRenameTestGenerated extends AbstractAndroidRenameTest {
|
||||
public void testAllFilesPresentInRename() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-idea-plugin/testData/android/rename"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/rename/fqNameInAttr/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/rename/fqNameInTag/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/rename/multiFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/rename/simple/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
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("plugins/android-idea-plugin/testData/android/crossParser")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class CrossParserTestGenerated extends AbstractCrossParserTest {
|
||||
public void testAllFilesPresentInCrossParser() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-idea-plugin/testData/android/crossParser"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/crossParser/fqNameInAttr/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/crossParser/fqNameInTag/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/crossParser/multiFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noIds")
|
||||
public void testNoIds() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/crossParser/noIds/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("singleFile")
|
||||
public void testSingleFile() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-idea-plugin/testData/android/crossParser/singleFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
+327
@@ -0,0 +1,327 @@
|
||||
/*
|
||||
* 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.android.SdkConstants;
|
||||
import com.android.ide.common.rendering.RenderSecurityManager;
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInspection.GlobalInspectionTool;
|
||||
import com.intellij.codeInspection.InspectionManager;
|
||||
import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
|
||||
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.ex.InspectionManagerEx;
|
||||
import com.intellij.facet.FacetManager;
|
||||
import com.intellij.facet.ModifiableFacetModel;
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.file.impl.FileManager;
|
||||
import com.intellij.testFramework.InspectionTestUtil;
|
||||
import com.intellij.testFramework.TestLogger;
|
||||
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
|
||||
import com.intellij.testFramework.fixtures.*;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.facet.AndroidRootUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.actions.internal.KotlinInternalMode;
|
||||
import org.jetbrains.jet.plugin.references.BuiltInsReferenceResolver;
|
||||
import org.jetbrains.jet.testing.ConfigLibraryUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
|
||||
public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
||||
protected Module myModule;
|
||||
protected List<Module> myAdditionalModules;
|
||||
|
||||
private boolean myCreateManifest;
|
||||
protected AndroidFacet myFacet;
|
||||
|
||||
private boolean kotlinInternalModeOriginalValue;
|
||||
|
||||
public KotlinAndroidTestCase(boolean createManifest) {
|
||||
this.myCreateManifest = createManifest;
|
||||
}
|
||||
|
||||
public KotlinAndroidTestCase() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getResRelativePath() {
|
||||
return "res/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
// sdk path workaround, set real android sdk path and platform for android plugin to work
|
||||
System.setProperty(KotlinAndroidTestCaseBase.SDK_PATH_PROPERTY, PathManager.getHomePath() + "/androidSDK/");
|
||||
System.setProperty(KotlinAndroidTestCaseBase.PLATFORM_DIR_PROPERTY, "android-17");
|
||||
|
||||
super.setUp();
|
||||
|
||||
// this will throw an exception if we don't have a full Android SDK, so we need to do this first thing before any other setup
|
||||
String sdkPath = getTestSdkPath();
|
||||
|
||||
final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder =
|
||||
IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
|
||||
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
|
||||
final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
|
||||
final String dirPath = myFixture.getTempDirPath() + getContentRootPath();
|
||||
final File dir = new File(dirPath);
|
||||
|
||||
if (!dir.exists()) {
|
||||
assertTrue(dir.mkdirs());
|
||||
}
|
||||
tuneModule(moduleFixtureBuilder, dirPath);
|
||||
|
||||
final ArrayList<MyAdditionalModuleData> modules = new ArrayList<MyAdditionalModuleData>();
|
||||
configureAdditionalModules(projectBuilder, modules);
|
||||
|
||||
myFixture.setUp();
|
||||
myFixture.setTestDataPath(getTestDataPath());
|
||||
myModule = moduleFixtureBuilder.getFixture().getModule();
|
||||
|
||||
// Must be done before addAndroidFacet, and must always be done, even if !myCreateManifest.
|
||||
// We will delete it at the end of setUp; this is needed when unit tests want to rewrite
|
||||
// the manifest on their own.
|
||||
createManifest();
|
||||
|
||||
androidSdk = createAndroidSdk(getTestSdkPath(), getPlatformDir());
|
||||
myFacet = addAndroidFacet(myModule, sdkPath, getPlatformDir(), isToAddSdk());
|
||||
if (new File(getResDir()).exists()) {
|
||||
myFixture.copyDirectoryToProject(getResDir(), "res");
|
||||
} else {
|
||||
TestLogger.getInstance(this.getClass()).info("No res directory found in test");
|
||||
}
|
||||
myAdditionalModules = new ArrayList<Module>();
|
||||
|
||||
for (MyAdditionalModuleData data : modules) {
|
||||
final Module additionalModule = data.myModuleFixtureBuilder.getFixture().getModule();
|
||||
myAdditionalModules.add(additionalModule);
|
||||
final AndroidFacet facet = addAndroidFacet(additionalModule, sdkPath, getPlatformDir());
|
||||
facet.setLibraryProject(data.myLibrary);
|
||||
final String rootPath = getContentRootPath(data.myDirName);
|
||||
myFixture.copyDirectoryToProject("res", rootPath + "/res");
|
||||
myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML,
|
||||
rootPath + '/' + SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||
ModuleRootModificationUtil.addDependency(myModule, additionalModule);
|
||||
}
|
||||
|
||||
if (!myCreateManifest) {
|
||||
deleteManifest();
|
||||
}
|
||||
|
||||
if (RenderSecurityManager.RESTRICT_READS) {
|
||||
// Unit test class loader includes disk directories which security manager does not allow access to
|
||||
RenderSecurityManager.sEnabled = false;
|
||||
}
|
||||
|
||||
((StartupManagerImpl) StartupManager.getInstance(getProject())).runPostStartupActivities();
|
||||
VfsRootAccess.allowRootAccess(JetTestCaseBuilder.getHomeDirectory());
|
||||
|
||||
kotlinInternalModeOriginalValue = KotlinInternalMode.OBJECT$.getEnabled();
|
||||
KotlinInternalMode.OBJECT$.setEnabled(true);
|
||||
}
|
||||
|
||||
protected boolean isToAddSdk() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getContentRootPath() {
|
||||
return "";
|
||||
}
|
||||
|
||||
protected void configureAdditionalModules(@NotNull TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder,
|
||||
@NotNull List<MyAdditionalModuleData> modules) {
|
||||
}
|
||||
|
||||
protected void addModuleWithAndroidFacet(@NotNull TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder,
|
||||
@NotNull List<MyAdditionalModuleData> modules,
|
||||
@NotNull String dirName,
|
||||
boolean library) {
|
||||
final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
|
||||
final String moduleDirPath = myFixture.getTempDirPath() + getContentRootPath(dirName);
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
new File(moduleDirPath).mkdirs();
|
||||
tuneModule(moduleFixtureBuilder, moduleDirPath);
|
||||
modules.add(new MyAdditionalModuleData(moduleFixtureBuilder, dirName, library));
|
||||
}
|
||||
|
||||
protected static String getContentRootPath(@NotNull String moduleName) {
|
||||
return "/additionalModules/" + moduleName;
|
||||
}
|
||||
|
||||
protected String getResDir() {
|
||||
return "res";
|
||||
}
|
||||
|
||||
public static void tuneModule(JavaModuleFixtureBuilder moduleBuilder, String moduleDirPath) {
|
||||
moduleBuilder.addContentRoot(moduleDirPath);
|
||||
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
new File(moduleDirPath + "/src/").mkdir();
|
||||
moduleBuilder.addSourceRoot("src");
|
||||
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
new File(moduleDirPath + "/gen/").mkdir();
|
||||
moduleBuilder.addSourceRoot("gen");
|
||||
}
|
||||
|
||||
protected void createManifest() throws IOException {
|
||||
myFixture.copyFileToProject("plugins/android-idea-plugin/testData/android/AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||
// myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML, SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||
}
|
||||
|
||||
protected void createProjectProperties() throws IOException {
|
||||
myFixture.copyFileToProject(SdkConstants.FN_PROJECT_PROPERTIES, SdkConstants.FN_PROJECT_PROPERTIES);
|
||||
}
|
||||
|
||||
protected void deleteManifest() throws IOException {
|
||||
deleteManifest(myModule);
|
||||
}
|
||||
|
||||
protected void deleteManifest(final Module module) throws IOException {
|
||||
final AndroidFacet facet = AndroidFacet.getInstance(module);
|
||||
assertNotNull(facet);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String manifestRelativePath = facet.getProperties().MANIFEST_FILE_RELATIVE_PATH;
|
||||
VirtualFile manifest = AndroidRootUtil.getFileByRelativeModulePath(module, manifestRelativePath, true);
|
||||
if (manifest != null) {
|
||||
try {
|
||||
manifest.delete(this);
|
||||
}
|
||||
catch (IOException e) {
|
||||
fail("Could not delete default manifest");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
KotlinInternalMode.OBJECT$.setEnabled(kotlinInternalModeOriginalValue);
|
||||
VfsRootAccess.disallowRootAccess(JetTestCaseBuilder.getHomeDirectory());
|
||||
|
||||
Set<JetFile> builtInsSources = getProject().getComponent(BuiltInsReferenceResolver.class).getBuiltInsSources();
|
||||
FileManager fileManager = ((PsiManagerEx) PsiManager.getInstance(getProject())).getFileManager();
|
||||
|
||||
myModule = null;
|
||||
myAdditionalModules = null;
|
||||
myFixture.tearDown();
|
||||
myFixture = null;
|
||||
myFacet = null;
|
||||
if (RenderSecurityManager.RESTRICT_READS) {
|
||||
RenderSecurityManager.sEnabled = true;
|
||||
}
|
||||
|
||||
super.tearDown();
|
||||
|
||||
// Restore mapping between PsiFiles and VirtualFiles dropped in FileManager.cleanupForNextTest(),
|
||||
// otherwise built-ins psi elements will become invalid in next test.
|
||||
for (JetFile source : builtInsSources) {
|
||||
FileViewProvider provider = source.getViewProvider();
|
||||
fileManager.setViewProvider(provider.getVirtualFile(), provider);
|
||||
}
|
||||
}
|
||||
|
||||
public AndroidFacet addAndroidFacet(Module module, String sdkPath, String platformDir) {
|
||||
return addAndroidFacet(module, sdkPath, platformDir, true);
|
||||
}
|
||||
|
||||
public AndroidFacet addAndroidFacet(Module module, String sdkPath, String platformDir, boolean addSdk) {
|
||||
FacetManager facetManager = FacetManager.getInstance(module);
|
||||
AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), "Android", null);
|
||||
|
||||
if (addSdk) {
|
||||
addAndroidSdk(module, sdkPath, platformDir);
|
||||
}
|
||||
final ModifiableFacetModel facetModel = facetManager.createModifiableModel();
|
||||
facetModel.addFacet(facet);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
facetModel.commit();
|
||||
}
|
||||
});
|
||||
return facet;
|
||||
}
|
||||
|
||||
protected void doGlobalInspectionTest(@NotNull GlobalInspectionTool inspection,
|
||||
@NotNull String globalTestDir,
|
||||
@NotNull AnalysisScope scope) {
|
||||
doGlobalInspectionTest(new GlobalInspectionToolWrapper(inspection), globalTestDir, scope);
|
||||
}
|
||||
|
||||
protected void doGlobalInspectionTest(@NotNull GlobalInspectionToolWrapper wrapper,
|
||||
@NotNull String globalTestDir,
|
||||
@NotNull AnalysisScope scope) {
|
||||
myFixture.enableInspections(wrapper.getTool());
|
||||
|
||||
scope.invalidate();
|
||||
|
||||
final InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject());
|
||||
final GlobalInspectionContextImpl globalContext =
|
||||
CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, wrapper);
|
||||
|
||||
InspectionTestUtil.runTool(wrapper, scope, globalContext, inspectionManager);
|
||||
InspectionTestUtil.compareToolResults(globalContext, wrapper, false, getTestDataPath() + globalTestDir);
|
||||
}
|
||||
|
||||
protected static class MyAdditionalModuleData {
|
||||
final JavaModuleFixtureBuilder myModuleFixtureBuilder;
|
||||
final String myDirName;
|
||||
final boolean myLibrary;
|
||||
|
||||
private MyAdditionalModuleData(@NotNull JavaModuleFixtureBuilder moduleFixtureBuilder,
|
||||
@NotNull String dirName,
|
||||
boolean library) {
|
||||
myModuleFixtureBuilder = moduleFixtureBuilder;
|
||||
myDirName = dirName;
|
||||
myLibrary = library;
|
||||
}
|
||||
}
|
||||
}
|
||||
+323
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* 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.android.sdklib.IAndroidTarget;
|
||||
import com.android.tools.idea.rendering.ResourceHelper;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkModificator;
|
||||
import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.util.Segment;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.xml.XmlAttributeValue;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
|
||||
import org.jetbrains.android.dom.wrappers.LazyValueResourceElementWrapper;
|
||||
import org.jetbrains.android.sdk.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
|
||||
public abstract class KotlinAndroidTestCaseBase extends UsefulTestCase {
|
||||
/** Environment variable or system property containing the full path to an SDK install */
|
||||
public static final String SDK_PATH_PROPERTY = "ADT_TEST_SDK_PATH";
|
||||
|
||||
/** Environment variable or system property pointing to the directory name of the platform inside $sdk/platforms, e.g. "android-17" */
|
||||
public static final String PLATFORM_DIR_PROPERTY = "ADT_TEST_PLATFORM";
|
||||
|
||||
protected CodeInsightTestFixture myFixture;
|
||||
|
||||
protected Sdk androidSdk;
|
||||
protected VirtualFile androidJar;
|
||||
|
||||
private static final String TEST_DATA_PROJECT_RELATIVE = "/plugins/android-idea-plugin/testData/android";
|
||||
|
||||
protected KotlinAndroidTestCaseBase() {
|
||||
IdeaTestCase.initPlatformPrefix();
|
||||
}
|
||||
|
||||
public String getAbsoluteTestDataPath() {
|
||||
// The following code doesn't work right now that the Android
|
||||
// plugin lives in a separate place:
|
||||
//String androidHomePath = System.getProperty("android.home.path");
|
||||
//if (androidHomePath == null) {
|
||||
// androidHomePath = new File(PathManager.getHomePath(), "android/android").getPath();
|
||||
//}
|
||||
//return PathUtil.getCanonicalPath(androidHomePath + "/testData");
|
||||
|
||||
// getTestDataPath already gives the absolute path anyway:
|
||||
String path = getTestDataPath();
|
||||
assertTrue(new File(path).isAbsolute());
|
||||
return path;
|
||||
}
|
||||
|
||||
public static String getPluginTestDataPathBase() {
|
||||
return JetTestCaseBuilder.getHomeDirectory() + TEST_DATA_PROJECT_RELATIVE;
|
||||
}
|
||||
|
||||
public String getTestDataPath() {
|
||||
return getPluginTestDataPathBase();
|
||||
}
|
||||
|
||||
public static String getAndroidPluginHome() {
|
||||
// Now that the Android plugin is kept in a separate place, we need to look in
|
||||
// a relative position instead
|
||||
String adtPath = PathManager.getHomePath() + "/../adt/idea/android";
|
||||
if (new File(adtPath).exists()) {
|
||||
return adtPath;
|
||||
}
|
||||
return new File(PathManager.getHomePath(), "android/android").getPath();
|
||||
}
|
||||
|
||||
public String getDefaultTestSdkPath() {
|
||||
return getTestDataPath() + "/sdk1.5";
|
||||
}
|
||||
|
||||
public String getDefaultPlatformDir() {
|
||||
return "android-1.5";
|
||||
}
|
||||
|
||||
protected String getTestSdkPath() {
|
||||
if (requireRecentSdk()) {
|
||||
String override = System.getProperty(SDK_PATH_PROPERTY);
|
||||
if (override != null) {
|
||||
assertTrue("Must also define " + PLATFORM_DIR_PROPERTY, System.getProperty(PLATFORM_DIR_PROPERTY) != null);
|
||||
assertTrue(override, new File(override).exists());
|
||||
return override;
|
||||
}
|
||||
override = System.getenv(SDK_PATH_PROPERTY);
|
||||
if (override != null) {
|
||||
assertTrue("Must also define " + PLATFORM_DIR_PROPERTY, System.getenv(PLATFORM_DIR_PROPERTY) != null);
|
||||
return override;
|
||||
}
|
||||
fail("This unit test requires " + SDK_PATH_PROPERTY + " and " + PLATFORM_DIR_PROPERTY + " to be defined.");
|
||||
}
|
||||
|
||||
return getDefaultTestSdkPath();
|
||||
}
|
||||
|
||||
protected String getPlatformDir() {
|
||||
if (requireRecentSdk()) {
|
||||
String override = System.getProperty(PLATFORM_DIR_PROPERTY);
|
||||
if (override != null) {
|
||||
return override;
|
||||
}
|
||||
override = System.getenv(PLATFORM_DIR_PROPERTY);
|
||||
if (override != null) {
|
||||
return override;
|
||||
}
|
||||
fail("This unit test requires " + SDK_PATH_PROPERTY + " and " + PLATFORM_DIR_PROPERTY + " to be defined.");
|
||||
}
|
||||
return getDefaultPlatformDir();
|
||||
}
|
||||
|
||||
/** Is the bundled (incomplete) SDK install adequate or do we need to find a valid install? */
|
||||
protected boolean requireRecentSdk() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void addAndroidSdk(Module module, String sdkPath, String platformDir) {
|
||||
assert androidSdk != null : "android sdk must be initialized";
|
||||
ModuleRootModificationUtil.setModuleSdk(module, androidSdk);
|
||||
}
|
||||
|
||||
public Sdk createAndroidSdk(String sdkPath, String platformDir) {
|
||||
Sdk sdk = ProjectJdkTable.getInstance().createSdk("android_test_sdk", AndroidSdkType.getInstance());
|
||||
SdkModificator sdkModificator = sdk.getSdkModificator();
|
||||
sdkModificator.setHomePath(sdkPath);
|
||||
|
||||
if (platformDir.equals(getDefaultPlatformDir())) {
|
||||
// Compatibility: the unit tests were using android.jar outside the sdk1.5 install;
|
||||
// we need to use that one, rather than the real one in sdk1.5, in order for the
|
||||
// tests to pass. Longer term, we should switch the unit tests over to all using
|
||||
// a valid SDK.
|
||||
String androidJarPath = sdkPath + "/../android.jar!/";
|
||||
androidJar = VirtualFileManager.getInstance().findFileByUrl("jar://" + androidJarPath);
|
||||
} else {
|
||||
androidJar = VirtualFileManager.getInstance().findFileByUrl("jar://" + sdkPath + "/platforms/" + platformDir + "/android.jar!/");
|
||||
}
|
||||
sdkModificator.addRoot(androidJar, OrderRootType.CLASSES);
|
||||
|
||||
VirtualFile resFolder = LocalFileSystem.getInstance().findFileByPath(sdkPath + "/platforms/" + platformDir + "/data/res");
|
||||
sdkModificator.addRoot(resFolder, OrderRootType.CLASSES);
|
||||
|
||||
VirtualFile docsFolder = LocalFileSystem.getInstance().findFileByPath(sdkPath + "/docs/reference");
|
||||
if (docsFolder != null) {
|
||||
sdkModificator.addRoot(docsFolder, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
|
||||
AndroidSdkAdditionalData data = new AndroidSdkAdditionalData(sdk);
|
||||
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdkPath);
|
||||
assertNotNull(sdkData);
|
||||
IAndroidTarget target = sdkData.findTargetByName("Android 4.2"); // TODO: Get rid of this hardcoded version number
|
||||
if (target == null) {
|
||||
IAndroidTarget[] targets = sdkData.getTargets();
|
||||
for (IAndroidTarget t : targets) {
|
||||
if (t.getLocation().contains(platformDir)) {
|
||||
target = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (target == null && targets.length > 0) {
|
||||
target = targets[targets.length - 1];
|
||||
}
|
||||
}
|
||||
assertNotNull(target);
|
||||
data.setBuildTarget(target);
|
||||
sdkModificator.setSdkAdditionalData(data);
|
||||
sdkModificator.commitChanges();
|
||||
return sdk;
|
||||
}
|
||||
|
||||
protected Project getProject() {
|
||||
return myFixture.getProject();
|
||||
}
|
||||
|
||||
protected void ensureSdkManagerAvailable() {
|
||||
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
|
||||
if (sdkData == null) {
|
||||
sdkData = createTestSdkManager();
|
||||
if (sdkData != null) {
|
||||
AndroidSdkUtils.setSdkData(sdkData);
|
||||
}
|
||||
}
|
||||
assertNotNull(sdkData);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected AndroidSdkData createTestSdkManager() {
|
||||
Sdk androidSdk = createAndroidSdk(getTestSdkPath(), getPlatformDir());
|
||||
AndroidSdkAdditionalData data = (AndroidSdkAdditionalData)androidSdk.getSdkAdditionalData();
|
||||
if (data != null) {
|
||||
AndroidPlatform androidPlatform = data.getAndroidPlatform();
|
||||
if (androidPlatform != null) {
|
||||
// Put default platforms in the list before non-default ones so they'll be looked at first.
|
||||
return androidPlatform.getSdkData();
|
||||
} else {
|
||||
fail("No getAndroidPlatform() associated with the AndroidSdkAdditionalData: " + data);
|
||||
}
|
||||
} else {
|
||||
fail("Could not find data associated with the SDK: " + androidSdk.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns a description of the given elements, suitable as unit test golden file output */
|
||||
public static String describeElements(@Nullable PsiElement[] elements) {
|
||||
if (elements == null) {
|
||||
return "Empty";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (PsiElement target : elements) {
|
||||
appendElementDescription(sb, target);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Appends a description of the given element, suitable as unit test golden file output */
|
||||
public static void appendElementDescription(@NotNull StringBuilder sb, @NotNull PsiElement element) {
|
||||
if (element instanceof LazyValueResourceElementWrapper) {
|
||||
LazyValueResourceElementWrapper wrapper = (LazyValueResourceElementWrapper)element;
|
||||
XmlAttributeValue value = wrapper.computeElement();
|
||||
if (value != null) {
|
||||
element = value;
|
||||
}
|
||||
}
|
||||
PsiFile file = element.getContainingFile();
|
||||
int offset = element.getTextOffset();
|
||||
TextRange segment = element.getTextRange();
|
||||
appendSourceDescription(sb, file, offset, segment);
|
||||
}
|
||||
|
||||
/** Appends a description of the given elements, suitable as unit test golden file output */
|
||||
public static void appendSourceDescription(@NotNull StringBuilder sb, @Nullable PsiFile file, int offset, @Nullable Segment segment) {
|
||||
if (file != null && segment != null) {
|
||||
if (ResourceHelper.getFolderType(file) != null) {
|
||||
assertNotNull(file.getParent());
|
||||
sb.append(file.getParent().getName());
|
||||
sb.append("/");
|
||||
}
|
||||
sb.append(file.getName());
|
||||
sb.append(':');
|
||||
String text = file.getText();
|
||||
int lineNumber = 1;
|
||||
for (int i = 0; i < offset; i++) {
|
||||
if (text.charAt(i) == '\n') {
|
||||
lineNumber++;
|
||||
}
|
||||
}
|
||||
sb.append(lineNumber);
|
||||
sb.append(":");
|
||||
sb.append('\n');
|
||||
int startOffset = segment.getStartOffset();
|
||||
int endOffset = segment.getEndOffset();
|
||||
assertTrue(offset == -1 || offset >= startOffset);
|
||||
assertTrue(offset == -1 || offset <= endOffset);
|
||||
|
||||
int lineStart = startOffset;
|
||||
while (lineStart > 0 && text.charAt(lineStart - 1) != '\n') {
|
||||
lineStart--;
|
||||
}
|
||||
|
||||
// Skip over leading whitespace
|
||||
while (lineStart < startOffset && Character.isWhitespace(text.charAt(lineStart))) {
|
||||
lineStart++;
|
||||
}
|
||||
|
||||
int lineEnd = startOffset;
|
||||
while (lineEnd < text.length() && text.charAt(lineEnd) != '\n') {
|
||||
lineEnd++;
|
||||
}
|
||||
String indent = " ";
|
||||
sb.append(indent);
|
||||
sb.append(text.substring(lineStart, lineEnd));
|
||||
sb.append('\n');
|
||||
sb.append(indent);
|
||||
for (int i = lineStart; i < lineEnd; i++) {
|
||||
if (i == offset) {
|
||||
sb.append('|');
|
||||
} else if (i >= startOffset && i <= endOffset) {
|
||||
sb.append('~');
|
||||
} else {
|
||||
sb.append(' ');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sb.append(offset);
|
||||
sb.append(":?");
|
||||
}
|
||||
sb.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user