1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*******************************************************************************
* Copyright (c) 2008, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.actions;
import java.util.List;
import org.eclipse.equinox.internal.p2.ui.actions.UpdateAction;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
* @since 3.5
*
*/
public class UpdateActionTest extends ProfileModificationActionTest {
class TestUpdateAction extends UpdateAction {
TestUpdateAction(Object[] sel) {
super(UpdateActionTest.this.getProvisioningUI(), UpdateActionTest.this.getSelectionProvider(sel), profile.getProfileId(), true);
}
@Override
public List<IInstallableUnit> getSelectedIUs() {
return super.getSelectedIUs();
}
}
public void testLockedElements() {
TestUpdateAction action = new TestUpdateAction(getTopLevelIUElementsWithLockedIU());
assertFalse("Should not be enabled with locked elements", action.isEnabled());
assertEquals(2, action.getSelectedIUs().size());
}
public void testLockedIUs() {
TestUpdateAction action = new TestUpdateAction(getTopLevelIUsWithLockedIU());
assertFalse("Should not be enabled with locked ius", action.isEnabled());
assertEquals(2, action.getSelectedIUs().size());
}
public void testEmptySelection() {
TestUpdateAction action = new TestUpdateAction(getEmptySelection());
assertFalse("Should not be enabled with empty selection", action.isEnabled());
assertEquals(0, action.getSelectedIUs().size());
}
public void testTopLevelIUs() {
TestUpdateAction action = new TestUpdateAction(getTopLevelIUs());
assertTrue("Should be enabled", action.isEnabled());
assertEquals(2, action.getSelectedIUs().size());
}
public void testTopLevelElements() {
TestUpdateAction action = new TestUpdateAction(getTopLevelIUElements());
assertTrue("Should be enabled", action.isEnabled());
assertEquals(2, action.getSelectedIUs().size());
}
public void testNestedIUs() {
TestUpdateAction action = new TestUpdateAction(getMixedIUs());
assertFalse("Should not enabled", action.isEnabled());
assertEquals(2, action.getSelectedIUs().size());
}
public void testNestedElements() {
TestUpdateAction action = new TestUpdateAction(getMixedIUElements());
assertFalse("Should not enabled", action.isEnabled());
assertEquals(2, action.getSelectedIUs().size());
}
public void testMixedIUsAndNonIUs() {
TestUpdateAction action = new TestUpdateAction(getMixedIUsAndNonIUs());
assertFalse("Should not enabled", action.isEnabled());
assertEquals(2, action.getSelectedIUs().size());
}
public void testMixedIUsAndElements() {
TestUpdateAction action = new TestUpdateAction(getMixedIUsAndElements());
assertTrue("Should be enabled", action.isEnabled());
assertEquals(2, action.getSelectedIUs().size());
}
}
|