Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.

Commit d10f35f

Browse files
test with mock account info
1 parent 0f1f91a commit d10f35f

File tree

7 files changed

+29
-25
lines changed

7 files changed

+29
-25
lines changed

android/canonical/app/build.gradle

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,6 @@ dependencies {
9494
// Espresso dependencies
9595
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
9696
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
97-
// androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
98-
// androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
99-
// androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.0'
100-
// androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.0'
101-
// androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.0'
102-
103-
// The following Espresso dependency can be either "implementation"
104-
// or "androidTestImplementation", depending on whether you want the
105-
// dependency to appear on your APK's compile classpath or the test APK
106-
// classpath.
107-
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
10897

10998
testImplementation 'junit:junit:4.12'
11099
testImplementation "androidx.arch.core:core-testing:2.1.0"

android/canonical/app/src/androidTest/java/com/google/samples/quickstart/canonical/DatabaseInteractionTest.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.google.samples.quickstart.canonical
33
import androidx.test.espresso.Espresso.onData
44
import androidx.test.espresso.Espresso.onView
55
import androidx.test.espresso.action.ViewActions.click
6-
import androidx.test.espresso.assertion.ViewAssertions
76
import androidx.test.espresso.assertion.ViewAssertions.matches
87
import androidx.test.espresso.matcher.RootMatchers.isDialog
98
import androidx.test.espresso.matcher.ViewMatchers
@@ -14,7 +13,6 @@ import androidx.test.uiautomator.UiDevice
1413
import androidx.test.uiautomator.UiSelector
1514
import org.hamcrest.Matchers
1615
import org.junit.After
17-
import org.junit.Assert.*
1816
import org.junit.Before
1917
import org.junit.Rule
2018
import org.junit.Test
@@ -33,13 +31,17 @@ class DatabaseInteractionTest {
3331
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
3432
onView(ViewMatchers.withId(R.id.sign_in_button))
3533
.perform(click())
36-
val googleSignInDialog = device.findObject(UiSelector().text("yl4324@columbia.edu"))
34+
val googleSignInDialog = device.findObject(UiSelector().text("example@gmail.com"))
3735
googleSignInDialog.clickAndWaitForNewWindow()
3836
// Make sure that:
3937
// 1. Your google account must have signed out before test.
4038
// 2. You should have at lest one google account for your device,
4139
// which means, when you click sign in button, you have at least
4240
// one account to choose
41+
42+
// Construct your test database:
43+
// Account: example@gmail.com
44+
4345
}
4446

4547
@Test
@@ -68,7 +70,7 @@ class DatabaseInteractionTest {
6870
.inAdapterView(ViewMatchers.withId(R.id.run_history_list_view))
6971
.atPosition(0)
7072
.onChildView(ViewMatchers.withId(R.id.single_run_time))
71-
.check(matches(ViewMatchers.withText("00:00:05")))
73+
.check(matches(ViewMatchers.withText("00:00:05"))) // In your test database, the latest
7274
.perform(click())
7375
}
7476

android/canonical/app/src/androidTest/java/com/google/samples/quickstart/canonical/LoginFragmentTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LoginFragmentTest {
3030
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
3131
Espresso.onView(ViewMatchers.withId(R.id.sign_in_button))
3232
.perform(ViewActions.click())
33-
val googleSignInDialog = device.findObject(UiSelector().text("sjtuly1996@gmail.com"))
33+
val googleSignInDialog = device.findObject(UiSelector().text("example@gmail.com"))
3434
googleSignInDialog.clickAndWaitForNewWindow()
3535
// Make sure that:
3636
// 1. Your google account must have signed out before test.
@@ -52,7 +52,7 @@ class LoginFragmentTest {
5252
// Sign in test
5353
Espresso.onView(ViewMatchers.withId(R.id.sign_in_button))
5454
.perform(ViewActions.click())
55-
val googleSignInDialog = device.findObject(UiSelector().text("sjtuly1996@gmail.com"))
55+
val googleSignInDialog = device.findObject(UiSelector().text("example@gmail.com"))
5656
googleSignInDialog.clickAndWaitForNewWindow()
5757
}
5858

@@ -76,7 +76,7 @@ class LoginFragmentTest {
7676
// Sign in
7777
Espresso.onView(ViewMatchers.withId(R.id.sign_in_button))
7878
.perform(ViewActions.click())
79-
val googleSignInDialog = device.findObject(UiSelector().text("sjtuly1996@gmail.com"))
79+
val googleSignInDialog = device.findObject(UiSelector().text("example@gmail.com"))
8080
googleSignInDialog.clickAndWaitForNewWindow()
8181

8282
}

android/canonical/app/src/androidTest/java/com/google/samples/quickstart/canonical/MapsFragmentTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MapsFragmentTest {
3434
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
3535
onView(ViewMatchers.withId(R.id.sign_in_button))
3636
.perform(ViewActions.click())
37-
val googleSignInDialog = device.findObject(UiSelector().text("sjtuly1996@gmail.com"))
37+
val googleSignInDialog = device.findObject(UiSelector().text("example@gmail.com"))
3838
googleSignInDialog.clickAndWaitForNewWindow()
3939
// Make sure that:
4040
// 1. Your google account must have signed out before test.
@@ -46,6 +46,7 @@ class MapsFragmentTest {
4646

4747
@Test
4848
fun searchDestination() {
49+
Thread.sleep(1000)
4950
onView(ViewMatchers.withId(R.id.bottom_navigation_item_map))
5051
.perform(ViewActions.click())
5152
Thread.sleep(3000)

android/canonical/app/src/androidTest/java/com/google/samples/quickstart/canonical/ProfileFragmentTest.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,26 @@ class ProfileFragmentTest {
3030
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
3131
onView(withId(R.id.sign_in_button))
3232
.perform(click())
33-
val googleSignInDialog = device.findObject(UiSelector().text("sjtuly1996@gmail.com"))
33+
val googleSignInDialog = device.findObject(UiSelector().text("exampleForProfileTest@gmail.com"))
3434
googleSignInDialog.clickAndWaitForNewWindow()
3535
Thread.sleep(1000)
3636
// Make sure that:
3737
// 1. Your google account must have signed out before test.
3838
// 2. You should have at lest one google account for your device,
3939
// which means, when you click sign in button, you have at least
4040
// one account to choose
41+
42+
// Account: exampleForProfileTest@gmail.com
43+
// Display name: example user
44+
45+
// Construct your test database:
46+
// User: exampleForProfileTest@gmail.com
47+
// Total running time: 00:05:39
48+
// Total energy consumed: 74
49+
// Latest running history:
50+
// datetime : 2000-01-01 00:00:00
51+
// time : 00:00:02
52+
4153
}
4254

4355
@Test
@@ -47,9 +59,9 @@ class ProfileFragmentTest {
4759
onView(withId(R.id.usr_img))
4860
.check(matches(isDisplayed()))
4961
onView(withId(R.id.usr_name))
50-
.check(matches(withText("Yang Li")))
62+
.check(matches(withText("example user")))
5163
onView(withId(R.id.usr_email))
52-
.check(matches(withText("sjtuly1996@gmail.com")))
64+
.check(matches(withText("exampleForProfileTest@gmail.com")))
5365
}
5466

5567
@Test
@@ -71,7 +83,7 @@ class ProfileFragmentTest {
7183
onData(anything()).inAdapterView(withId(R.id.run_history_list_view))
7284
.atPosition(0)
7385
.onChildView(withId(R.id.single_run_datetime))
74-
.check(matches(withText("2020-08-12 20:11:04")))
86+
.check(matches(withText("2000-01-01 00:00:00")))
7587
.perform(click())
7688
onData(anything()).inAdapterView(withId(R.id.run_history_list_view))
7789
.atPosition(0)

android/canonical/app/src/androidTest/java/com/google/samples/quickstart/canonical/RunFragmentTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class RunFragmentTest {
3434
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
3535
onView(withId(R.id.sign_in_button))
3636
.perform(click())
37-
val googleSignInDialog = device.findObject(UiSelector().text("sjtuly1996@gmail.com"))
37+
val googleSignInDialog = device.findObject(UiSelector().text("example@gmail.com"))
3838
googleSignInDialog.clickAndWaitForNewWindow()
3939
// Make sure that:
4040
// 1. Your google account must have signed out before test.

android/canonical/app/src/main/res/layout/single_run_item.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
android:layout_width="match_parent"
1212
android:layout_height="match_parent"
1313
android:layout_weight="1"
14-
android:layout_margin="10dp"
14+
android:layout_margin="20dp"
1515
android:fontFamily="sans-serif-light"
1616
android:gravity="center"
1717
android:text="2020-08-08 19:51:26"

0 commit comments

Comments
 (0)