Skip to content

Commit 1cee074

Browse files
committed
new Robotium tutorial and a l and a broken version for exercise
1 parent 586b92a commit 1cee074

File tree

172 files changed

+2631
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+2631
-38
lines changed

andoid.lint.example/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
# project structure.
99

1010
# Project target.
11-
target=android-15
11+
target=android-17

android.example/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
# project structure.
99

1010
# Project target.
11-
target=Google Inc.:Google APIs:15
11+
target=Google Inc.:Google APIs:17

com.vogella.android.mockito.intent.test/src/com/vogella/android/mockito/intent/test/MainActivtityTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public MainActivtityTest() {
2929
protected void setUp() throws Exception {
3030
super.setUp();
3131
MockitoAnnotations.initMocks(this);
32+
3233
myApp = mock(MyApp.class);
3334
when(myApp.getNumber()).thenReturn(42);
3435
setApplication(myApp);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Create test project
2+
3+
Add the following three libraries
4+
to the libs folder of your Android test project:
5+
6+
https://mockito.googlecode.com/files/mockito-all-1.9.5.jar
7+
8+
http://dexmaker.googlecode.com/files/dexmaker-1.0.jar
9+
10+
http://dexmaker.googlecode.com/files/dexmaker-mockito-1.0.jar
11+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Create new test class. Extend ActivityUnitTestCase for your test class
2+
3+
Develop first test method for createQuery using Mockito. Mock
4+
the Context object.
5+
6+
7+
Develop second test method. Use mock for application to check onCreate()
8+
use the information of the Application correctly
9+

com.vogella.android.mockito.intent/src/com/vogella/android/mockito/intent/MainActivity.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import android.content.Context;
55
import android.content.Intent;
66
import android.os.Bundle;
7-
import android.view.Menu;
87
import android.widget.TextView;
98

109
public class MainActivity extends Activity {
1110

11+
/*
12+
* Get Application and display data
13+
*/
14+
1215
@Override
1316
protected void onCreate(Bundle savedInstanceState) {
1417
super.onCreate(savedInstanceState);
@@ -18,11 +21,9 @@ protected void onCreate(Bundle savedInstanceState) {
1821
view.setText(String.valueOf(application.getNumber()));
1922
}
2023

21-
@Override
22-
public boolean onCreateOptionsMenu(Menu menu) {
23-
getMenuInflater().inflate(R.menu.main, menu);
24-
return true;
25-
}
24+
/*
25+
* Prepare Intent
26+
*/
2627

2728
public static Intent createQuery(Context context, String query, String value) {
2829
Intent i = new Intent(context, MyListActivity.class);

com.vogella.android.mockito.intent/src/com/vogella/android/mockito/intent/MyListActivity.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import android.app.Activity;
44
import android.os.Bundle;
5-
import android.view.Menu;
65

6+
/*
7+
* Just dumm
8+
*/
79
public class MyListActivity extends Activity {
810

911
@Override
@@ -12,11 +14,4 @@ protected void onCreate(Bundle savedInstanceState) {
1214
setContentView(R.layout.activity_main);
1315
}
1416

15-
@Override
16-
public boolean onCreateOptionsMenu(Menu menu) {
17-
// Inflate the menu; this adds items to the action bar if it is present.
18-
getMenuInflater().inflate(R.menu.main, menu);
19-
return true;
20-
}
21-
2217
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry kind="output" path="bin/classes"/>
8+
</classpath>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>com.vogella.android.roboguice.starter</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.vogella.android.roboguice.starter"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk
8+
android:minSdkVersion="17"
9+
android:targetSdkVersion="17" />
10+
11+
<application
12+
android:allowBackup="true"
13+
android:icon="@drawable/ic_launcher"
14+
android:label="@string/app_name"
15+
android:theme="@style/AppTheme" >
16+
<activity
17+
android:name="com.vogella.android.roboguice.starter.MainActivity"
18+
android:label="@string/app_name" >
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
27+
</manifest>

0 commit comments

Comments
 (0)