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 android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.Instrumentation; | 8 import android.app.Instrumentation; |
| 9 import android.content.ComponentName; |
9 import android.content.Intent; | 10 import android.content.Intent; |
| 11 import android.net.Uri; |
| 12 import android.support.customtabs.CustomTabsIntent; |
10 | 13 |
11 import org.chromium.chrome.browser.DeferredStartupHandler; | 14 import org.chromium.chrome.browser.DeferredStartupHandler; |
| 15 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
12 import org.chromium.chrome.browser.tab.Tab; | 16 import org.chromium.chrome.browser.tab.Tab; |
| 17 import org.chromium.chrome.browser.util.IntentUtils; |
13 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 18 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
14 import org.chromium.content.browser.test.util.Criteria; | 19 import org.chromium.content.browser.test.util.Criteria; |
15 import org.chromium.content.browser.test.util.CriteriaHelper; | 20 import org.chromium.content.browser.test.util.CriteriaHelper; |
16 | 21 |
17 /** | 22 /** |
18 * Base class for all instrumentation tests that require a {@link CustomTabActiv
ity}. | 23 * Base class for all instrumentation tests that require a {@link CustomTabActiv
ity}. |
19 */ | 24 */ |
20 public abstract class CustomTabActivityTestBase extends | 25 public abstract class CustomTabActivityTestBase extends |
21 ChromeActivityTestCaseBase<CustomTabActivity> { | 26 ChromeActivityTestCaseBase<CustomTabActivity> { |
22 | 27 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 60 } |
56 })); | 61 })); |
57 Tab tab = getActivity().getActivityTab(); | 62 Tab tab = getActivity().getActivityTab(); |
58 | 63 |
59 assertTrue("Deferred startup never completed", | 64 assertTrue("Deferred startup never completed", |
60 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { | 65 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
61 @Override | 66 @Override |
62 public boolean isSatisfied() { | 67 public boolean isSatisfied() { |
63 return DeferredStartupHandler.getInstance().isDeferredSt
artupComplete(); | 68 return DeferredStartupHandler.getInstance().isDeferredSt
artupComplete(); |
64 } | 69 } |
65 }, 5000, 200)); | 70 })); |
66 | 71 |
67 assertNotNull(tab); | 72 assertNotNull(tab); |
68 assertNotNull(tab.getView()); | 73 assertNotNull(tab.getView()); |
69 } | 74 } |
| 75 |
| 76 /** |
| 77 * Creates the simplest intent that is sufficient to let {@link ChromeLaunch
erActivity} launch |
| 78 * the {@link CustomTabActivity}. |
| 79 */ |
| 80 protected Intent createMinimalCustomTabIntent(String url) { |
| 81 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| 82 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 83 intent.setComponent(new ComponentName(getInstrumentation().getTargetCont
ext(), |
| 84 ChromeLauncherActivity.class)); |
| 85 IntentUtils.safePutBinderExtra(intent, CustomTabsIntent.EXTRA_SESSION, n
ull); |
| 86 return intent; |
| 87 } |
70 } | 88 } |
OLD | NEW |