| 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.lib.common.WebApkUtils; |
| 22 import org.chromium.minting.test.dex_optimizer.IDexOptimizerService; | 22 import org.chromium.minting.test.dex_optimizer.IDexOptimizerService; |
| 23 | 23 |
| 24 import java.io.File; | 24 import java.io.File; |
| 25 import java.util.ArrayList; | 25 import java.util.ArrayList; |
| 26 import java.util.Arrays; | 26 import java.util.Arrays; |
| 27 | 27 |
| 28 public class DexLoaderTest extends InstrumentationTestCase { | 28 public class DexLoaderTest extends InstrumentationTestCase { |
| 29 /** | 29 /** |
| 30 * 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. |
| 31 */ | 31 */ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 default: | 81 default: |
| 82 break; | 82 break; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 @Override | 87 @Override |
| 88 protected void setUp() { | 88 protected void setUp() { |
| 89 mContext = getInstrumentation().getTargetContext(); | 89 mContext = getInstrumentation().getTargetContext(); |
| 90 | 90 |
| 91 mRemoteContext = WebAPKUtils.getHostBrowserContext(mContext); | 91 mRemoteContext = WebApkUtils.getHostBrowserContext(mContext); |
| 92 if (mRemoteContext == null) { | 92 if (mRemoteContext == null) { |
| 93 fail("Failed to get remote context."); | 93 fail("Failed to get remote context."); |
| 94 } | 94 } |
| 95 | 95 |
| 96 mLocalDexDir = mContext.getDir("dex", Context.MODE_PRIVATE); | 96 mLocalDexDir = mContext.getDir("dex", Context.MODE_PRIVATE); |
| 97 if (mLocalDexDir.exists()) { | 97 if (mLocalDexDir.exists()) { |
| 98 FileUtils.recursivelyDeleteFile(mLocalDexDir); | 98 FileUtils.recursivelyDeleteFile(mLocalDexDir); |
| 99 if (mLocalDexDir.exists()) { | 99 if (mLocalDexDir.exists()) { |
| 100 fail("Could not delete local dex directory."); | 100 fail("Could not delete local dex directory."); |
| 101 } | 101 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 /** Returns whether the ClassLoader can load {@link CANARY_CLASS_NAME} */ | 309 /** Returns whether the ClassLoader can load {@link CANARY_CLASS_NAME} */ |
| 310 private boolean canLoadCanaryClass(ClassLoader loader) { | 310 private boolean canLoadCanaryClass(ClassLoader loader) { |
| 311 try { | 311 try { |
| 312 loader.loadClass(CANARY_CLASS_NAME); | 312 loader.loadClass(CANARY_CLASS_NAME); |
| 313 return true; | 313 return true; |
| 314 } catch (Exception e) { | 314 } catch (Exception e) { |
| 315 return false; | 315 return false; |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 } | 318 } |
| OLD | NEW |