OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.content.browser.installedapp; | 5 package org.chromium.content.browser.installedapp; |
6 | 6 |
7 import android.content.pm.ApplicationInfo; | 7 import android.content.pm.ApplicationInfo; |
8 import android.content.pm.PackageManager; | 8 import android.content.pm.PackageManager; |
9 import android.content.pm.PackageManager.NameNotFoundException; | 9 import android.content.pm.PackageManager.NameNotFoundException; |
10 import android.content.res.AssetManager; | 10 import android.content.res.AssetManager; |
11 import android.content.res.Resources; | 11 import android.content.res.Resources; |
12 import android.os.Bundle; | 12 import android.os.Bundle; |
13 | 13 |
14 import org.junit.Assert; | 14 import org.junit.Assert; |
15 import org.junit.Before; | 15 import org.junit.Before; |
16 import org.junit.Test; | 16 import org.junit.Test; |
17 import org.junit.runner.RunWith; | 17 import org.junit.runner.RunWith; |
18 | 18 |
19 import org.robolectric.RuntimeEnvironment; | 19 import org.robolectric.RuntimeEnvironment; |
20 import org.robolectric.annotation.Config; | 20 import org.robolectric.annotation.Config; |
21 import org.robolectric.res.builder.DefaultPackageManager; | 21 import org.robolectric.res.builder.DefaultPackageManager; |
22 | 22 |
23 import org.chromium.base.test.util.Feature; | 23 import org.chromium.base.test.util.Feature; |
24 import org.chromium.installedapp.mojom.InstalledAppProvider; | 24 import org.chromium.installedapp.mojom.InstalledAppProvider; |
25 import org.chromium.installedapp.mojom.RelatedApplication; | 25 import org.chromium.installedapp.mojom.RelatedApplication; |
| 26 import org.chromium.testing.local.CustomShadowAsyncTask; |
26 import org.chromium.testing.local.LocalRobolectricTestRunner; | 27 import org.chromium.testing.local.LocalRobolectricTestRunner; |
27 | 28 |
28 import java.net.URI; | 29 import java.net.URI; |
29 import java.net.URISyntaxException; | 30 import java.net.URISyntaxException; |
30 import java.util.HashMap; | 31 import java.util.HashMap; |
31 | 32 |
32 /** | 33 /** |
33 * Ensure that the InstalledAppProvider returns the correct apps. | 34 * Ensure that the InstalledAppProvider returns the correct apps. |
34 */ | 35 */ |
35 @RunWith(LocalRobolectricTestRunner.class) | 36 @RunWith(LocalRobolectricTestRunner.class) |
36 @Config(manifest = Config.NONE) | 37 @Config(manifest = Config.NONE, shadows = {CustomShadowAsyncTask.class}) |
37 public class InstalledAppProviderTest { | 38 public class InstalledAppProviderTest { |
38 private static final String ASSET_STATEMENTS_KEY = | 39 private static final String ASSET_STATEMENTS_KEY = |
39 InstalledAppProviderImpl.ASSET_STATEMENTS_KEY; | 40 InstalledAppProviderImpl.ASSET_STATEMENTS_KEY; |
40 private static final String RELATION_HANDLE_ALL_URLS = | 41 private static final String RELATION_HANDLE_ALL_URLS = |
41 "delegate_permission/common.handle_all_urls"; | 42 "delegate_permission/common.handle_all_urls"; |
42 private static final String NAMESPACE_WEB = | 43 private static final String NAMESPACE_WEB = |
43 InstalledAppProviderImpl.ASSET_STATEMENT_NAMESPACE_WEB; | 44 InstalledAppProviderImpl.ASSET_STATEMENT_NAMESPACE_WEB; |
44 private static final String PLATFORM_ANDROID = | 45 private static final String PLATFORM_ANDROID = |
45 InstalledAppProviderImpl.RELATED_APP_PLATFORM_ANDROID; | 46 InstalledAppProviderImpl.RELATED_APP_PLATFORM_ANDROID; |
46 private static final String PLATFORM_OTHER = "itunes"; | 47 private static final String PLATFORM_OTHER = "itunes"; |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 createRelatedApplication(PLATFORM_ANDROID, PACKAGE_NAME_3, null)
}; | 784 createRelatedApplication(PLATFORM_ANDROID, PACKAGE_NAME_3, null)
}; |
784 | 785 |
785 setAssetStatement(PACKAGE_NAME_2, NAMESPACE_WEB, RELATION_HANDLE_ALL_URL
S, ORIGIN); | 786 setAssetStatement(PACKAGE_NAME_2, NAMESPACE_WEB, RELATION_HANDLE_ALL_URL
S, ORIGIN); |
786 setAssetStatement(PACKAGE_NAME_3, NAMESPACE_WEB, RELATION_HANDLE_ALL_URL
S, ORIGIN); | 787 setAssetStatement(PACKAGE_NAME_3, NAMESPACE_WEB, RELATION_HANDLE_ALL_URL
S, ORIGIN); |
787 | 788 |
788 RelatedApplication[] expectedInstalledRelatedApps = | 789 RelatedApplication[] expectedInstalledRelatedApps = |
789 new RelatedApplication[] {manifestRelatedApps[1], manifestRelate
dApps[3]}; | 790 new RelatedApplication[] {manifestRelatedApps[1], manifestRelate
dApps[3]}; |
790 verifyInstalledApps(manifestRelatedApps, expectedInstalledRelatedApps); | 791 verifyInstalledApps(manifestRelatedApps, expectedInstalledRelatedApps); |
791 } | 792 } |
792 } | 793 } |
OLD | NEW |