Skip to content
Snippets Groups Projects
Commit d6d5f14a authored by Adam A. Porter's avatar Adam A. Porter
Browse files

Recovered solution. Updated Robotium

parent fa9aaedf
No related branches found
No related tags found
No related merge requests found
Showing
with 323 additions and 231 deletions
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 18 compileSdkVersion 26
buildToolsVersion "21.1.2" buildToolsVersion "26.0.1"
defaultConfig { defaultConfig {
applicationId "course.labs.activitylab" applicationId "course.labs.activitylab"
minSdkVersion 14 minSdkVersion 21
targetSdkVersion 19 targetSdkVersion 26
testApplicationId "course.labs.activitylab.tests" testApplicationId "course.labs.activitylab.tests"
testInstrumentationRunner "android.test.InstrumentationTestRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
...@@ -22,5 +22,6 @@ android { ...@@ -22,5 +22,6 @@ android {
} }
dependencies { dependencies {
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1' androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.6.0'
} }
File deleted
...@@ -4,13 +4,9 @@ ...@@ -4,13 +4,9 @@
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" > android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@drawable/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme" > android:theme="@style/AppTheme" >
<activity <activity
......
...@@ -11,108 +11,179 @@ import android.widget.TextView; ...@@ -11,108 +11,179 @@ import android.widget.TextView;
public class ActivityOne extends Activity { public class ActivityOne extends Activity {
// Use these as keys when you're saving state between reconfigurations private static final String RESTART_KEY = "restart";
private static final String RESTART_KEY = "restart"; private static final String RESUME_KEY = "resume";
private static final String RESUME_KEY = "resume"; private static final String START_KEY = "start";
private static final String START_KEY = "start"; private static final String CREATE_KEY = "create";
private static final String CREATE_KEY = "create";
// String for LogCat documentation // String for LogCat documentation
private final static String TAG = "Lab-ActivityOne"; private final static String TAG = "Lab-ActivityOne";
// Lifecycle counters // Lifecycle counters
// TODO: // TODO:
// Create variables named // Create counter variables for onCreate(), onRestart(), onStart() and
// mCreate, mRestart, mStart and mResume // onResume()
// to count calls to onCreate(), onRestart(), onStart() and // You will need to increment these variables' values when their
// onResume(). These variables should not be defined as static. // corresponding lifecycle methods get called
// You will need to increment these variables' values when their private int mCreate = 0;
// corresponding lifecycle methods get called. private int mRestart = 0;
private int mStart = 0;
private int mResume = 0;
// TODO: Create variables for each of the TextViews // TODO: Create variables for each of the TextViews
// named mTvCreate, mTvRestart, mTvStart, mTvResume. private TextView mTvCreate;
// for displaying the current count of each counter variable private TextView mTvRestart;
private TextView mTvStart;
private TextView mTvResume;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_one); setContentView(R.layout.activity_one);
// TODO: Assign the appropriate TextViews to the TextView variables // TODO: Assign the appropriate TextViews to the TextView variables
// Hint: Access the TextView by calling Activity's findViewById() // Hint: Access the TextView by calling Activity's findViewById()
// textView1 = (TextView) findViewById(R.id.textView1); // textView1 = (TextView) findViewById(R.id.textView1);
Button launchActivityTwoButton = (Button) findViewById(R.id.bLaunchActivityTwo); mTvCreate = findViewById(R.id.create);
launchActivityTwoButton.setOnClickListener(new OnClickListener() { mTvRestart = findViewById(R.id.restart);
mTvStart = findViewById(R.id.start);
mTvResume = findViewById(R.id.resume);
@Override Button launchActivityTwoButton = findViewById(R.id.bLaunchActivityTwo);
public void onClick(View v) { launchActivityTwoButton.setOnClickListener(new OnClickListener() {
// TODO:
// Launch Activity Two
// Hint: use Context's startActivity() method
// Create an intent stating which Activity you would like to @Override
// start public void onClick(View v) {
Intent intent = null; // TODO:
// Launch Activity Two
// Hint: use Context's startActivity() method
// Launch the Activity using the intent // Create an intent stating which Activity you would like to start
Intent intent = new Intent(ActivityOne.this, ActivityTwo.class);
} // Launch the Activity using the intent
}); startActivity(intent);
// Emit LogCat message using the Log.i method }
});
} // Has previous state been saved?
if (savedInstanceState != null) {
// TODO:
// Restore value of counters from saved state
// Only need 4 lines of code, one for every count variable
mCreate = savedInstanceState.getInt(CREATE_KEY);
mStart = savedInstanceState.getInt(START_KEY);
mResume = savedInstanceState.getInt(RESUME_KEY);
mRestart = savedInstanceState.getInt(RESTART_KEY);
@Override }
public void onStart() {
super.onStart();
// Emit LogCat message using the Log.i method // Emit LogCat message
} Log.i(TAG, "Entered the onCreate() method");
@Override // TODO:
public void onResume() { // Update the appropriate count variable
// Update the user interface via the displayCounts() method
mCreate++;
displayCounts();
}
// Lifecycle callback overrides
@Override
public void onStart() {
super.onStart();
// Emit LogCat message
Log.i(TAG, "Entered the onStart() method");
// TODO:
// Update the appropriate count variable
// Update the user interface
mStart++;
displayCounts();
}
@Override
public void onResume() {
super.onResume(); super.onResume();
// Emit LogCat message using the Log.i method
}
@Override // Emit LogCat message
public void onPause() { Log.i(TAG, "Entered the onResume() method");
// TODO:
// Update the appropriate count variable
// Update the user interface
mResume++;
displayCounts();
}
@Override
public void onPause() {
super.onPause(); super.onPause();
// Emit LogCat message using the Log.i method
}
@Override // Emit LogCat message
public void onStop() { Log.i(TAG, "Entered the onPause() method");
}
@Override
public void onStop() {
super.onStop(); super.onStop();
// Emit LogCat message using the Log.i method
}
@Override // Emit LogCat message
public void onRestart() { Log.i(TAG, "Entered the onStop() method");
}
@Override
public void onRestart() {
super.onRestart(); super.onRestart();
// Emit LogCat message using the Log.i method
} // Emit LogCat message
Log.i(TAG, "Entered the onRestart() method");
// TODO:
// Update the appropriate count variable
// Update the user interface
@Override mRestart++;
public void onDestroy() { displayCounts();
}
@Override
public void onDestroy() {
super.onDestroy(); super.onDestroy();
// Emit LogCat message using the Log.i method
}
@Override // Emit LogCat message
public void onSaveInstanceState(Bundle savedInstanceState) { Log.i(TAG, "Entered the onDestroy() method");
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
// TODO:
// Save state information with a collection of key-value pairs
// 4 lines of code, one for every count variable
savedInstanceState.putInt(CREATE_KEY, mCreate);
savedInstanceState.putInt(START_KEY, mStart);
savedInstanceState.putInt(RESUME_KEY, mResume);
savedInstanceState.putInt(RESTART_KEY, mRestart);
} }
// Updates the displayed counters
private void displayCounts() {
public void displayCounts() { mTvCreate.setText("onCreate() calls: " + mCreate);
mTvStart.setText("onStart() calls: " + mStart);
mTvResume.setText("onResume() calls: " + mResume);
mTvRestart.setText("onRestart() calls: " + mRestart);
} }
} }
...@@ -10,129 +10,178 @@ import android.widget.TextView; ...@@ -10,129 +10,178 @@ import android.widget.TextView;
public class ActivityTwo extends Activity { public class ActivityTwo extends Activity {
// Use these as keys when you're saving state between reconfigurations private static final String RESTART_KEY = "restart";
private static final String RESTART_KEY = "restart"; private static final String RESUME_KEY = "resume";
private static final String RESUME_KEY = "resume"; private static final String START_KEY = "start";
private static final String START_KEY = "start"; private static final String CREATE_KEY = "create";
private static final String CREATE_KEY = "create";
// String for LogCat documentation
private final static String TAG = "Lab-ActivityTwo";
// Lifecycle counters
// TODO:
// Create variables named
// mCreate, mRestart, mStart and mResume
// to count calls to onCreate(), onRestart(), onStart() and
// onResume(). These variables should not be defined as static.
// You will need to increment these variables' values when their
// corresponding lifecycle methods get called.
// TODO: Create variables for each of the TextViews
// named mTvCreate, mTvRestart, mTvStart, mTvResume.
// for displaying the current count of each counter variable
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_two);
// TODO: Assign the appropriate TextViews to the TextView variables
// Hint: Access the TextView by calling Activity's findViewById()
// textView1 = (TextView) findViewById(R.id.textView1);
Button closeButton = (Button) findViewById(R.id.bClose);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO:
// This function closes Activity Two
// Hint: use Context's finish() method
}
});
// Has previous state been saved?
if (savedInstanceState != null) {
// TODO:
// Restore value of counters from saved state
// Only need 4 lines of code, one for every count variable
}
// Emit LogCat message using the Log.i method
}
@Override
public void onStart() {
super.onStart();
// Emit LogCat message using the Log.i method
}
@Override
public void onResume() {
super.onResume();
// Emit LogCat message using the Log.i method
}
@Override
public void onPause() {
super.onPause();
// Emit LogCat message using the Log.i method
}
@Override
public void onStop() {
super.onStop();
// Emit LogCat message using the Log.i method
}
@Override
public void onRestart() {
super.onRestart();
// Emit LogCat message using the Log.i method
}
@Override // String for LogCat documentation
public void onDestroy() { private final static String TAG = "Lab-ActivityTwo";
super.onDestroy();
// Emit LogCat message using the Log.i method
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
// Lifecycle counters
}
// TODO:
// Create counter variables for onCreate(), onRestart(), onStart() and
// onResume()
// You will need to increment these variables' values when their
// corresponding lifecycle methods get called
// specified above private int mCreate = 0;
public void displayCounts() { private int mRestart = 0;
private int mStart = 0;
private int mResume = 0;
// TODO: Create variables for each of the TextViews
} private TextView mTvCreate;
private TextView mTvRestart;
private TextView mTvStart;
private TextView mTvResume;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_two);
// TODO: Assign the appropriate TextViews to the TextView variables
// Hint: Access the TextView by calling Activity's findViewById()
// textView1 = (TextView) findViewById(R.id.textView1);
mTvCreate = findViewById(R.id.create);
mTvRestart = findViewById(R.id.restart);
mTvStart = findViewById(R.id.start);
mTvResume = findViewById(R.id.resume);
Button closeButton = findViewById(R.id.bClose);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO:
// This function closes Activity Two
// Hint: use Context's finish() method
finish();
}
});
// Has previous state been saved?
if (savedInstanceState != null) {
// TODO:
// Restore value of counters from saved state
// Only need 4 lines of code, one for every count variable
mCreate = savedInstanceState.getInt(CREATE_KEY);
mStart = savedInstanceState.getInt(START_KEY);
mResume = savedInstanceState.getInt(RESUME_KEY);
mRestart = savedInstanceState.getInt(RESTART_KEY);
}
// Emit LogCat message
Log.i(TAG, "Entered the onCreate() method");
// TODO:
// Update the appropriate count variable
// Update the user interface via the displayCounts() method
mCreate++;
displayCounts();
}
// Lifecycle callback methods overrides
@Override
public void onStart() {
super.onStart();
// Emit LogCat message
Log.i(TAG, "Entered the onStart() method");
// TODO:
// Update the appropriate count variable
// Update the user interface
mStart++;
displayCounts();
}
@Override
public void onResume() {
super.onResume();
// Emit LogCat message
Log.i(TAG, "Entered the onResume() method");
// TODO:
// Update the appropriate count variable
// Update the user interface
mResume++;
displayCounts();
}
@Override
public void onPause() {
super.onPause();
// Emit LogCat message
Log.i(TAG, "Entered the onPause() method");
}
@Override
public void onStop() {
super.onStop();
// Emit LogCat message
Log.i(TAG, "Entered the onStop() method");
}
@Override
public void onRestart() {
super.onRestart();
// Emit LogCat message
Log.i(TAG, "Entered the onRestart() method");
// TODO:
// Update the appropriate count variable
// Update the user interface
mRestart++;
displayCounts();
}
@Override
public void onDestroy() {
super.onDestroy();
// Emit LogCat message
Log.i(TAG, "Entered the onDestroy() method");
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
// TODO:
// Save counter state information with a collection of key-value pairs
// 4 lines of code, one for every count variable
savedInstanceState.putInt(CREATE_KEY, mCreate);
savedInstanceState.putInt(START_KEY, mStart);
savedInstanceState.putInt(RESUME_KEY, mResume);
savedInstanceState.putInt(RESTART_KEY, mRestart);
}
// Updates the displayed counters
private void displayCounts() {
mTvCreate.setText("onCreate() calls: " + mCreate);
mTvStart.setText("onStart() calls: " + mStart);
mTvResume.setText("onResume() calls: " + mResume);
mTvRestart.setText("onRestart() calls: " + mRestart);
}
} }
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical">
<TextView android:id="@+id/create" <TextView android:id="@+id/create"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical">
<TextView android:id="@+id/create" <TextView android:id="@+id/create"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
\ No newline at end of file
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
\ No newline at end of file
...@@ -4,7 +4,7 @@ buildscript { ...@@ -4,7 +4,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.android.tools.build:gradle:3.0.0-beta4'
} }
} }
......
#Wed Apr 10 15:27:10 PDT 2013 #Fri Sep 08 12:02:35 EDT 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment