| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.common; | 5 package org.chromium.content.common; |
| 6 | 6 |
| 7 import android.test.InstrumentationTestCase; | 7 import android.test.InstrumentationTestCase; |
| 8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
| 9 | 9 |
| 10 import org.chromium.base.annotations.SuppressFBWarnings; | 10 import org.chromium.base.annotations.SuppressFBWarnings; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 public void setUp() throws Exception { | 44 public void setUp() throws Exception { |
| 45 super.setUp(); | 45 super.setUp(); |
| 46 sObjectCount.set(0); | 46 sObjectCount.set(0); |
| 47 } | 47 } |
| 48 | 48 |
| 49 @SuppressFBWarnings("DM_GC") | 49 @SuppressFBWarnings("DM_GC") |
| 50 private void collectGarbage() { | 50 private void collectGarbage() { |
| 51 // While this is only a 'hint' to the VM, it's generally effective and s
ufficient on | 51 // While this is only a 'hint' to the VM, it's generally effective and s
ufficient on |
| 52 // dalvik. If this changes in future, maybe try allocating a few gargant
uan objects | 52 // dalvik. If this changes in future, maybe try allocating a few gargant
uan objects |
| 53 // too, to force the GC to work. | 53 // too, to force the GC to work. |
| 54 System.gc(); | 54 Runtime.getRuntime().gc(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") | 57 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") |
| 58 @SmallTest | 58 @SmallTest |
| 59 @Feature({"AndroidWebView"}) | 59 @Feature({"AndroidWebView"}) |
| 60 public void testCreateSingle() throws Throwable { | 60 public void testCreateSingle() throws Throwable { |
| 61 assertEquals(0, sObjectCount.get()); | 61 assertEquals(0, sObjectCount.get()); |
| 62 | 62 |
| 63 ReferredObject instance = new ReferredObject(); | 63 ReferredObject instance = new ReferredObject(); |
| 64 assertEquals(1, sObjectCount.get()); | 64 assertEquals(1, sObjectCount.get()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 collectGarbage(); | 98 collectGarbage(); |
| 99 CriteriaHelper.pollInstrumentationThread(Criteria.equals(0, new Callable
<Integer>() { | 99 CriteriaHelper.pollInstrumentationThread(Criteria.equals(0, new Callable
<Integer>() { |
| 100 @Override | 100 @Override |
| 101 public Integer call() { | 101 public Integer call() { |
| 102 return sObjectCount.get(); | 102 return sObjectCount.get(); |
| 103 } | 103 } |
| 104 })); | 104 })); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } | 107 } |
| OLD | NEW |