Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java

Issue 2472163003: [CustomTabs] Report the navigation start as absolute time (Closed)
Patch Set: Cache tick offset Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
index 5116be5008f885d3accd11eff332125bbb46b912..c7186ef694b9021d31b3a846f4dc74b457b7d892 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
@@ -24,6 +24,7 @@ import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.os.SystemClock;
import android.support.customtabs.CustomTabsCallback;
import android.support.customtabs.CustomTabsClient;
import android.support.customtabs.CustomTabsIntent;
@@ -848,13 +849,23 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase {
@RetryOnFailure
public void testPageLoadMetricIsSent() {
final AtomicReference<Long> firstContentfulPaintMs = new AtomicReference<>(-1L);
+ final AtomicReference<Long> activityStartTimeMs = new AtomicReference<>(-1L);
+
CustomTabsCallback cb = new CustomTabsCallback() {
@Override
public void extraCallback(String callbackName, Bundle args) {
assertEquals(CustomTabsConnection.PAGE_LOAD_METRICS_CALLBACK, callbackName);
- long value = args.getLong(PageLoadMetrics.FIRST_CONTENTFUL_PAINT, -1);
- assertTrue(value > 0);
- firstContentfulPaintMs.set(value);
+
+ long navigationStart = args.getLong(PageLoadMetrics.NAVIGATION_START, -1);
+ long current = SystemClock.uptimeMillis();
+ assertTrue(navigationStart <= current);
+ assertTrue(navigationStart >= activityStartTimeMs.get());
+
+ long firstContentfulPaint =
+ args.getLong(PageLoadMetrics.FIRST_CONTENTFUL_PAINT, -1);
+ assertTrue(firstContentfulPaint > 0);
+ assertTrue(firstContentfulPaint <= (current - navigationStart));
+ firstContentfulPaintMs.set(firstContentfulPaint);
}
};
@@ -866,6 +877,7 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
+ activityStartTimeMs.set(SystemClock.uptimeMillis());
startCustomTabActivityWithIntent(intent);
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override

Powered by Google App Engine
This is Rietveld 408576698