| 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.base; | 5 package org.chromium.base; |
| 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.test.util.Feature; | 10 import org.chromium.base.test.util.Feature; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 observerList.addObserver(b); | 241 observerList.addObserver(b); |
| 242 | 242 |
| 243 assertTrue(observerList.removeObserver(a)); | 243 assertTrue(observerList.removeObserver(a)); |
| 244 assertFalse(observerList.removeObserver(a)); | 244 assertFalse(observerList.removeObserver(a)); |
| 245 assertFalse(observerList.removeObserver(new Object())); | 245 assertFalse(observerList.removeObserver(new Object())); |
| 246 assertTrue(observerList.removeObserver(b)); | 246 assertTrue(observerList.removeObserver(b)); |
| 247 assertFalse(observerList.removeObserver(null)); | 247 assertFalse(observerList.removeObserver(null)); |
| 248 | 248 |
| 249 // If we remove an object while iterating, it will be replaced by 'null'
. | 249 // If we remove an object while iterating, it will be replaced by 'null'
. |
| 250 observerList.addObserver(a); | 250 observerList.addObserver(a); |
| 251 Iterator<Object> iterator = observerList.iterator(); | |
| 252 assertTrue(observerList.removeObserver(a)); | 251 assertTrue(observerList.removeObserver(a)); |
| 253 assertFalse(observerList.removeObserver(null)); | 252 assertFalse(observerList.removeObserver(null)); |
| 254 } | 253 } |
| 255 | 254 |
| 256 @SmallTest | 255 @SmallTest |
| 257 @Feature({"Android-AppBase"}) | 256 @Feature({"Android-AppBase"}) |
| 258 public void testSize() { | 257 public void testSize() { |
| 259 ObserverList<Object> observerList = new ObserverList<Object>(); | 258 ObserverList<Object> observerList = new ObserverList<Object>(); |
| 260 | 259 |
| 261 assertEquals(0, observerList.size()); | 260 assertEquals(0, observerList.size()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 assertTrue(observerList.isEmpty()); | 321 assertTrue(observerList.isEmpty()); |
| 323 | 322 |
| 324 observerList.removeObserver(a); | 323 observerList.removeObserver(a); |
| 325 observerList.removeObserver(b); | 324 observerList.removeObserver(b); |
| 326 observerList.removeObserver(null); | 325 observerList.removeObserver(null); |
| 327 observerList.removeObserver(new Object()); | 326 observerList.removeObserver(new Object()); |
| 328 assertEquals(0, observerList.size()); | 327 assertEquals(0, observerList.size()); |
| 329 assertTrue(observerList.isEmpty()); | 328 assertTrue(observerList.isEmpty()); |
| 330 } | 329 } |
| 331 } | 330 } |
| OLD | NEW |