OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.minting; | 5 package org.chromium.minting; |
6 | 6 |
7 import android.content.ComponentName; | 7 import android.content.ComponentName; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.ServiceConnection; | 10 import android.content.ServiceConnection; |
11 import android.os.FileObserver; | 11 import android.os.FileObserver; |
12 import android.os.IBinder; | 12 import android.os.IBinder; |
13 import android.os.RemoteException; | 13 import android.os.RemoteException; |
14 import android.test.InstrumentationTestCase; | 14 import android.test.InstrumentationTestCase; |
15 import android.test.suitebuilder.annotation.MediumTest; | 15 import android.test.suitebuilder.annotation.MediumTest; |
16 | 16 |
17 import dalvik.system.DexFile; | 17 import dalvik.system.DexFile; |
18 | 18 |
19 import org.chromium.base.FileUtils; | 19 import org.chromium.base.FileUtils; |
20 import org.chromium.content.browser.test.util.CallbackHelper; | 20 import org.chromium.content.browser.test.util.CallbackHelper; |
| 21 import org.chromium.minting.lib.common.WebAPKUtils; |
21 import org.chromium.minting.test.dex_optimizer.IDexOptimizerService; | 22 import org.chromium.minting.test.dex_optimizer.IDexOptimizerService; |
22 | 23 |
23 import java.io.File; | 24 import java.io.File; |
24 import java.util.ArrayList; | 25 import java.util.ArrayList; |
25 import java.util.Arrays; | 26 import java.util.Arrays; |
26 | 27 |
27 public class DexLoaderTest extends InstrumentationTestCase { | 28 public class DexLoaderTest extends InstrumentationTestCase { |
28 /** | 29 /** |
29 * Package of APK to load dex file from and package which provides DexOptimi
zerService. | 30 * Package of APK to load dex file from and package which provides DexOptimi
zerService. |
30 */ | 31 */ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 default: | 81 default: |
81 break; | 82 break; |
82 } | 83 } |
83 } | 84 } |
84 } | 85 } |
85 | 86 |
86 @Override | 87 @Override |
87 protected void setUp() { | 88 protected void setUp() { |
88 mContext = getInstrumentation().getTargetContext(); | 89 mContext = getInstrumentation().getTargetContext(); |
89 | 90 |
90 mRemoteContext = DexLoader.getRemoteContext(mContext, DEX_OPTIMIZER_SERV
ICE_PACKAGE); | 91 mRemoteContext = WebAPKUtils.getHostBrowserContext(mContext); |
91 if (mRemoteContext == null) { | 92 if (mRemoteContext == null) { |
92 fail("Failed to get remote context."); | 93 fail("Failed to get remote context."); |
93 } | 94 } |
94 | 95 |
95 mLocalDexDir = mContext.getDir("dex", Context.MODE_PRIVATE); | 96 mLocalDexDir = mContext.getDir("dex", Context.MODE_PRIVATE); |
96 if (mLocalDexDir.exists()) { | 97 if (mLocalDexDir.exists()) { |
97 FileUtils.recursivelyDeleteFile(mLocalDexDir); | 98 FileUtils.recursivelyDeleteFile(mLocalDexDir); |
98 if (mLocalDexDir.exists()) { | 99 if (mLocalDexDir.exists()) { |
99 fail("Could not delete local dex directory."); | 100 fail("Could not delete local dex directory."); |
100 } | 101 } |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 /** Returns whether the ClassLoader can load {@link CANARY_CLASS_NAME} */ | 265 /** Returns whether the ClassLoader can load {@link CANARY_CLASS_NAME} */ |
265 private boolean canLoadCanaryClass(ClassLoader loader) { | 266 private boolean canLoadCanaryClass(ClassLoader loader) { |
266 try { | 267 try { |
267 loader.loadClass(CANARY_CLASS_NAME); | 268 loader.loadClass(CANARY_CLASS_NAME); |
268 return true; | 269 return true; |
269 } catch (Exception e) { | 270 } catch (Exception e) { |
270 return false; | 271 return false; |
271 } | 272 } |
272 } | 273 } |
273 } | 274 } |
OLD | NEW |