Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/canonical-gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
pull_request:
branches: [ summer-2020 ]

defaults:
run:
working-directory: android/canonical

jobs:
build:

Expand All @@ -20,8 +24,6 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Switch to canonical project
run: cd android/canonical/
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ GEM
httpclient (2.8.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (2.2.0)
json (2.5.1)
minitest (5.11.3)
molinillo (0.6.6)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.11.0)
ruby-macho (1.4.0)
thread_safe (0.3.6)
tzinfo (1.2.5)
tzinfo (1.2.10)
thread_safe (~> 0.1)

PLATFORMS
Expand Down
14 changes: 14 additions & 0 deletions android/canonical/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
1 change: 1 addition & 0 deletions android/canonical/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
107 changes: 107 additions & 0 deletions android/canonical/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

buildFeatures {
dataBinding true
}

defaultConfig {
applicationId "com.google.samples.quickstart.canonical"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

staging {
initWith(buildTypes.debug) // keep versionName and PIN from 'debug'
defaultConfig.minSdkVersion 18
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

testOptions {
unitTests.returnDefaultValues = true
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "androidx.fragment:fragment-ktx:1.2.5"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.gms:play-services-auth:18.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.libraries.places:places:2.3.0'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'com.google.firebase:firebase-analytics-ktx:17.4.4'
implementation 'com.google.firebase:firebase-auth-ktx:19.3.2'
implementation 'com.google.firebase:firebase-firestore-ktx:21.4.3'

implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'

debugImplementation "androidx.fragment:fragment-testing:1.2.5"

kapt 'com.android.databinding:compiler:3.1.4'

// Core library
androidTestImplementation 'androidx.test:core:1.0.0'

// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'


// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.ext:truth:1.0.0'
androidTestImplementation 'com.google.truth:truth:0.42'

// Espresso dependencies
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'

testImplementation 'junit:junit:4.12'
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation "androidx.test.ext:junit-ktx:1.1.1"
testImplementation "androidx.test:core-ktx:1.2.0"
testImplementation "org.robolectric:robolectric:4.1"




}
48 changes: 48 additions & 0 deletions android/canonical/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"project_info": {
"project_number": "558666181231",
"firebase_url": "https://pivotal-nebula-281103.firebaseio.com",
"project_id": "pivotal-nebula-281103",
"storage_bucket": "pivotal-nebula-281103.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:558666181231:android:ace62cb2b3bd45e4a3fb9a",
"android_client_info": {
"package_name": "com.google.samples.quickstart.canonical"
}
},
"oauth_client": [
{
"client_id": "558666181231-ts5q1e04oha2g1m7km4jonff5s6fe1qk.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.google.samples.quickstart.canonical",
"certificate_hash": "cf9e073a08e94150b32d4c6e5004a5e26a647287"
}
},
{
"client_id": "558666181231-bt85k6hb4mfeuri817m7o2n1m96a3shh.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "THIS IS PRIVATE"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "558666181231-bt85k6hb4mfeuri817m7o2n1m96a3shh.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
21 changes: 21 additions & 0 deletions android/canonical/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.google.samples.quickstart.canonical

import androidx.test.espresso.Espresso.onData
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.ActivityTestRule
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import org.hamcrest.Matchers
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class DatabaseInteractionTest {
@get:Rule
var activityRule: ActivityTestRule<MainActivity>
= ActivityTestRule(MainActivity::class.java)

lateinit var device : UiDevice

@Before
fun setup() {
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
onView(ViewMatchers.withId(R.id.sign_in_button))
.perform(click())
val googleSignInDialog = device.findObject(UiSelector().text("example@gmail.com"))
googleSignInDialog.clickAndWaitForNewWindow()
// Make sure that:
// 1. Your google account must have signed out before test.
// 2. You should have at lest one google account for your device,
// which means, when you click sign in button, you have at least
// one account to choose

// Construct your test database:
// Account: example@gmail.com

}

@Test
fun submitRecord() {
onView(ViewMatchers.withId(R.id.start_pause_btn))
.perform(click())
Thread.sleep(5000)

onView(ViewMatchers.withId(R.id.submit_btn))
.perform(click())
Thread.sleep(2000)
onView(ViewMatchers.withText("Submission Confirm"))
.inRoot(isDialog())
.check(matches(ViewMatchers.isDisplayed()))
onView(ViewMatchers.withText("Confirm"))
.inRoot(isDialog())
.perform(click())
Thread.sleep(1000)

onView(ViewMatchers.withId(R.id.bottom_navigation_item_profile))
.perform(click())

onView(ViewMatchers.withId(R.id.run_history_list_view))
.check(matches(ViewMatchers.isDisplayed()))
onData(Matchers.anything())
.inAdapterView(ViewMatchers.withId(R.id.run_history_list_view))
.atPosition(0)
.onChildView(ViewMatchers.withId(R.id.single_run_time))
.check(matches(ViewMatchers.withText("00:00:05"))) // In your test database, the latest
.perform(click())
}

@After
fun logoutUser() {
onView(ViewMatchers.withId(R.id.bottom_navigation_item_profile))
.perform(click())
onView(ViewMatchers.withId(R.id.logout_button))
.perform(click())
Thread.sleep(1000)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.google.samples.quickstart.canonical

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.google.samples.quickstart.canonical", appContext.packageName)
}
}
Loading