diff options
author | Ahmet Kerim Senol <akerim@google.com> | 2022-07-01 07:18:36 +0000 |
---|---|---|
committer | TreeHugger Robot <treehugger-gerrit@google.com> | 2022-07-01 11:49:39 +0000 |
commit | 8a6e23eead9a67062b9a9237963a620eeb3e13d1 (patch) | |
tree | 9f0aeca226c04ff22ae0c4094458c5076d47ac2d | |
parent | 0d9e8348c6216396701defb833ff6f883336284b (diff) | |
download | idea-8a6e23eead9a67062b9a9237963a620eeb3e13d1.tar.gz |
Add a test project with a single manifest merging error.
This is used in ManifestPanelContentTest to assert the current
behaviour of the manifest panel to prepare it for more substantial
changes.
Here is a screenshot for the current output for the erroneous project:
https://screenshot.googleplex.com/6uU6ai7GkrxbfAK
Bug: 230452643
Test: Added testProject_withErrors_simpleApplicationMissingExport to
ManifestPanelContentTest
Change-Id: Ie88770c9aa324d84c81bb393b8f9ba84aed31efc
Change-Id: Ie7accab023c3cf7706823223b84978cb5a04ff90
31 files changed, 541 insertions, 17 deletions
diff --git a/android-test-framework/testSrc/com/android/tools/idea/testing/TestProjectPaths.java b/android-test-framework/testSrc/com/android/tools/idea/testing/TestProjectPaths.java index 6d2940a5918..ab86e816bbe 100644 --- a/android-test-framework/testSrc/com/android/tools/idea/testing/TestProjectPaths.java +++ b/android-test-framework/testSrc/com/android/tools/idea/testing/TestProjectPaths.java @@ -118,4 +118,6 @@ public final class TestProjectPaths { public static final String UNUSED_RESOURCES_GROOVY = "projects/unusedResources"; public static final String UNUSED_RESOURCES_KTS = "projects/unusedResourcesKotlin"; public static final String UNUSED_RESOURCES_MULTI_MODULE = "projects/unusedResourcesMultiModule"; + + public static final String WITH_ERRORS_SIMPLE_APPLICATION_MISSING_EXPORT = "projects/withErrors/simpleApplicationMissingExport"; } diff --git a/android/testData/projects/navigationEditor/includeFromLib/snapshots/contentForNavigationEditor_includeFromLib_manifest_report.html.txt b/android/testData/projects/navigationEditor/includeFromLib/snapshots/project_navigationEditor_includeFromLib_manifest_report.html.txt index 4a16a1ad4ba..4a16a1ad4ba 100644 --- a/android/testData/projects/navigationEditor/includeFromLib/snapshots/contentForNavigationEditor_includeFromLib_manifest_report.html.txt +++ b/android/testData/projects/navigationEditor/includeFromLib/snapshots/project_navigationEditor_includeFromLib_manifest_report.html.txt diff --git a/android/testData/projects/navigationEditor/includeFromLib/snapshots/contentForNavigationEditor_includeFromLib_merged_manifest.xml.txt b/android/testData/projects/navigationEditor/includeFromLib/snapshots/project_navigationEditor_includeFromLib_merged_manifest.xml.txt index c88de41766e..c88de41766e 100644 --- a/android/testData/projects/navigationEditor/includeFromLib/snapshots/contentForNavigationEditor_includeFromLib_merged_manifest.xml.txt +++ b/android/testData/projects/navigationEditor/includeFromLib/snapshots/project_navigationEditor_includeFromLib_merged_manifest.xml.txt diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/.gitignore b/android/testData/projects/withErrors/simpleApplicationMissingExport/.gitignore new file mode 100644 index 00000000000..49e18267fc8 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/.gitignore @@ -0,0 +1,17 @@ +.gradle +/gradle +/local.properties +/.idea/copyright +/.idea/scopes +/.idea/libraries +/.idea/compiler.xml +/.idea/encodings.xml +/.idea/gradle.xml +/.idea/misc.xml +/.idea/vcs.xml +/.idea/workspace.xml +.DS_Store +/build +gradlew +gradlew.bat +../../snapshots/projects/simpleApplication/gradle.properties diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/.gitignore b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/.gitignore new file mode 100644 index 00000000000..796b96d1c40 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/build.gradle b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/build.gradle new file mode 100644 index 00000000000..ab87c889463 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.2" + useLibrary 'org.apache.http.legacy' + + defaultConfig { + applicationId "google.simpleapplication" + minSdkVersion 19 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} + +dependencies { + api fileTree(dir: 'libs', include: ['*.jar']) + api 'com.android.support:appcompat-v7:+' + api 'com.google.guava:guava:19.0' + api 'com.android.support.constraint:constraint-layout:1.0.2' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:+' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:+' +} diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/proguard-rules.pro b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/proguard-rules.pro new file mode 100644 index 00000000000..e2f6a3ded07 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Applications/adt-bundle-mac-x86_64-20131030/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/androidTest/java/google/simpleapplication/ApplicationTest.java b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/androidTest/java/google/simpleapplication/ApplicationTest.java new file mode 100644 index 00000000000..0b16c57ceca --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/androidTest/java/google/simpleapplication/ApplicationTest.java @@ -0,0 +1,15 @@ +package google.simpleapplication; + +import android.support.test.runner.AndroidJUnit4; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> + */ +@RunWith(AndroidJUnit4.class) +public class ApplicationTest { + @Test + public void exampleTest() { + } +}
\ No newline at end of file diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/AndroidManifest.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..77ffec64cf7 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="google.simpleapplication" > + + <application + android:allowBackup="true" + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name=".MyActivity" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/java/google/simpleapplication/MyActivity.java b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/java/google/simpleapplication/MyActivity.java new file mode 100644 index 00000000000..490b137b4d3 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/java/google/simpleapplication/MyActivity.java @@ -0,0 +1,36 @@ +package google.simpleapplication; + +import android.app.Activity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + + +public class MyActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_my); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.my, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + if (id == R.id.action_settings) { + return true; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/drawable/ic_launcher.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/drawable/ic_launcher.xml new file mode 100644 index 00000000000..bebd9834a0e --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/drawable/ic_launcher.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<color xmlns:android="http://schemas.android.com/apk/res/android" android:color="#ff0000" /> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/absolute.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/absolute.xml new file mode 100644 index 00000000000..a4c567ae912 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/absolute.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="utf-8"?> +<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:layout_width="match_parent" android:layout_height="match_parent"> + + <Button + android:text="Button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_x="3dp" + android:layout_y="2dp" + android:id="@+id/button" /> + + <Button + android:text="Button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_x="6dp" + android:layout_y="50dp" + android:id="@+id/button2" /> + + <EditText + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:inputType="textPersonName" + android:text="Name" + android:ems="10" + android:layout_x="108dp" + android:layout_y="206dp" + android:id="@+id/editText" /> + + <LinearLayout + android:layout_width="359dp" + android:layout_height="89dp" + android:layout_x="17dp" + android:layout_y="416dp"> + + <Button + android:text="Button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/button3" + android:layout_weight="1" /> + + <Button + android:text="Button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/button5" + android:layout_weight="1" /> + + <Button + android:text="Button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/button6" + android:layout_weight="1" /> + </LinearLayout> +</AbsoluteLayout> + diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/activity_my.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/activity_my.xml new file mode 100644 index 00000000000..c17166f4d34 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/activity_my.xml @@ -0,0 +1,16 @@ +<RelativeLayout 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" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + android:paddingBottom="@dimen/activity_vertical_margin" + tools:context=".MyActivity"> + + <TextView + android:text="@string/hello_world" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + +</RelativeLayout> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/frames.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/frames.xml new file mode 100644 index 00000000000..985fa0ccf9b --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/layout/frames.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Welcome" /> + + <FrameLayout + android:id="@+id/attending_remotely" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:foreground="?android:selectableItemBackground"> + + <ImageView + android:layout_width="100dp" + android:layout_height="100dp" + android:adjustViewBounds="true" + android:scaleType="centerInside" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom|end|right" + android:text="Remotely" /> + + </FrameLayout> + + <FrameLayout + android:id="@+id/attending_in_person" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:foreground="?android:selectableItemBackground"> + + <ImageView + android:layout_width="100dp" + android:layout_height="100dp" + android:adjustViewBounds="true" + android:scaleType="centerInside" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom|end|right" + android:text="In Person" /> + + </FrameLayout> + +</LinearLayout> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/menu/my.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/menu/my.xml new file mode 100644 index 00000000000..bea58cc00be --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/menu/my.xml @@ -0,0 +1,8 @@ +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + tools:context=".MyActivity" > + <item android:id="@+id/action_settings" + android:title="@string/action_settings" + android:orderInCategory="100" + android:showAsAction="never" /> +</menu> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-en-rGB/strings.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-en-rGB/strings.xml new file mode 100644 index 00000000000..35986fa7193 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-en-rGB/strings.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2014 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. + --> +<resources> + + <string name="app_name">Simple Application</string> + <string name="hello_world">Hello world!</string> + +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-en/strings.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-en/strings.xml new file mode 100644 index 00000000000..d13ac5fc81f --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-en/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">Simple Application</string> + <string name="hello_world">Hello world!</string> + <string name="action_settings">Settings</string> + +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-ta/strings.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-ta/strings.xml new file mode 100644 index 00000000000..d13ac5fc81f --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-ta/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">Simple Application</string> + <string name="hello_world">Hello world!</string> + <string name="action_settings">Settings</string> + +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-v19/styles.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-v19/styles.xml new file mode 100644 index 00000000000..de742ebe7e4 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-v19/styles.xml @@ -0,0 +1,6 @@ +<resources> + + <style name="PreviewTheme" parent="android:Theme.Holo"> + </style> + +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-v20/styles.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-v20/styles.xml new file mode 100644 index 00000000000..de742ebe7e4 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-v20/styles.xml @@ -0,0 +1,6 @@ +<resources> + + <style name="PreviewTheme" parent="android:Theme.Holo"> + </style> + +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-w820dp/dimens.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 00000000000..63fc8164446 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ +<resources> + <!-- Example customization of dimensions originally defined in res/values/dimens.xml + (such as screen margins) for screens with more than 820dp of available width. This + would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> + <dimen name="activity_horizontal_margin">64dp</dimen> +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-zh-rCN/strings.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-zh-rCN/strings.xml new file mode 100644 index 00000000000..100d85e9da1 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values-zh-rCN/strings.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2014 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. + --> +<resources> + <string name="app_name">谷歌 I/O</string> + <string name="hello_world">Hello world!</string> + <string name="action_settings">Settings</string> + <string name="cancel">取消</string> +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/dimens.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/dimens.xml new file mode 100644 index 00000000000..47c82246738 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ +<resources> + <!-- Default screen margins, per the Android Design guidelines. --> + <dimen name="activity_horizontal_margin">16dp</dimen> + <dimen name="activity_vertical_margin">16dp</dimen> +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/strings.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/strings.xml new file mode 100644 index 00000000000..d13ac5fc81f --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">Simple Application</string> + <string name="hello_world">Hello world!</string> + <string name="action_settings">Settings</string> + +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/styles.xml b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/styles.xml new file mode 100644 index 00000000000..fdc045eccfd --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/main/res/values/styles.xml @@ -0,0 +1,13 @@ +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> + <!-- Customize your theme here. --> + </style> + + <style name="PreviewTheme" parent="android:Theme.Holo.Light.DarkActionBar"> + </style> + + <style name="NotATheme"> + </style> +</resources> diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/test/java/google/simpleapplication/UnitTest.java b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/test/java/google/simpleapplication/UnitTest.java new file mode 100644 index 00000000000..767acad98f6 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/app/src/test/java/google/simpleapplication/UnitTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015 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 google.simpleapplication; + +import org.junit.Assert; +import org.junit.Test; + +import java.lang.Deprecated; + +/** + * A unit test to be executed on the local vm. + */ +public class UnitTest { + @Test + public void passingTest() throws Exception { + Assert.assertEquals(2, 1 + 1); + } + + @Test + public void failingTest() throws Exception { + Assert.assertEquals(5, 2 + 2); + } +}
\ No newline at end of file diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/build.gradle b/android/testData/projects/withErrors/simpleApplicationMissingExport/build.gradle new file mode 100644 index 00000000000..77e021b94c1 --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/build.gradle @@ -0,0 +1,21 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + // This will be populated by AndroidGradleTestCase + } + dependencies { + classpath 'com.android.tools.build:gradle:1.5.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + // This will be populated by AndroidGradleTestCase + } +} + +println("This is a simple application!") diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/settings.gradle b/android/testData/projects/withErrors/simpleApplicationMissingExport/settings.gradle new file mode 100644 index 00000000000..e7b4def49cb --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/snapshots/project_withErrors_simpleApplicationMissingExport_manifest_report.html.txt b/android/testData/projects/withErrors/simpleApplicationMissingExport/snapshots/project_withErrors_simpleApplicationMissingExport_manifest_report.html.txt new file mode 100644 index 00000000000..3a30c62847a --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/snapshots/project_withErrors_simpleApplicationMissingExport_manifest_report.html.txt @@ -0,0 +1,58 @@ +<html> + <head> + </head> + <body> + <u><b>Manifest Sources</b></u><br> + <table border="0"> + <tr> + <td width="24" height="24" style="background-color: #ffffff; border-top-color: #808080; border-top-style: solid; border-top-width: 1px; border-right-color: #808080; border-right-style: solid; border-right-width: 1px; border-bottom-color: #808080; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: #808080; border-left-style: solid; border-left-width: 1px"> + </td> + <td> + <a href='<PROJECT_DIR>/app/src/main/AndroidManifest.xml'>project.app + main</a> manifest (this file) + </td> + </tr> + </table> + <br> + <u><b>Other Manifest Files</b></u><br>(Included in merge, but did not + contribute any elements)<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/animated-vector-drawable-28.0.0/AndroidManifest.xml'>animated-vector-drawable:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/appcompat-v7-28.0.0/AndroidManifest.xml'>appcompat-v7:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/constraint-layout-1.0.2/AndroidManifest.xml'>constraint-layout:1.0.2</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/runtime-1.1.1/AndroidManifest.xml'>core:runtime:1.1.1</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/livedata-1.1.1/AndroidManifest.xml'>lifecycle:livedata:1.1.1</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/runtime-1.1.1/AndroidManifest.xml'>lifecycle:runtime:1.1.1</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/viewmodel-1.1.1/AndroidManifest.xml'>lifecycle:viewmodel:1.1.1</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/livedata-core-1.1.1/AndroidManifest.xml'>livedata-core:1.1.1</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/support-compat-28.0.0/AndroidManifest.xml'>support-compat:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/support-core-ui-28.0.0/AndroidManifest.xml'>support-core-ui:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/support-core-utils-28.0.0/AndroidManifest.xml'>support-core-utils:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/support-fragment-28.0.0/AndroidManifest.xml'>support-fragment:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/support-vector-drawable-28.0.0/AndroidManifest.xml'>support-vector-drawable:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/asynclayoutinflater-28.0.0/AndroidManifest.xml'>support:asynclayoutinflater:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/coordinatorlayout-28.0.0/AndroidManifest.xml'>support:coordinatorlayout:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/cursoradapter-28.0.0/AndroidManifest.xml'>support:cursoradapter:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/customview-28.0.0/AndroidManifest.xml'>support:customview:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/documentfile-28.0.0/AndroidManifest.xml'>support:documentfile:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/drawerlayout-28.0.0/AndroidManifest.xml'>support:drawerlayout:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/interpolator-28.0.0/AndroidManifest.xml'>support:interpolator:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/loader-28.0.0/AndroidManifest.xml'>support:loader:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/localbroadcastmanager-28.0.0/AndroidManifest.xml'>support:localbroadcastmanager:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/print-28.0.0/AndroidManifest.xml'>support:print:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/slidingpanelayout-28.0.0/AndroidManifest.xml'>support:slidingpanelayout:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/swiperefreshlayout-28.0.0/AndroidManifest.xml'>support:swiperefreshlayout:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/versionedparcelable-28.0.0/AndroidManifest.xml'>support:versionedparcelable:28.0.0</a> + manifest<br><a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/viewpager-28.0.0/AndroidManifest.xml'>support:viewpager:28.0.0</a> + manifest<br><br><br>Merging Errors:<br>Warning Namespace + 'android.support.graphics.drawable' used in: AndroidManifest.xml, + AndroidManifest.xml. <a href='<GRADLE>/caches/transforms-3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/transformed/support-vector-drawable-28.0.0/AndroidManifest.xml'>support-vector-drawable:28.0.0</a> + manifest<br><font color="#ff0000"><b>Error</b></font>: android:exported + needs to be explicitly specified for element + <activity#google.simpleapplication.MyActivity>. Apps targeting Android 12 + and higher are required to specify an explicit value for + `android:exported` when the corresponding component has an intent filter + defined. See + https://developer.android.com/guide/topics/manifest/activity-element#exported + for details. <a href='<PROJECT_DIR>/app/src/main/AndroidManifest.xml:9:8'>project.app + main</a> manifest (this file), line 9<br> + </body> +</html>
\ No newline at end of file diff --git a/android/testData/projects/withErrors/simpleApplicationMissingExport/snapshots/project_withErrors_simpleApplicationMissingExport_merged_manifest.xml.txt b/android/testData/projects/withErrors/simpleApplicationMissingExport/snapshots/project_withErrors_simpleApplicationMissingExport_merged_manifest.xml.txt new file mode 100644 index 00000000000..b2ec84759ac --- /dev/null +++ b/android/testData/projects/withErrors/simpleApplicationMissingExport/snapshots/project_withErrors_simpleApplicationMissingExport_merged_manifest.xml.txt @@ -0,0 +1 @@ +Pane content is empty
\ No newline at end of file diff --git a/android/testSrc/com/android/tools/idea/editors/manifest/ManifestPanelContentTest.kt b/android/testSrc/com/android/tools/idea/editors/manifest/ManifestPanelContentTest.kt index aaefd62a0c8..d6eb16168a7 100644 --- a/android/testSrc/com/android/tools/idea/editors/manifest/ManifestPanelContentTest.kt +++ b/android/testSrc/com/android/tools/idea/editors/manifest/ManifestPanelContentTest.kt @@ -25,7 +25,6 @@ import com.android.tools.idea.testing.GradleIntegrationTest import com.android.tools.idea.testing.SnapshotComparisonTest import com.android.tools.idea.testing.TestProjectPaths import com.android.tools.idea.testing.assertAreEqualToSnapshots -import com.android.tools.idea.testing.assertIsEqualToSnapshot import com.android.tools.idea.testing.gradleModule import com.android.tools.idea.testing.onEdt import com.android.tools.idea.testing.openPreparedProject @@ -42,6 +41,7 @@ import java.io.File import java.nio.file.Paths import java.util.concurrent.TimeUnit import java.io.StringWriter +import javax.swing.tree.TreeModel import javax.xml.transform.OutputKeys import javax.xml.transform.TransformerFactory import javax.xml.transform.dom.DOMSource @@ -63,17 +63,25 @@ class ManifestPanelContentTest : GradleIntegrationTest, SnapshotComparisonTest { override fun getTestDataDirectoryWorkspaceRelativePath(): String = "tools/adt/idea/android/testData" override fun getAdditionalRepos(): Collection<File> = listOf() - override val snapshotDirectoryWorkspaceRelativePath = Paths - .get(getTestDataDirectoryWorkspaceRelativePath()) - .resolve(TestProjectPaths.NAVIGATION_EDITOR_INCLUDE_FROM_LIB) - .resolve("snapshots") - .toString() + override lateinit var snapshotDirectoryWorkspaceRelativePath: String override fun getName(): String = testName.methodName @Test - fun contentForNavigationEditor_includeFromLib() { - val projectPath = TestProjectPaths.NAVIGATION_EDITOR_INCLUDE_FROM_LIB + fun testProject_navigationEditor_includeFromLib() { + testProject(TestProjectPaths.NAVIGATION_EDITOR_INCLUDE_FROM_LIB) + } + @Test + fun testProject_withErrors_simpleApplicationMissingExport() { + testProject(TestProjectPaths.WITH_ERRORS_SIMPLE_APPLICATION_MISSING_EXPORT) + } + + private fun testProject(projectPath : String) { + snapshotDirectoryWorkspaceRelativePath = Paths + .get(getTestDataDirectoryWorkspaceRelativePath()) + .resolve(projectPath) + .resolve("snapshots") + .toString() val projectRoot = prepareGradleProject(projectPath, "project") openPreparedProject("project") { project -> val appModule = project.gradleModule(":app")?.getMainModule() ?: error("Cannot find :app module") @@ -84,7 +92,8 @@ class ManifestPanelContentTest : GradleIntegrationTest, SnapshotComparisonTest { val panel = ManifestPanel(appModuleFacet, projectRule.testRootDisposable) panel.showManifest(mergedManifest, appModuleFacet.sourceProviders.mainManifestFile!!, false) val detailsPaneContent = panel.detailsPane.text - val manifestPaneContent = (panel.tree.model.root as ManifestTreeNode).userObject.transformToString() + val model: TreeModel? = panel.tree.model + val manifestPaneContent: String? = model?.transformToString() ProjectDumper().nest(projectRoot, "PROJECT_DIR") { assertAreEqualToSnapshots( @@ -96,7 +105,8 @@ class ManifestPanelContentTest : GradleIntegrationTest, SnapshotComparisonTest { } /* Goes through each line, removing empty lines and replacing hyperlinks with files with stable naming across different config/runs. */ - private fun ProjectDumper.normalizeContentForTest(htmlString: String) = htmlString + private fun ProjectDumper.normalizeContentForTest(htmlString: String?) = htmlString + .let { it ?: "Pane content is empty" } .lines() .filter { it.trim().isNotEmpty() } .joinToString(separator = "\n", postfix = "\n") { @@ -119,12 +129,16 @@ class ManifestPanelContentTest : GradleIntegrationTest, SnapshotComparisonTest { return fileAndPosition.substring(0, suffixPosition) to fileAndPosition.substring(suffixPosition, fileAndPosition.length) } - private fun Node.transformToString() = - StringWriter().let { - TransformerFactory.newInstance().newTransformer().apply { - setOutputProperty(OutputKeys.INDENT, "yes") - setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - }.transform(DOMSource(this), StreamResult(it)) - it.buffer.toString() + private fun TreeModel?.transformToString() : String? = + if (this == null) { + null + } else { + StringWriter().let { + TransformerFactory.newInstance().newTransformer().apply { + setOutputProperty(OutputKeys.INDENT, "yes") + setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + }.transform(DOMSource((this.root as ManifestTreeNode).userObject), StreamResult(it)) + it.buffer.toString() + } } }
\ No newline at end of file |