OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.customtabs; | 5 package org.chromium.chrome.browser.customtabs; |
6 | 6 |
7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E
ND_DEVICE; | 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E
ND_DEVICE; |
8 | 8 |
9 import android.app.Activity; | 9 import android.app.Activity; |
10 import android.app.Application; | 10 import android.app.Application; |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 assertFalse(navigationEvents.contains(CustomTabsCallback.NAVIGATION_FAIL
ED)); | 820 assertFalse(navigationEvents.contains(CustomTabsCallback.NAVIGATION_FAIL
ED)); |
821 assertFalse(navigationEvents.contains(CustomTabsCallback.NAVIGATION_ABOR
TED)); | 821 assertFalse(navigationEvents.contains(CustomTabsCallback.NAVIGATION_ABOR
TED)); |
822 } | 822 } |
823 | 823 |
824 /** | 824 /** |
825 * Tests that Time To First Contentful Paint is sent. | 825 * Tests that Time To First Contentful Paint is sent. |
826 */ | 826 */ |
827 @SmallTest | 827 @SmallTest |
828 @RetryOnFailure | 828 @RetryOnFailure |
829 public void testPageLoadMetricIsSent() { | 829 public void testPageLoadMetricIsSent() { |
830 Context context = getInstrumentation().getTargetContext().getApplication
Context(); | |
831 CustomTabsConnection connection = CustomTabsConnection.getInstance((Appl
ication) context); | |
832 connection.enablePageLoadMetricsCallbacks(); | |
833 | |
834 final AtomicReference<Long> firstContentfulPaintMs = new AtomicReference
<>(-1L); | 830 final AtomicReference<Long> firstContentfulPaintMs = new AtomicReference
<>(-1L); |
835 CustomTabsCallback cb = new CustomTabsCallback() { | 831 CustomTabsCallback cb = new CustomTabsCallback() { |
836 @Override | 832 @Override |
837 public void extraCallback(String callbackName, Bundle args) { | 833 public void extraCallback(String callbackName, Bundle args) { |
838 assertEquals(CustomTabsConnection.PAGE_LOAD_METRICS_CALLBACK, ca
llbackName); | 834 assertEquals(CustomTabsConnection.PAGE_LOAD_METRICS_CALLBACK, ca
llbackName); |
839 long value = args.getLong(PageLoadMetrics.FIRST_CONTENTFUL_PAINT
, -1); | 835 long value = args.getLong(PageLoadMetrics.FIRST_CONTENTFUL_PAINT
, -1); |
840 assertTrue(value > 0); | 836 assertTrue(value > 0); |
841 firstContentfulPaintMs.set(value); | 837 firstContentfulPaintMs.set(value); |
842 } | 838 } |
843 }; | 839 }; |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 if (jsonText.equalsIgnoreCase("null")) jsonText = ""; | 1550 if (jsonText.equalsIgnoreCase("null")) jsonText = ""; |
1555 value = jsonText; | 1551 value = jsonText; |
1556 } catch (InterruptedException | TimeoutException e) { | 1552 } catch (InterruptedException | TimeoutException e) { |
1557 e.printStackTrace(); | 1553 e.printStackTrace(); |
1558 return false; | 1554 return false; |
1559 } | 1555 } |
1560 return TextUtils.equals(mExpected, value); | 1556 return TextUtils.equals(mExpected, value); |
1561 } | 1557 } |
1562 } | 1558 } |
1563 } | 1559 } |
OLD | NEW |