Search in sources :

Example 6 with Constraints

use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.

the class DefaultActionGroupTest method addTwoBefore.

@Test
public void addTwoBefore() {
    // given
    mockRegisterActions();
    defaultActionGroup.add(firstAction);
    defaultActionGroup.add(secondAction);
    defaultActionGroup.add(thirdAction, new Constraints(BEFORE, "secondAction"));
    defaultActionGroup.add(fourthAction);
    defaultActionGroup.add(fifthAction, new Constraints(BEFORE, "secondAction"));
    defaultActionGroup.add(sixthAction);
    // when
    Action[] result = defaultActionGroup.getChildren(mock(ActionEvent.class));
    //then
    assertThat(Arrays.asList(result)).hasSize(6).containsExactly(firstAction, thirdAction, fifthAction, secondAction, fourthAction, sixthAction);
}
Also used : Constraints(org.eclipse.che.ide.api.constraints.Constraints) Test(org.junit.Test)

Example 7 with Constraints

use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.

the class DefaultActionGroupTest method addComplexAfter.

@Test
public void addComplexAfter() {
    // given
    mockRegisterActions();
    defaultActionGroup.add(firstAction);
    defaultActionGroup.add(secondAction, new Constraints(AFTER, "fifthAction"));
    defaultActionGroup.add(thirdAction);
    defaultActionGroup.add(fourthAction);
    defaultActionGroup.add(fifthAction, new Constraints(AFTER, "firstAction"));
    defaultActionGroup.add(sixthAction);
    // when
    Action[] result = defaultActionGroup.getChildren(mock(ActionEvent.class));
    // then
    assertThat(Arrays.asList(result)).hasSize(6).containsExactly(firstAction, fifthAction, secondAction, thirdAction, fourthAction, sixthAction);
}
Also used : Constraints(org.eclipse.che.ide.api.constraints.Constraints) Test(org.junit.Test)

Example 8 with Constraints

use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.

the class DefaultActionGroupTest method addActionToTheEndWhenConstraintUnsatisfied.

@Test
public void addActionToTheEndWhenConstraintUnsatisfied() {
    // given
    mockRegisterActions();
    defaultActionGroup.add(firstAction);
    defaultActionGroup.add(secondAction, new Constraints(AFTER, "tenthAction"));
    defaultActionGroup.add(thirdAction);
    defaultActionGroup.add(fourthAction);
    defaultActionGroup.add(fifthAction);
    defaultActionGroup.add(sixthAction);
    // when
    Action[] result = defaultActionGroup.getChildren(mock(ActionEvent.class));
    // then
    assertThat(Arrays.asList(result)).hasSize(6).containsExactly(firstAction, thirdAction, fourthAction, fifthAction, sixthAction, secondAction);
}
Also used : Constraints(org.eclipse.che.ide.api.constraints.Constraints) Test(org.junit.Test)

Example 9 with Constraints

use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.

the class DefaultActionGroupTest method addOneAfter.

@Test
public void addOneAfter() {
    // given
    mockRegisterActions();
    defaultActionGroup.add(firstAction);
    defaultActionGroup.add(secondAction);
    defaultActionGroup.add(thirdAction);
    defaultActionGroup.add(fourthAction, new Constraints(AFTER, "firstAction"));
    defaultActionGroup.add(fifthAction);
    defaultActionGroup.add(sixthAction);
    // when
    Action[] result = defaultActionGroup.getChildren(mock(ActionEvent.class));
    //then
    assertThat(Arrays.asList(result)).hasSize(6).containsExactly(firstAction, fourthAction, secondAction, thirdAction, fifthAction, sixthAction);
}
Also used : Constraints(org.eclipse.che.ide.api.constraints.Constraints) Test(org.junit.Test)

Example 10 with Constraints

use of org.eclipse.che.ide.api.constraints.Constraints in project che by eclipse.

the class DefaultActionGroupTest method addOneBeforeNotAdded.

@Test
public void addOneBeforeNotAdded() {
    // given
    mockRegisterActions();
    defaultActionGroup.add(firstAction);
    defaultActionGroup.add(secondAction);
    defaultActionGroup.add(thirdAction, new Constraints(BEFORE, "fifthAction"));
    defaultActionGroup.add(fourthAction);
    defaultActionGroup.add(fifthAction);
    defaultActionGroup.add(sixthAction);
    // when
    Action[] result = defaultActionGroup.getChildren(mock(ActionEvent.class));
    // then
    assertThat(Arrays.asList(result)).hasSize(6).containsExactly(firstAction, secondAction, fourthAction, thirdAction, fifthAction, sixthAction);
}
Also used : Constraints(org.eclipse.che.ide.api.constraints.Constraints) Test(org.junit.Test)

Aggregations

Constraints (org.eclipse.che.ide.api.constraints.Constraints)21 Test (org.junit.Test)12 Inject (com.google.inject.Inject)3 DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 KeyBuilder (org.eclipse.che.ide.api.keybinding.KeyBuilder)2 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 JsonObject (elemental.json.JsonObject)1 Map (java.util.Map)1 Promise (org.eclipse.che.api.promises.client.Promise)1 Anchor (org.eclipse.che.ide.api.constraints.Anchor)1 EditorPartStack (org.eclipse.che.ide.api.parts.EditorPartStack)1