|
Lines 8-13
Link Here
|
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* Brad Reynolds - initial API and implementation |
9 |
* Brad Reynolds - initial API and implementation |
| 10 |
* Matthew Hall - bugs 208858, 221351, 213145 |
10 |
* Matthew Hall - bugs 208858, 221351, 213145 |
|
|
11 |
* Ovidio Mallo - bug 241318 |
| 11 |
******************************************************************************/ |
12 |
******************************************************************************/ |
| 12 |
|
13 |
|
| 13 |
package org.eclipse.core.tests.internal.databinding.observable.masterdetail; |
14 |
package org.eclipse.core.tests.internal.databinding.observable.masterdetail; |
|
Lines 44-58
Link Here
|
| 44 |
public void testElementTypeNull() throws Exception { |
45 |
public void testElementTypeNull() throws Exception { |
| 45 |
WritableValue observableValue = new WritableValue(new WritableList(new ArrayList(), Object.class), null); |
46 |
WritableValue observableValue = new WritableValue(new WritableList(new ArrayList(), Object.class), null); |
| 46 |
|
47 |
|
| 47 |
class Factory implements IObservableFactory { |
48 |
WritableListFactory factory = new WritableListFactory(); |
| 48 |
Object type = Object.class; |
|
|
| 49 |
|
| 50 |
public IObservable createObservable(Object target) { |
| 51 |
return new WritableList(new ArrayList(), type); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
Factory factory = new Factory(); |
| 56 |
DetailObservableList detailObservable = new DetailObservableList( |
49 |
DetailObservableList detailObservable = new DetailObservableList( |
| 57 |
factory, observableValue, null); |
50 |
factory, observableValue, null); |
| 58 |
assertNull(detailObservable.getElementType()); |
51 |
assertNull(detailObservable.getElementType()); |
|
Lines 72-86
Link Here
|
| 72 |
WritableValue observableValue = new WritableValue(new WritableList(new ArrayList(), Object.class), |
65 |
WritableValue observableValue = new WritableValue(new WritableList(new ArrayList(), Object.class), |
| 73 |
null); |
66 |
null); |
| 74 |
|
67 |
|
| 75 |
class Factory implements IObservableFactory { |
68 |
WritableListFactory factory = new WritableListFactory(); |
| 76 |
Object type = Object.class; |
|
|
| 77 |
|
| 78 |
public IObservable createObservable(Object target) { |
| 79 |
return new WritableList(new ArrayList(), type); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
Factory factory = new Factory(); |
| 84 |
DetailObservableList detailObservable = new DetailObservableList(factory, |
69 |
DetailObservableList detailObservable = new DetailObservableList(factory, |
| 85 |
observableValue, Object.class); |
70 |
observableValue, Object.class); |
| 86 |
assertEquals(factory.type, detailObservable.getElementType()); |
71 |
assertEquals(factory.type, detailObservable.getElementType()); |
|
Lines 94-99
Link Here
|
| 94 |
} |
79 |
} |
| 95 |
} |
80 |
} |
| 96 |
|
81 |
|
|
|
82 |
/** |
| 83 |
* Asserts that the master observable value is not disposed upon disposing |
| 84 |
* its detail observable value (bug 241318). |
| 85 |
*/ |
| 86 |
public void testMasterNotDisposedWhenDetailDisposed() { |
| 87 |
class OuterObservable extends WritableValue { |
| 88 |
boolean disposed = false; |
| 89 |
|
| 90 |
public synchronized void dispose() { |
| 91 |
disposed = true; |
| 92 |
super.dispose(); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
OuterObservable outerObservable = new OuterObservable(); |
| 97 |
WritableListFactory factory = new WritableListFactory(); |
| 98 |
DetailObservableList detailObservable = new DetailObservableList( |
| 99 |
factory, outerObservable, null); |
| 100 |
|
| 101 |
assertFalse(outerObservable.disposed); |
| 102 |
|
| 103 |
detailObservable.dispose(); |
| 104 |
assertFalse(outerObservable.disposed); |
| 105 |
} |
| 106 |
|
| 107 |
private static class WritableListFactory implements IObservableFactory { |
| 108 |
Object type = Object.class; |
| 109 |
|
| 110 |
public IObservable createObservable(Object target) { |
| 111 |
return new WritableList(new ArrayList(), type); |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 97 |
public static Test suite() { |
115 |
public static Test suite() { |
| 98 |
TestSuite suite = new TestSuite(DetailObservableListTest.class.getName()); |
116 |
TestSuite suite = new TestSuite(DetailObservableListTest.class.getName()); |
| 99 |
suite.addTestSuite(DetailObservableListTest.class); |
117 |
suite.addTestSuite(DetailObservableListTest.class); |