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
Branches
No related tags found
No related merge requests found
Showing
with 323 additions and 231 deletions
apply plugin: 'com.android.application'
android {
compileSdkVersion 18
buildToolsVersion "21.1.2"
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "course.labs.activitylab"
minSdkVersion 14
targetSdkVersion 19
minSdkVersion 21
targetSdkVersion 26
testApplicationId "course.labs.activitylab.tests"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
......@@ -22,5 +22,6 @@ android {
}
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 @@
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
......
......@@ -11,108 +11,179 @@ import android.widget.TextView;
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 RESUME_KEY = "resume";
private static final String START_KEY = "start";
private static final String CREATE_KEY = "create";
private static final String RESTART_KEY = "restart";
private static final String RESUME_KEY = "resume";
private static final String START_KEY = "start";
private static final String CREATE_KEY = "create";
// String for LogCat documentation
private final static String TAG = "Lab-ActivityOne";
// String for LogCat documentation
private final static String TAG = "Lab-ActivityOne";
// Lifecycle counters
// 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.
// 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
// You will need to increment these variables' values when their
// corresponding lifecycle methods get called.
private int mCreate = 0;
private int mRestart = 0;
private int mStart = 0;
private int mResume = 0;
// TODO: Create variables for each of the TextViews
// named mTvCreate, mTvRestart, mTvStart, mTvResume.
// for displaying the current count of each counter variable
// 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_one);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_one);
// TODO: Assign the appropriate TextViews to the TextView variables
// Hint: Access the TextView by calling Activity's findViewById()
// textView1 = (TextView) findViewById(R.id.textView1);
// 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 launchActivityTwoButton = (Button) findViewById(R.id.bLaunchActivityTwo);
launchActivityTwoButton.setOnClickListener(new OnClickListener() {
mTvCreate = findViewById(R.id.create);
mTvRestart = findViewById(R.id.restart);
mTvStart = findViewById(R.id.start);
mTvResume = findViewById(R.id.resume);
@Override
public void onClick(View v) {
// TODO:
// Launch Activity Two
// Hint: use Context's startActivity() method
Button launchActivityTwoButton = findViewById(R.id.bLaunchActivityTwo);
launchActivityTwoButton.setOnClickListener(new OnClickListener() {
// Create an intent stating which Activity you would like to
// start
Intent intent = null;
@Override
public void onClick(View v) {
// 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
public void onResume() {
// TODO:
// 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();
// Emit LogCat message using the Log.i method
}
@Override
public void onPause() {
// 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 using the Log.i method
}
@Override
public void onStop() {
// Emit LogCat message
Log.i(TAG, "Entered the onPause() method");
}
@Override
public void onStop() {
super.onStop();
// Emit LogCat message using the Log.i method
}
@Override
public void onRestart() {
// Emit LogCat message
Log.i(TAG, "Entered the onStop() method");
}
@Override
public void 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
public void onDestroy() {
mRestart++;
displayCounts();
}
@Override
public void onDestroy() {
super.onDestroy();
// Emit LogCat message using the Log.i method
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
// Emit LogCat message
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;
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 RESUME_KEY = "resume";
private static final String START_KEY = "start";
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
}
private static final String RESTART_KEY = "restart";
private static final String RESUME_KEY = "resume";
private static final String START_KEY = "start";
private static final String CREATE_KEY = "create";
@Override
public void onDestroy() {
super.onDestroy();
// Emit LogCat message using the Log.i method
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
// String for LogCat documentation
private final static String TAG = "Lab-ActivityTwo";
}
// 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
public void displayCounts() {
private int mCreate = 0;
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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:orientation="vertical">
<TextView android:id="@+id/create"
android:layout_width="wrap_content"
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:orientation="vertical">
<TextView android:id="@+id/create"
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 {
jcenter()
}
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
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
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.
Please register or to comment