|
| 1 | +/** |
| 2 | + * Copyright (C) 2010-2013 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.receiver; |
| 17 | + |
| 18 | +import org.androidannotations.AndroidAnnotationProcessor; |
| 19 | +import org.androidannotations.utils.AAProcessorTestHelper; |
| 20 | +import org.junit.Before; |
| 21 | +import org.junit.Test; |
| 22 | + |
| 23 | +import java.io.IOException; |
| 24 | + |
| 25 | +public class ReceiverRegistrationTest extends AAProcessorTestHelper { |
| 26 | + |
| 27 | + @Before |
| 28 | + public void setup() { |
| 29 | + addManifestProcessorParameter(ActivityWithValidReceiver.class); |
| 30 | + addProcessor(AndroidAnnotationProcessor.class); |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + public void activity_with_valid_receiver_annotation_compile() throws IOException { |
| 35 | + CompileResult result = compileFiles(ActivityWithValidReceiver.class); |
| 36 | + assertCompilationSuccessful(result); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + public void activity_with_invalid_registerAt_not_compile() throws IOException { |
| 41 | + CompileResult result = compileFiles(ActivityWithInvalidRegisterAt.class); |
| 42 | + assertCompilationErrorOn(ActivityWithInvalidRegisterAt.class, "@Receiver", result); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void activity_with_two_method_with_same_name_not_compile() throws IOException { |
| 47 | + CompileResult result = compileFiles(ActivityWithTwoSameNameMethod.class); |
| 48 | + assertCompilationErrorOn(ActivityWithTwoSameNameMethod.class, "@Receiver", result); |
| 49 | + assertCompilationErrorCount(2, result); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void fragment_with_valid_receiver_annotation_compile() throws IOException { |
| 54 | + CompileResult result = compileFiles(FragmentWithValidReceiver.class); |
| 55 | + assertCompilationSuccessful(result); |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + public void service_with_valid_receiver_annotation_compile() throws IOException { |
| 60 | + CompileResult result = compileFiles(ServiceWithValidReceiver.class); |
| 61 | + assertCompilationSuccessful(result); |
| 62 | + } |
| 63 | + |
| 64 | + @Test |
| 65 | + public void service_with_invalid_registerAt_not_compile() throws IOException { |
| 66 | + CompileResult result = compileFiles(ServiceWithInvalidReceiver.class); |
| 67 | + assertCompilationErrorOn(ServiceWithInvalidReceiver.class, "@Receiver", result); |
| 68 | + assertCompilationErrorCount(3, result); |
| 69 | + } |
| 70 | + |
| 71 | +} |
0 commit comments