Skip to content

Commit d7342c9

Browse files
Added some tests for @background api classes generation
1 parent fc3d52e commit d7342c9

5 files changed

Lines changed: 68 additions & 13 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.androidannotations.generation;
2+
3+
import org.androidannotations.annotations.Background;
4+
import org.androidannotations.annotations.EActivity;
5+
6+
import android.app.Activity;
7+
8+
@EActivity
9+
public class ActivityWithBackgroundMethod extends Activity {
10+
11+
@Background
12+
public void executingOnBackground() {
13+
14+
}
15+
16+
}

‎AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/generation/ActivityWithoutOnBackPressedMethod.java‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/generation/OnBackPressedApiDependenciesTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public void setup() {
3333
}
3434

3535
@Test
36-
public void activity_without_on_back_pressed_generate_api_dependency() throws IOException {
36+
public void activity_with_on_back_pressed_generate_api_dependency() throws IOException {
3737
CompileResult result = compileFiles(ActivityWithOnBackPressedMethod.class);
3838
assertClassSourcesGeneratedToOutput(SdkVersionHelper.class);
3939
assertCompilationSuccessful(result);
4040
}
4141

4242
@Test
4343
public void activity_without_on_back_pressed_do_not_generate_api_dependency() throws IOException {
44-
CompileResult result = compileFiles(ActivityWithoutOnBackPressedMethod.class);
44+
CompileResult result = compileFiles(ActivityWithBackgroundMethod.class);
4545
assertClassSourcesNotGeneratedToOutput(SdkVersionHelper.class);
4646
assertCompilationSuccessful(result);
4747
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright (C) 2010-2012 eBusiness Information, Excilys Group
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed To in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package org.androidannotations.generation;
17+
18+
import java.io.IOException;
19+
20+
import org.androidannotations.AndroidAnnotationProcessor;
21+
import org.androidannotations.api.BackgroundExecutor;
22+
import org.androidannotations.utils.AAProcessorTestHelper;
23+
import org.junit.Before;
24+
import org.junit.Test;
25+
26+
public class OnBackgroundApiDependenciesTest extends AAProcessorTestHelper {
27+
28+
@Before
29+
public void setup() {
30+
addManifestProcessorParameter(OnBackgroundApiDependenciesTest.class);
31+
addProcessor(AndroidAnnotationProcessor.class);
32+
ensureOutputDirectoryIsEmpty();
33+
}
34+
35+
@Test
36+
public void activity_with_background_annotated_method_generate_api_dependency() throws IOException {
37+
CompileResult result = compileFiles(ActivityWithBackgroundMethod.class);
38+
assertClassSourcesGeneratedToOutput(BackgroundExecutor.class);
39+
assertCompilationSuccessful(result);
40+
}
41+
42+
@Test
43+
public void activity_without_background_annotated_method_generate_api_dependency() throws IOException {
44+
CompileResult result = compileFiles(ActivityWithOnBackPressedMethod.class);
45+
assertClassSourcesNotGeneratedToOutput(BackgroundExecutor.class);
46+
assertCompilationSuccessful(result);
47+
}
48+
49+
}

‎AndroidAnnotations/androidannotations/src/test/resources/org/androidannotations/generation/AndroidManifest.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<application>
2525
<activity android:name="org.androidannotations.generation.ActivityWithOnBackPressedMethod_" />
26-
<activity android:name="org.androidannotations.generation.ActivityWithoutOnBackPressedMethod_" />
26+
<activity android:name="org.androidannotations.generation.ActivityWithBackgroundMethod_" />
2727
</application>
2828

2929
</manifest>

0 commit comments

Comments
 (0)