Skip to content

Commit

Permalink
First test working and the first activity created
Browse files Browse the repository at this point in the history
  • Loading branch information
josefadamcik committed Sep 20, 2018
1 parent f8fe196 commit fc4caa1
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 3 deletions.
13 changes: 12 additions & 1 deletion app/build.gradle
Expand Up @@ -21,14 +21,25 @@ android {
}
}

//https://developer.android.com/training/testing/set-up-project
// useLibrary 'android.test.runner'
// useLibrary 'android.test.base'
// useLibrary 'android.test.mock'

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0-rc02'
testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'

}
@@ -0,0 +1,30 @@
package cz.josefadamcik.activityjournal

import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.assertion.ViewAssertions.matches

import android.support.test.espresso.matcher.ViewMatchers.*
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith


@RunWith(AndroidJUnit4::class)
@LargeTest
class MainActivityTest {
@Rule
@JvmField
var activityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)

@Test
fun applicationStart_activityDisplays() {
onView(withId(R.id.fab))
.check(matches(isDisplayed()))
onView(withId(R.id.toolbar))
.check(matches(isDisplayed()))
}

}
17 changes: 15 additions & 2 deletions app/src/main/AndroidManifest.xml
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="cz.josefadamcik.activityjournal"
xmlns:android="http://schemas.android.com/apk/res/android">

Expand All @@ -7,5 +8,17 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"/>
</manifest>
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
22 changes: 22 additions & 0 deletions app/src/main/java/cz/josefadamcik/activityjournal/MainActivity.kt
@@ -0,0 +1,22 @@
package cz.josefadamcik.activityjournal

import android.os.Bundle
import android.support.design.widget.Snackbar
import android.support.v7.app.AppCompatActivity;

import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)

fab.setOnClickListener { view ->
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}
}

}
34 changes: 34 additions & 0 deletions app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email"/>

</android.support.design.widget.CoordinatorLayout>
12 changes: 12 additions & 0 deletions app/src/main/res/layout/content_main.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">

</android.support.constraint.ConstraintLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/dimens.xml
@@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">16dp</dimen>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">ActivityJournal</string>
<string name="title_activity_main">MainActivity</string>
</resources>
9 changes: 9 additions & 0 deletions app/src/main/res/values/styles.xml
Expand Up @@ -8,4 +8,13 @@
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>

</resources>

0 comments on commit fc4caa1

Please sign in to comment.