├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-es
│ │ │ │ └── strings.xml
│ │ │ ├── values-fr
│ │ │ │ └── strings.xml
│ │ │ ├── values
│ │ │ │ ├── styles.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── strings.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_main.xml
│ │ │ │ ├── menu_first.xml
│ │ │ │ ├── menu_localized.xml
│ │ │ │ ├── menu_second.xml
│ │ │ │ └── menu_search_history.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── activity_recycler_view.xml
│ │ │ │ ├── layout_item_post.xml
│ │ │ │ ├── activity_async_task.xml
│ │ │ │ ├── activity_intent_two.xml
│ │ │ │ ├── activity_localized.xml
│ │ │ │ ├── activity_intent_one.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_search_history.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── codepath
│ │ │ │ └── testingdemo
│ │ │ │ ├── activities
│ │ │ │ ├── LocalizedActivity.java
│ │ │ │ ├── IntentTwoActivity.java
│ │ │ │ ├── IntentOneActivity.java
│ │ │ │ ├── RecyclerViewActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── AsyncTaskActivity.java
│ │ │ │ └── SearchHistoryActivity.java
│ │ │ │ ├── models
│ │ │ │ └── Post.java
│ │ │ │ └── adapters
│ │ │ │ └── PostsAdapter.java
│ │ └── AndroidManifest.xml
│ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── codepath
│ │ │ └── testingdemo
│ │ │ └── ApplicationTest.java
│ └── test
│ │ └── java
│ │ └── com.codepath.testingdemo
│ │ ├── models
│ │ ├── PostTestParameterized.java
│ │ └── PostTest.java
│ │ ├── activities
│ │ ├── LocalizedActivityTest.java
│ │ ├── AsyncTaskActivityTest.java
│ │ ├── BaseActivityTest.java
│ │ ├── SearchHistoryActivityTest.java
│ │ └── IntentOneActivityTest.java
│ │ └── adapters
│ │ └── PostsAdapterTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── vcs.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
└── compiler.xml
├── settings.gradle
├── README.md
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── android-testing-demo.iml
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | android-testing-demo
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # android-testing-demo
2 | Starter Code for Android Testing Unit
3 | * 
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-testing-demo/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-testing-demo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-testing-demo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-testing-demo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codepath/android-testing-demo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-es/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hola Mundo!
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hola Mundo!
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_first.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_localized.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_second.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_search_history.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/codepath/testingdemo/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.codepath.testingdemo;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TestingDemo
3 |
4 | Hello world!
5 | Settings
6 | AsyncTask
7 | RecyclerView
8 | SearchHistoryActivity
9 | LocalizedActivity
10 | FirstActivity
11 | SecondActivity
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/testingdemo/activities/LocalizedActivity.java:
--------------------------------------------------------------------------------
1 | package com.codepath.testingdemo.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.codepath.testingdemo.R;
7 |
8 | /*
9 | * Display a TextView with "Hello World!" in the user's native language (as long as that language
10 | * is English, French, or Spanish).
11 | */
12 | public class LocalizedActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_localized);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_item_post.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
16 |
17 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /opt/android_sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_async_task.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_intent_two.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_localized.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/android-testing-demo.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/testingdemo/activities/IntentTwoActivity.java:
--------------------------------------------------------------------------------
1 | package com.codepath.testingdemo.activities;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.widget.TextView;
6 | import android.widget.Toast;
7 |
8 | import com.codepath.testingdemo.R;
9 |
10 | /*
11 | * Take in a "message" as an intent extra. Use the message to set the TextView text.
12 | */
13 | public class IntentTwoActivity extends AppCompatActivity {
14 |
15 | public static final String EXTRA_MESSAGE = "message";
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_intent_two);
21 |
22 | String message = getIntent().getStringExtra(EXTRA_MESSAGE);
23 |
24 | TextView tvMessage = (TextView)findViewById(R.id.tvMessage);
25 | tvMessage.setText(message);
26 |
27 | Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_intent_one.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | useLibrary 'org.apache.http.legacy'
8 |
9 | defaultConfig {
10 | applicationId "com.codepath.testingdemo"
11 | minSdkVersion 16
12 | targetSdkVersion 23
13 | versionCode 1
14 | versionName "1.0"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | compile 'com.android.support:appcompat-v7:23.1.1'
27 | compile 'com.android.support:recyclerview-v7:23.1.1'
28 | compile group: 'com.google.guava', name: 'guava', version: '18.0'
29 | testCompile 'junit:junit:4.12'
30 | testCompile 'org.robolectric:robolectric:3.0'
31 | testCompile('com.squareup.assertj:assertj-android:1.0.0') {
32 | exclude group: 'com.android.support', module: 'support-annotations'
33 | }
34 | testCompile('com.squareup.assertj:assertj-android-recyclerview-v7:1.0.0') {
35 | exclude group: 'com.android.support', module: 'recyclerview-v7'
36 | exclude group: 'com.android.support', module: 'support-annotations'
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/codepath/testingdemo/activities/IntentOneActivity.java:
--------------------------------------------------------------------------------
1 | package com.codepath.testingdemo.activities;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | import com.codepath.testingdemo.R;
11 |
12 | /*
13 | * Take in a "message" as an intent extra. Use the message to set the TextView text.
14 | * Allow user to launch IntentTwoActivity by hitting "Next" button.
15 | */
16 | public class IntentOneActivity extends AppCompatActivity {
17 |
18 | public static final String EXTRA_MESSAGE = "message";
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_intent_one);
24 |
25 | String message = getIntent().getStringExtra(EXTRA_MESSAGE);
26 |
27 | TextView tvMessage = (TextView)findViewById(R.id.tvMessage);
28 | tvMessage.setText(message);
29 |
30 | Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
31 | }
32 |
33 | public void onNextTapped(View view) {
34 | Intent intent = new Intent(this, IntentTwoActivity.class);
35 | intent.putExtra(IntentTwoActivity.EXTRA_MESSAGE, "Second Activity");
36 |
37 | startActivity(intent);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/test/java/com.codepath.testingdemo/models/PostTestParameterized.java:
--------------------------------------------------------------------------------
1 | package com.codepath.testingdemo.models;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.junit.runners.Parameterized;
6 |
7 | import java.util.Arrays;
8 | import java.util.Collection;
9 | import static org.junit.Assert.*;
10 |
11 | @RunWith(Parameterized.class)
12 | public class PostTestParameterized {
13 |
14 | private Post post;
15 | private String expectedResult;
16 |
17 | private static Post postWithLikers(String... userNames) {
18 | Post post = new Post();
19 | post.likers = Arrays.asList(userNames);
20 | return post;
21 | }
22 |
23 | @Parameterized.Parameters( name = "{index}: postWithLikers-{1}" )
24 | public static Collection