Package gov.nasa.arc.mct.gui.impl

Examples of gov.nasa.arc.mct.gui.impl.ActionContextImpl


    private ActionContextImpl context;
   
    @BeforeClass
    public void setup() {
        action = new ChangeHousingViewAction();
        context = new ActionContextImpl();
    }
View Full Code Here


        controlArea.canHandle(null);
    }

    @Test (dependsOnMethods = { "testConstructor" })
    public void testNonNullContext() {
        ActionContextImpl context = new ActionContextImpl();
        MCTHousing housing = Mockito.mock(MCTHousing.class);
        context.setTargetHousing(housing);
       
        assertTrue(controlArea.canHandle(context));
        assertTrue(controlArea.isEnabled());
       
        controlArea.actionPerformed(Mockito.mock(ActionEvent.class));
View Full Code Here

                housings.add(housing2);
                return housings;
            }
        };

        ActionContextImpl context = new ActionContextImpl();
        context.setTargetHousing(housing1);
        Assert.assertTrue(action.canHandle(context));
        Assert.assertTrue(action.isEnabled());

        Mockito.doNothing().when(housing2).closeHousing();
        action.actionPerformed(Mockito.mock(ActionEvent.class));
View Full Code Here

            Collection<MCTAbstractHousing> getAllHousings() {
                return Collections.emptyList();
            }
        };

        ActionContextImpl context = new ActionContextImpl();
        context.setTargetHousing(null);
        Assert.assertFalse(action.canHandle(context));
    }
View Full Code Here

                housings.add(housing1);
                return housings;
            }
        };

        ActionContextImpl context = new ActionContextImpl();
        context.setTargetHousing(housing1);
        Assert.assertTrue(action.canHandle(context));
        Assert.assertFalse(action.isEnabled());
    }
View Full Code Here

        // Elaborate mocking to simulate context menu activation
        MCTHousing mockHousing = Mockito.mock(MCTHousing.class);
        MCTContentArea mockContentArea = Mockito.mock(MCTContentArea.class);
        View mockView = Mockito.mock(View.class);
        ActionContextImpl mockContext = Mockito.mock(ActionContextImpl.class);

        Mockito.when(mockContext.getInspectorComponent()).thenReturn(comp);
        Mockito.when(mockContext.getTargetComponent()).thenReturn(comp);
        Mockito.when(mockContext.getTargetHousing()).thenReturn(mockHousing);
        Mockito.when(mockHousing.getContentArea()).thenReturn(mockContentArea);
        Mockito.when(mockContentArea.getHousedViewManifestation()).thenReturn(mockView);
        Mockito.when(mockView.getManifestedComponent()).thenReturn(comp);

        // Generate a new persistence provider each time
View Full Code Here

    public void testSaveAllEnabled(ContextAwareAction action, AbstractComponent comp, boolean shouldHandle, boolean shouldBeEnabled) {
        // Elaborate mocking to simulate context menu activation
        MCTHousing mockHousing = Mockito.mock(MCTHousing.class);
        MCTContentArea mockContentArea = Mockito.mock(MCTContentArea.class);
        View mockView = Mockito.mock(View.class);
        ActionContextImpl mockContext = Mockito.mock(ActionContextImpl.class);
       
        Mockito.when(mockContext.getInspectorComponent()).thenReturn(comp);
        Mockito.when(mockContext.getTargetComponent()).thenReturn(comp);
        Mockito.when(mockContext.getTargetHousing()).thenReturn(mockHousing);
        Mockito.when(mockHousing.getContentArea()).thenReturn(mockContentArea);
        Mockito.when(mockContentArea.getHousedViewManifestation()).thenReturn(mockView);
        Mockito.when(mockView.getManifestedComponent()).thenReturn(comp);
       
        // Verify that enabled/disabled states match expectations
View Full Code Here

    public void testWarningDialog(ContextAwareAction action, AbstractComponent comp, boolean confirm, boolean prompt, final Set<AbstractComponent> expect) {
        // Elaborate mocking to simulate context menu activation
        MCTHousing mockHousing = Mockito.mock(MCTHousing.class);
        MCTContentArea mockContentArea = Mockito.mock(MCTContentArea.class);
        View mockView = Mockito.mock(View.class);
        ActionContextImpl mockContext = Mockito.mock(ActionContextImpl.class);
       
        Mockito.when(mockContext.getInspectorComponent()).thenReturn(comp);
        Mockito.when(mockContext.getTargetComponent()).thenReturn(comp);
        Mockito.when(mockContext.getTargetHousing()).thenReturn(mockHousing);
        Mockito.when(mockHousing.getContentArea()).thenReturn(mockContentArea);
        Mockito.when(mockContentArea.getHousedViewManifestation()).thenReturn(mockView);
        Mockito.when(mockView.getManifestedComponent()).thenReturn(comp);

        // Generate a new persistence provider each time
View Full Code Here

    }
   
    @Test
    public void testCanHandle() throws Exception {
        if (DetectGraphicsDevices.getInstance().getNumberGraphicsDevices() == DetectGraphicsDevices.MINIMUM_MONITOR_CHECK) {
            ActionContextImpl context = new ActionContextImpl();
            context.addTargetViewComponent(viewManifestation1);
            context.addTargetViewComponent(viewManifestation2);
            context.addTargetViewComponent(viewManifestation3);
            Assert.assertTrue(action.canHandle(context));  
            Assert.assertTrue(action.isEnabled());
           
            // Test case 1: successfully returns a new collection
            setResult = true;
View Full Code Here

    // Test that the action cannot be applied to a ModelRole that
    // does not have a parent. Created a new "failAction" for this as
    // "action" is used elsewhere in this test.
    public void testCannotHandle() {
        if (DetectGraphicsDevices.getInstance().getNumberGraphicsDevices() == DetectGraphicsDevices.MINIMUM_MONITOR_CHECK) {
            ActionContextImpl failContext = new ActionContextImpl();
            failContext.addTargetViewComponent(viewManifestation1);
            Assert.assertTrue(failAction.canHandle(failContext));       
            // Add a component with a model role that does not have a parent.
            failContext.addTargetViewComponent(viewManifestationRootComponent);
            // Action cannot now handle this context.
            Assert.assertFalse(failAction.canHandle(failContext));
        }
    }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.gui.impl.ActionContextImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.