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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 ReferredObject[] instances = new ReferredObject[instanceCount]; | 84 ReferredObject[] instances = new ReferredObject[instanceCount]; |
85 | 85 |
86 for (int i = 0; i < instanceCount; ++i) { | 86 for (int i = 0; i < instanceCount; ++i) { |
87 instances[i] = new ReferredObject(); | 87 instances[i] = new ReferredObject(); |
88 assertEquals(i + 1, sObjectCount.get()); | 88 assertEquals(i + 1, sObjectCount.get()); |
89 } | 89 } |
90 | 90 |
91 instances = null; | 91 instances = null; |
92 // Ensure compiler / instrumentation does not strip out the assignment. | 92 // Ensure compiler / instrumentation does not strip out the assignment. |
93 assertTrue(instances == null); | 93 assertTrue(instances == null); |
| 94 // Calling sObjectCount.get() before collectGarbage() seems to be requir
ed for the objects |
| 95 // to be GC'ed only when building using GN. |
| 96 assertTrue(sObjectCount.get() != -1); |
94 collectGarbage(); | 97 collectGarbage(); |
95 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | 98 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
96 @Override | 99 @Override |
97 public boolean isSatisfied() { | 100 public boolean isSatisfied() { |
98 return sObjectCount.get() == 0; | 101 return sObjectCount.get() == 0; |
99 } | 102 } |
100 })); | 103 })); |
101 } | 104 } |
102 | 105 |
103 } | 106 } |
OLD | NEW |