| 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.Application; | 9 import android.app.Application; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| 11 import android.content.Intent; | 11 import android.content.Intent; |
| 12 import android.net.Uri; | 12 import android.net.Uri; |
| 13 import android.os.Build; | 13 import android.os.Build; |
| 14 import android.os.Bundle; | 14 import android.os.Bundle; |
| 15 import android.os.Process; | 15 import android.os.Process; |
| 16 import android.support.customtabs.CustomTabsService; | 16 import android.support.customtabs.CustomTabsService; |
| 17 import android.support.customtabs.CustomTabsSessionToken; | 17 import android.support.customtabs.CustomTabsSessionToken; |
| 18 import android.test.InstrumentationTestCase; | 18 import android.test.InstrumentationTestCase; |
| 19 import android.test.suitebuilder.annotation.SmallTest; | 19 import android.test.suitebuilder.annotation.SmallTest; |
| 20 | 20 |
| 21 import org.chromium.base.PathUtils; | 21 import org.chromium.base.PathUtils; |
| 22 import org.chromium.base.ThreadUtils; | 22 import org.chromium.base.ThreadUtils; |
| 23 import org.chromium.base.library_loader.LibraryLoader; | 23 import org.chromium.base.library_loader.LibraryLoader; |
| 24 import org.chromium.base.library_loader.LibraryProcessType; | 24 import org.chromium.base.library_loader.LibraryProcessType; |
| 25 import org.chromium.base.test.util.Restriction; | 25 import org.chromium.base.test.util.Restriction; |
| 26 import org.chromium.base.test.util.RetryOnFailure; |
| 26 import org.chromium.chrome.browser.WarmupManager; | 27 import org.chromium.chrome.browser.WarmupManager; |
| 27 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 28 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 28 import org.chromium.content_public.browser.WebContents; | 29 import org.chromium.content_public.browser.WebContents; |
| 29 | 30 |
| 30 import java.util.ArrayList; | 31 import java.util.ArrayList; |
| 31 import java.util.List; | 32 import java.util.List; |
| 32 import java.util.concurrent.Callable; | 33 import java.util.concurrent.Callable; |
| 33 import java.util.concurrent.FutureTask; | 34 import java.util.concurrent.FutureTask; |
| 34 | 35 |
| 35 /** Tests for CustomTabsConnection. */ | 36 /** Tests for CustomTabsConnection. */ |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 public void run() { | 298 public void run() { |
| 298 assertNull(WarmupManager.getInstance().takeSpareWebContents(fals
e, false)); | 299 assertNull(WarmupManager.getInstance().takeSpareWebContents(fals
e, false)); |
| 299 String referrer = mCustomTabsConnection.getReferrerForSession(to
ken).getUrl(); | 300 String referrer = mCustomTabsConnection.getReferrerForSession(to
ken).getUrl(); |
| 300 assertNotNull(mCustomTabsConnection.takePrerenderedUrl(token, UR
L, referrer)); | 301 assertNotNull(mCustomTabsConnection.takePrerenderedUrl(token, UR
L, referrer)); |
| 301 } | 302 } |
| 302 }); | 303 }); |
| 303 } | 304 } |
| 304 | 305 |
| 305 @SmallTest | 306 @SmallTest |
| 306 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) | 307 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) |
| 308 @RetryOnFailure |
| 307 public void testCanCancelPrerender() { | 309 public void testCanCancelPrerender() { |
| 308 final CustomTabsSessionToken token = assertWarmupAndMayLaunchUrl(null, U
RL, true); | 310 final CustomTabsSessionToken token = assertWarmupAndMayLaunchUrl(null, U
RL, true); |
| 309 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 311 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 310 @Override | 312 @Override |
| 311 public void run() { | 313 public void run() { |
| 312 assertNull(WarmupManager.getInstance().takeSpareWebContents(fals
e, false)); | 314 assertNull(WarmupManager.getInstance().takeSpareWebContents(fals
e, false)); |
| 313 } | 315 } |
| 314 }); | 316 }); |
| 315 assertTrue(mCustomTabsConnection.mayLaunchUrl(token, null, null, null)); | 317 assertTrue(mCustomTabsConnection.mayLaunchUrl(token, null, null, null)); |
| 316 // mayLaunchUrl() posts a task, the following has to run after it. | 318 // mayLaunchUrl() posts a task, the following has to run after it. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } finally { | 570 } finally { |
| 569 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 571 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 570 @Override | 572 @Override |
| 571 public void run() { | 573 public void run() { |
| 572 PrefServiceBridge.getInstance().setNetworkPredictionEnabled(
enabled); | 574 PrefServiceBridge.getInstance().setNetworkPredictionEnabled(
enabled); |
| 573 } | 575 } |
| 574 }); | 576 }); |
| 575 } | 577 } |
| 576 } | 578 } |
| 577 } | 579 } |
| OLD | NEW |