| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.banners; | 5 package org.chromium.chrome.browser.banners; |
| 6 | 6 |
| 7 import android.content.pm.PackageInfo; | 7 import android.content.pm.PackageInfo; |
| 8 import android.os.HandlerThread; | 8 import android.os.HandlerThread; |
| 9 import android.support.test.filters.SmallTest; | 9 import android.support.test.filters.SmallTest; |
| 10 import android.test.InstrumentationTestCase; | |
| 11 import android.test.mock.MockPackageManager; | 10 import android.test.mock.MockPackageManager; |
| 12 | 11 |
| 12 import junit.framework.TestCase; |
| 13 |
| 13 import org.chromium.base.test.util.RetryOnFailure; | 14 import org.chromium.base.test.util.RetryOnFailure; |
| 14 import org.chromium.content.browser.test.util.Criteria; | 15 import org.chromium.content.browser.test.util.Criteria; |
| 15 import org.chromium.content.browser.test.util.CriteriaHelper; | 16 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * Tests the InstallerDelegate to make sure that it functions correctly and resp
onds to changes | 19 * Tests the InstallerDelegate to make sure that it functions correctly and resp
onds to changes |
| 19 * in the PackageManager. | 20 * in the PackageManager. |
| 20 */ | 21 */ |
| 21 public class InstallerDelegateTest extends InstrumentationTestCase | 22 public class InstallerDelegateTest extends TestCase implements InstallerDelegate
.Observer { |
| 22 implements InstallerDelegate.Observer{ | |
| 23 private static final String MOCK_PACKAGE_NAME = "mock.package.name"; | 23 private static final String MOCK_PACKAGE_NAME = "mock.package.name"; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Returns a mocked set of installed packages. | 26 * Returns a mocked set of installed packages. |
| 27 */ | 27 */ |
| 28 public static class TestPackageManager extends MockPackageManager { | 28 public static class TestPackageManager extends MockPackageManager { |
| 29 public boolean isInstalled = false; | 29 public boolean isInstalled = false; |
| 30 | 30 |
| 31 @Override | 31 @Override |
| 32 public PackageInfo getPackageInfo(String packageName, int flags) | 32 public PackageInfo getPackageInfo(String packageName, int flags) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 */ | 148 */ |
| 149 @SmallTest | 149 @SmallTest |
| 150 @RetryOnFailure | 150 @RetryOnFailure |
| 151 public void testRunnableRaceCondition() { | 151 public void testRunnableRaceCondition() { |
| 152 mPackageManager.isInstalled = true; | 152 mPackageManager.isInstalled = true; |
| 153 mTestDelegate.setTimingForTests(1, 5000); | 153 mTestDelegate.setTimingForTests(1, 5000); |
| 154 startMonitoring(); | 154 startMonitoring(); |
| 155 checkResults(true); | 155 checkResults(true); |
| 156 } | 156 } |
| 157 } | 157 } |
| OLD | NEW |