Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1355b0c

Browse files
authored
Merge pull request #9 from tnorbye/studio30
Update to Gradle 3.0, and update tests to new DSL
2 parents 57511bd + b14198a commit 1355b0c

File tree

4 files changed

+81
-101
lines changed

4 files changed

+81
-101
lines changed

‎build.gradle‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@
1717
apply plugin: 'java'
1818

1919
repositories {
20+
google()
2021
jcenter()
21-
maven {
22-
url "http://dl.bintray.com/android/android-tools"
23-
}
22+
}
23+
24+
ext {
25+
lintVersion = '26.0.0-beta2'
2426
}
2527

2628
dependencies {
27-
compile 'com.android.tools.lint:lint-api:25.3.0'
28-
compile 'com.android.tools.lint:lint-checks:25.3.0'
29-
testCompile 'junit:junit:4.11'
30-
testCompile 'com.android.tools.lint:lint:25.3.0'
31-
testCompile 'com.android.tools.lint:lint-tests:25.3.0'
32-
testCompile 'com.android.tools:testutils:25.3.0'
29+
compile "com.android.tools.lint:lint-api:$lintVersion"
30+
compile "com.android.tools.lint:lint-checks:$lintVersion"
31+
testCompile "junit:junit:4.11"
32+
testCompile "com.android.tools.lint:lint:$lintVersion"
33+
testCompile "com.android.tools.lint:lint-tests:$lintVersion"
34+
testCompile "com.android.tools:testutils:$lintVersion"
3335
}
3436

3537
jar {
3638
manifest {
37-
attributes("Lint-Registry": "com.example.google.lint.MyIssueRegistry")
39+
attributes("Lint-Registry-v2": "com.example.google.lint.MyIssueRegistry")
3840
}
3941
}
4042

‎gradle/wrapper/gradle-wrapper.jar‎

1.34 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Aug 21 14:39:26 PDT 2015
1+
#Wed Aug 09 14:33:29 PDT 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip

‎src/test/java/com/example/google/lint/MainActivityDetectorTest.java‎

Lines changed: 67 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@
1616

1717
package com.example.google.lint;
1818

19-
import com.android.annotations.NonNull;
2019
import com.android.tools.lint.checks.infrastructure.LintDetectorTest;
21-
import com.android.tools.lint.client.api.LintClient;
2220
import com.android.tools.lint.detector.api.Detector;
2321
import com.android.tools.lint.detector.api.Issue;
24-
import com.android.tools.lint.detector.api.Project;
2522

2623
import java.util.Collections;
27-
import java.util.HashSet;
2824
import java.util.List;
29-
import java.util.Set;
3025

3126
import static com.android.SdkConstants.FN_ANDROID_MANIFEST_XML;
3227

