Skip to content

Commit 492820b

Browse files
committed
add compilation test for view casting of view listener annotations
1 parent d989b7d commit 492820b

6 files changed

Lines changed: 218 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (C) 2010-2016 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.viewlistener;
17+
18+
import org.androidannotations.annotations.Click;
19+
import org.androidannotations.annotations.EActivity;
20+
import org.androidannotations.annotations.FocusChange;
21+
import org.androidannotations.annotations.LongClick;
22+
import org.androidannotations.annotations.Touch;
23+
import org.androidannotations.viewbyid.R;
24+
25+
import android.app.Activity;
26+
27+
@EActivity
28+
public abstract class AbstractViewListenerActivity extends Activity {
29+
30+
@FocusChange(R.id.view)
31+
protected void onFocusChange() {
32+
}
33+
34+
@Click(R.id.view)
35+
protected void onClick() {
36+
}
37+
38+
@LongClick(R.id.view)
39+
protected void onLongClick() {
40+
}
41+
42+
@Touch(R.id.view)
43+
protected void onTouch() {
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright (C) 2010-2016 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.viewlistener;
17+
18+
import org.androidannotations.annotations.EActivity;
19+
import org.androidannotations.annotations.ItemClick;
20+
import org.androidannotations.annotations.ItemLongClick;
21+
import org.androidannotations.annotations.ItemSelect;
22+
import org.androidannotations.viewbyid.R;
23+
24+
@EActivity
25+
public class AdapterViewListenerActivity extends AbstractViewListenerActivity {
26+
27+
@ItemClick(R.id.view)
28+
protected void onItemClick() {
29+
}
30+
31+
@ItemLongClick(R.id.view)
32+
protected void onItemLongClick() {
33+
}
34+
35+
@ItemSelect(R.id.view)
36+
protected void onItemSelect(boolean selected) {
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (C) 2010-2016 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.viewlistener;
17+
18+
import org.androidannotations.annotations.CheckedChange;
19+
import org.androidannotations.annotations.EActivity;
20+
import org.androidannotations.viewbyid.R;
21+
22+
@EActivity
23+
public class CompoundButtonListenerActivity extends AbstractViewListenerActivity {
24+
25+
@CheckedChange(R.id.view)
26+
protected void onCheckedChange() {
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright (C) 2010-2016 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.viewlistener;
17+
18+
import org.androidannotations.annotations.EActivity;
19+
import org.androidannotations.annotations.EditorAction;
20+
import org.androidannotations.viewbyid.R;
21+
22+
@EActivity
23+
public class TextViewListenerActivity extends AbstractViewListenerActivity {
24+
25+
@EditorAction(R.id.view)
26+
protected void onEditorAction() {
27+
}
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright (C) 2010-2016 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.viewlistener;
17+
18+
import java.io.IOException;
19+
20+
import org.androidannotations.internal.AndroidAnnotationProcessor;
21+
import org.androidannotations.testutils.AAProcessorTestHelper;
22+
import org.junit.Before;
23+
import org.junit.Test;
24+
25+
public class ViewListenerCompilationTest extends AAProcessorTestHelper {
26+
27+
@Before
28+
public void setUp() {
29+
addManifestProcessorParameter(AbstractViewListenerActivity.class);
30+
addProcessor(AndroidAnnotationProcessor.class);
31+
ensureOutputDirectoryIsEmpty();
32+
}
33+
34+
@Test
35+
public void ensureAdapterViewListenerCompilationSuccessful() throws IOException {
36+
assertCompilationSuccessful(compileFiles(AdapterViewListenerActivity.class));
37+
}
38+
39+
@Test
40+
public void ensureTextViewListenerCompilationSuccessful() throws IOException {
41+
assertCompilationSuccessful(compileFiles(TextViewListenerActivity.class));
42+
}
43+
44+
@Test
45+
public void ensureCompundButtonListenerCompilationSuccessful() throws IOException {
46+
assertCompilationSuccessful(compileFiles(CompoundButtonListenerActivity.class));
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
4+
Copyright (C) 2010-2016 eBusiness Information, Excilys Group
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"); you may not
7+
use this file except in compliance with the License. You may obtain a copy of
8+
the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed To in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
License for the specific language governing permissions and limitations under
16+
the License.
17+
18+
-->
19+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
20+
package="org.androidannotations.viewbyid"
21+
android:versionCode="1"
22+
android:versionName="1.0" >
23+
24+
<application>
25+
<activity android:name="org.androidannotations.viewlistener.CompoundButtonListenerActivity_" />
26+
<activity android:name="org.androidannotations.viewlistener.AdapterViewListenerActivity_" />
27+
<activity android:name="org.androidannotations.viewlistener.TextViewListenerActivity_" />
28+
</application>
29+
30+
</manifest>

0 commit comments

Comments
 (0)