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.hardware_acceleration; | 5 package org.chromium.chrome.browser.hardware_acceleration; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.pm.ActivityInfo; | 8 import android.content.pm.ActivityInfo; |
9 import android.content.pm.PackageInfo; | 9 import android.content.pm.PackageInfo; |
10 import android.content.pm.PackageManager; | 10 import android.content.pm.PackageManager; |
| 11 import android.support.test.InstrumentationRegistry; |
11 import android.support.test.filters.SmallTest; | 12 import android.support.test.filters.SmallTest; |
12 import android.test.InstrumentationTestCase; | 13 |
| 14 import org.junit.Assert; |
| 15 import org.junit.Test; |
| 16 import org.junit.runner.RunWith; |
13 | 17 |
14 import org.chromium.chrome.browser.ChromeActivity; | 18 import org.chromium.chrome.browser.ChromeActivity; |
| 19 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
15 | 20 |
16 /** | 21 /** |
17 * Hardware acceleration-related manifest tests. | 22 * Hardware acceleration-related manifest tests. |
18 */ | 23 */ |
19 public class ManifestHWATest extends InstrumentationTestCase { | 24 @RunWith(ChromeJUnit4ClassRunner.class) |
20 | 25 public class ManifestHWATest { |
| 26 @Test |
21 @SmallTest | 27 @SmallTest |
22 public void testAccelerationDisabled() throws Exception { | 28 public void testAccelerationDisabled() throws Exception { |
23 Context context = getInstrumentation().getTargetContext(); | 29 Context context = InstrumentationRegistry.getInstrumentation().getTarget
Context(); |
24 PackageInfo info = context.getPackageManager().getPackageInfo( | 30 PackageInfo info = context.getPackageManager().getPackageInfo( |
25 context.getApplicationInfo().packageName, | 31 context.getApplicationInfo().packageName, |
26 PackageManager.GET_ACTIVITIES); | 32 PackageManager.GET_ACTIVITIES); |
27 for (ActivityInfo activityInfo : info.activities) { | 33 for (ActivityInfo activityInfo : info.activities) { |
28 String activityName = activityInfo.targetActivity != null | 34 String activityName = activityInfo.targetActivity != null |
29 ? activityInfo.targetActivity | 35 ? activityInfo.targetActivity |
30 : activityInfo.name; | 36 : activityInfo.name; |
31 Class<?> activityClass = Class.forName(activityName); | 37 Class<?> activityClass = Class.forName(activityName); |
32 if (ChromeActivity.class.isAssignableFrom(activityClass)) { | 38 if (ChromeActivity.class.isAssignableFrom(activityClass)) { |
33 // Every activity derived from ChromeActivity must disable hardw
are | 39 // Every activity derived from ChromeActivity must disable hardw
are |
34 // acceleration in the manifest. | 40 // acceleration in the manifest. |
35 assertTrue(0 == (activityInfo.flags & ActivityInfo.FLAG_HARDWARE
_ACCELERATED)); | 41 Assert.assertTrue( |
| 42 0 == (activityInfo.flags & ActivityInfo.FLAG_HARDWARE_AC
CELERATED)); |
36 } | 43 } |
37 } | 44 } |
38 } | 45 } |
39 } | 46 } |
OLD | NEW |