Skip to content

Commit 9ab121f

Browse files
Fireperf: trigger sendScreenTrace by starting new activity in FirebasePerformanceScreenTracesTest (#3638)
* Attempt to fix e2e tests by starting a new Activity to trigger the end of screen trace instead of backgrounding * make sure pause is called * attempt to fix errors * revert
1 parent dcd2042 commit 9ab121f

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

firebase-perf/e2e-app/src/androidTest/java/com/google/firebase/testing/fireperf/FirebasePerformanceScreenTracesTest.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,12 @@
1717
import static androidx.test.espresso.Espresso.onView;
1818
import static androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition;
1919
import static androidx.test.espresso.matcher.ViewMatchers.withId;
20-
import static com.google.common.truth.Truth.assertThat;
2120

21+
import android.content.Intent;
2222
import androidx.recyclerview.widget.RecyclerView;
2323
import androidx.test.filters.MediumTest;
24-
import androidx.test.platform.app.InstrumentationRegistry;
2524
import androidx.test.rule.ActivityTestRule;
2625
import androidx.test.runner.AndroidJUnit4;
27-
import androidx.test.uiautomator.By;
28-
import androidx.test.uiautomator.UiDevice;
29-
import androidx.test.uiautomator.Until;
30-
import org.junit.After;
3126
import org.junit.Rule;
3227
import org.junit.Test;
3328
import org.junit.runner.RunWith;
@@ -48,16 +43,6 @@ public class FirebasePerformanceScreenTracesTest {
4843
/* initialTouchMode= */ false,
4944
/* launchActivity= */ true);
5045

51-
@After
52-
public void pressHome_toTriggerSendScreenTrace() {
53-
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
54-
boolean success = device.pressHome();
55-
// Wait for launcher
56-
final String launcherPackage = device.getLauncherPackageName();
57-
assertThat(launcherPackage).isNotNull();
58-
device.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);
59-
}
60-
6146
@Test
6247
public void scrollRecyclerViewToEnd() {
6348
RecyclerView recyclerView = activityRule.getActivity().findViewById(R.id.rv_numbers);
@@ -68,5 +53,8 @@ public void scrollRecyclerViewToEnd() {
6853
onView(withId(R.id.rv_numbers)).perform(scrollToPosition(currItemCount));
6954
currItemCount += 5;
7055
}
56+
// End Activity screen trace by switching to another Activity
57+
activityRule.launchActivity(
58+
new Intent(activityRule.getActivity(), FirebasePerfScreenTracesActivity.class));
7159
}
7260
}

0 commit comments

Comments
 (0)