|
| 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 com.googlecode.androidannotations.test15; |
| 17 | + |
| 18 | +import static org.fest.assertions.Assertions.assertThat; |
| 19 | + |
| 20 | +import org.junit.Test; |
| 21 | +import org.junit.runner.RunWith; |
| 22 | + |
| 23 | +@RunWith(AndroidAnnotationsTestRunner.class) |
| 24 | +public class AwaitingResultActivityTest { |
| 25 | + |
| 26 | + @Test |
| 27 | + public void onlyFirstRequestAnnotatedMethodAreCalled() { |
| 28 | + AwaitingResultActivity_ activity = new AwaitingResultActivity_(); |
| 29 | + |
| 30 | + activity.onActivityResult(AwaitingResultActivity.FIRST_REQUEST, 0, null); |
| 31 | + |
| 32 | + assertThat(activity.onResultCalled).isTrue(); |
| 33 | + assertThat(activity.onResultWithDataCalled).isFalse(); |
| 34 | + assertThat(activity.onActivityResultWithResultCodeAndDataCalled).isFalse(); |
| 35 | + assertThat(activity.onActivityResultWithDataAndResultCodeCalled).isFalse(); |
| 36 | + assertThat(activity.onResultWithIntResultCodeCalled).isFalse(); |
| 37 | + assertThat(activity.onResultWithIntegerResultCodeCalled).isFalse(); |
| 38 | + } |
| 39 | + |
| 40 | + |
| 41 | + @Test |
| 42 | + public void onlySecondRequestAnnotatedMethodAreCalled() { |
| 43 | + AwaitingResultActivity_ activity = new AwaitingResultActivity_(); |
| 44 | + |
| 45 | + activity.onActivityResult(AwaitingResultActivity.SECOND_REQUEST, 0, null); |
| 46 | + |
| 47 | + assertThat(activity.onResultCalled).isFalse(); |
| 48 | + assertThat(activity.onResultWithDataCalled).isTrue(); |
| 49 | + assertThat(activity.onActivityResultWithResultCodeAndDataCalled).isTrue(); |
| 50 | + assertThat(activity.onActivityResultWithDataAndResultCodeCalled).isTrue(); |
| 51 | + assertThat(activity.onResultWithIntResultCodeCalled).isFalse(); |
| 52 | + assertThat(activity.onResultWithIntegerResultCodeCalled).isFalse(); |
| 53 | + } |
| 54 | + |
| 55 | + |
| 56 | + @Test |
| 57 | + public void onlyThirdRequestAnnotatedMethodAreCalled() { |
| 58 | + AwaitingResultActivity_ activity = new AwaitingResultActivity_(); |
| 59 | + |
| 60 | + activity.onActivityResult(AwaitingResultActivity.THIRD_REQUEST, 0, null); |
| 61 | + |
| 62 | + assertThat(activity.onResultCalled).isFalse(); |
| 63 | + assertThat(activity.onResultWithDataCalled).isFalse(); |
| 64 | + assertThat(activity.onActivityResultWithResultCodeAndDataCalled).isFalse(); |
| 65 | + assertThat(activity.onActivityResultWithDataAndResultCodeCalled).isFalse(); |
| 66 | + assertThat(activity.onResultWithIntResultCodeCalled).isTrue(); |
| 67 | + assertThat(activity.onResultWithIntegerResultCodeCalled).isTrue(); |
| 68 | + } |
| 69 | + |
| 70 | +} |
0 commit comments