@@ -35,11 +30,6 @@
3530
* to adjust your code for the next tools release.</b>
3631
*/
3732
public class MainActivityDetectorTest extends LintDetectorTest {
38-
/**
39-
* The set of enabled issues for a given test.
40-
*/
41-
private Set<Issue> mEnabled = new HashSet<Issue>();
42-
4333
@Override
4434
protected Detector getDetector() {
4535
return new MainActivityDetector();
@@ -50,103 +40,91 @@ protected List<Issue> getIssues() {
5040
return Collections.singletonList(MainActivityDetector.ISSUE);
5141
}
5242

53-
/**
54-
* Gets the configuration for the test.
55-
* Each test can have a set of enabled issues by assigning the member field {@link #mEnabled}.
56-
*/
57-
@Override
58-
protected TestConfiguration getConfiguration(LintClient client, Project project) {
59-
return new TestConfiguration(client, project, null) {
60-
@Override
61-
public boolean isEnabled(@NonNull Issue issue) {
62-
return super.isEnabled(issue) && mEnabled.contains(issue);
63-
}
64-
};
65-
}
66-
6743
/**
6844
* Test that a manifest with an activity with a launcher intent has no warnings.
6945
*/
70-
public void testHasMainActivity() throwsException{
71-
mEnabled = Collections.singleton(MainActivityDetector.ISSUE);
72-
Stringexpected = "No warnings.";
73-
Stringresult = lintProject(xml(FN_ANDROID_MANIFEST_XML, "" +
74-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
75-
"<manifest package=\"com.example.android.custom-lint-rules\"\n" +
76-
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
77-
" <application>\n" +
78-
" <activity android:name=\"com.example.android.custom-lint-rules" +
79-
".OtherActivity\">\n" +
80-
" </activity>\n" +
81-
"\n" +
82-
" <activity android:name=\"com.example.android.custom-lint-rules" +
83-
".MainActivity\">\n" +
84-
" <intent-filter>\n" +
85-
" <action android:name=\"android.intent.action.MAIN\"/>\n" +
86-
" <category android:name=\"android.intent.category.LAUNCHER\"/>\n" +
87-
" </intent-filter>\n" +
88-
" </activity>\n" +
89-
" </application>\n" +
90-
"</manifest>"));
91-
assertEquals(expected, result);
46+
public void testHasMainActivity() {
47+
lint().files(
48+
xml(FN_ANDROID_MANIFEST_XML, "" +
49+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
50+
"<manifest package=\"com.example.android.custom-lint-rules\"\n" +
51+
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
52+
" <application>\n" +
53+
" <activity android:name=\"com.example.android.custom-lint-rules" +
54+
".OtherActivity\">\n" +
55+
" </activity>\n" +
56+
"\n" +
57+
" <activity android:name=\"com.example.android.custom-lint-rules" +
58+
".MainActivity\">\n" +
59+
" <intent-filter>\n" +
60+
" <action android:name=\"android.intent.action.MAIN\"/>\n" +
61+
" <category android:name=\"android.intent.category.LAUNCHER\"/>\n" +
62+
" </intent-filter>\n" +
63+
" </activity>\n" +
64+
" </application>\n" +
65+
"</manifest>"))
66+
.run()
67+
.expectClean();
9268
}
9369

9470
/**
9571
* Test that a manifest <em>without</em> an activity with a launcher intent reports an error.
9672
*/
97-
public void testMissingMainActivity() throws Exception {
98-
mEnabled = Collections.singleton(MainActivityDetector.ISSUE);
73+
public void testMissingMainActivity() {
9974
String expected = "AndroidManifest.xml: Error: Expecting AndroidManifest.xml to have an " +
10075
"activity with a launcher intent. [MainActivityDetector]\n" +
10176
"1 errors, 0 warnings\n";
102-
String result = lintProject(xml(FN_ANDROID_MANIFEST_XML, "" +
103-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
104-
"<manifest package=\"com.example.android.custom-lint-rules\"\n" +
105-
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
106-
" <application>\n" +
107-
" <activity android:name=\"com.example.android.custom-lint-rules" +
108-
".Activity1\">\n" +
109-
" <intent-filter>\n" +
110-
" <action android:name=\"android.intent.action.VIEW\" />\n" +
111-
"\n" +
112-
" <category android:name=\"android.intent.category.HOME\" />\n" +
113-
" <category android:name=\"android.intent.category.LAUNCHER\" />\n" +
114-
" <category android:name=\"android.intent.category.DEFAULT\" />\n" +
115-
" <category android:name=\"android.intent.category.BROWSABLE\" " +
116-
"/>\n" +
117-
" </intent-filter>\n" +
118-
" </activity>\n" +
119-
"\n" +
120-
" <activity android:name=\"com.example.android.custom-lint-rules" +
121-
".Activity2\">\n" +
122-
" </activity>\n" +
123-
"\n" +
124-
" <activity android:name=\"com.example.android.custom-lint-rules" +
125-
".Activity3\">\n" +
126-
" <intent-filter>\n" +
127-
" <action android:name=\"android.intent.action.SEND\"/>\n" +
128-
" <category android:name=\"android.intent.category.DEFAULT\"/>\n" +
129-
" <data android:mimeType=\"text/plain\"/>\n" +
130-
" </intent-filter>\n" +
131-
" </activity>\n" +
132-
" </application>\n" +
133-
"</manifest>"));
134-
assertEquals(expected, result);
77+
lint().files(
78+
xml(FN_ANDROID_MANIFEST_XML, "" +
79+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
80+
"<manifest package=\"com.example.android.custom-lint-rules\"\n" +
81+
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
82+
" <application>\n" +
83+
" <activity android:name=\"com.example.android.custom-lint-rules" +
84+
".Activity1\">\n" +
85+
" <intent-filter>\n" +
86+
" <action android:name=\"android.intent.action.VIEW\" />\n" +
87+
"\n" +
88+
" <category android:name=\"android.intent.category.HOME\" />\n" +
89+
" <category android:name=\"android.intent.category.LAUNCHER\" />\n" +
90+
" <category android:name=\"android.intent.category.DEFAULT\" />\n" +
91+
" <category android:name=\"android.intent.category.BROWSABLE\" " +
92+
"/>\n" +
93+
" </intent-filter>\n" +
94+
" </activity>\n" +
95+
"\n" +
96+
" <activity android:name=\"com.example.android.custom-lint-rules" +
97+
".Activity2\">\n" +
98+
" </activity>\n" +
99+
"\n" +
100+
" <activity android:name=\"com.example.android.custom-lint-rules" +
101+
".Activity3\">\n" +
102+
" <intent-filter>\n" +
103+
" <action android:name=\"android.intent.action.SEND\"/>\n" +
104+
" <category android:name=\"android.intent.category.DEFAULT\"/>\n" +
105+
" <data android:mimeType=\"text/plain\"/>\n" +
106+
" </intent-filter>\n" +
107+
" </activity>\n" +
108+
" </application>\n" +
109+
"</manifest>"))
110+
.run()
111+
.expect(expected);
135112
}
136113

137114
/**
138115
* Test that a manifest without an <code>&lt;application&gt;</code> tag reports an error.
139116
*/
140-
public void testMissingApplication() throws Exception {
141-
mEnabled = Collections.singleton(MainActivityDetector.ISSUE);
117+
public void testMissingApplication() {
142118
String expected = "AndroidManifest.xml: Error: Expecting AndroidManifest.xml to have an " +
143119
"<activity> tag. [MainActivityDetector]\n" +
144120
"1 errors, 0 warnings\n";
145-
String result = lintProject(xml(FN_ANDROID_MANIFEST_XML, "" +
146-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
147-
"<manifest package=\"com.example.android.custom-lint-rules\"\n" +
148-
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
149-
"</manifest>"));
150-
assertEquals(expected, result);
121+
lint().files(
122+
xml(FN_ANDROID_MANIFEST_XML, "" +
123+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
124+
"<manifest package=\"com.example.android.custom-lint-rules\"\n" +
125+
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
126+
"</manifest>"))
127+
.run()
128+
.expect(expected);
151129
}
152130
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /