use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class NlPalettePanelTest method testCopy.
public void testCopy() throws Exception {
myPanel.requestFocus();
DataContext context = mock(DataContext.class);
CopyProvider provider = (CopyProvider) myPanel.getData(PlatformDataKeys.COPY_PROVIDER.getName());
assertThat(provider).isNotNull();
assertThat(provider.isCopyVisible(context)).isTrue();
assertThat(provider.isCopyEnabled(context)).isTrue();
provider.performCopy(context);
ArgumentCaptor<Transferable> captor = ArgumentCaptor.forClass(Transferable.class);
verify(myCopyPasteManager).setContents(captor.capture());
Transferable transferable = captor.getValue();
assertThat(transferable).isNotNull();
assertThat(transferable.isDataFlavorSupported(ItemTransferable.DESIGNER_FLAVOR)).isTrue();
Object item = transferable.getTransferData(ItemTransferable.DESIGNER_FLAVOR);
assertThat(item).isInstanceOf(DnDTransferItem.class);
DnDTransferItem dndItem = (DnDTransferItem) item;
assertThat(dndItem.getComponents().size()).isEqualTo(1);
DnDTransferComponent component = dndItem.getComponents().get(0);
assertThat(component.getRepresentation()).startsWith(("<TextView"));
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class ProjectsTest method testGetSelectedModules.
public void testGetSelectedModules() {
createAndAddGradleFacet(myModule);
DataContext dataContext = createMock(DataContext.class);
Module[] data = { myModule };
expect(dataContext.getData(LangDataKeys.MODULE_CONTEXT_ARRAY.getName())).andReturn(data);
replay(dataContext);
Module[] selectedModules = Projects.getModulesToBuildFromSelection(myProject, dataContext);
assertSame(data, selectedModules);
verify(dataContext);
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class NlComponentTreeTest method testPasteIsNotPossibleWhenMultipleComponentsAreSelected.
public void testPasteIsNotPossibleWhenMultipleComponentsAreSelected() {
copy(myTextView);
DataContext context = mock(DataContext.class);
myModel.getSelectionModel().toggle(myLinearLayout);
myModel.getSelectionModel().toggle(myAbsoluteLayout);
assertThat(myTree.isPasteEnabled(context)).isTrue();
assertThat(myTree.isPastePossible(context)).isFalse();
myTree.performPaste(context);
assertThat(toTree()).isEqualTo("<RelativeLayout> [expanded]\n" + " <LinearLayout> [expanded] [selected]\n" + " <Button>\n" + " <TextView>\n" + " <AbsoluteLayout> [selected]\n");
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class NlComponentTreeTest method testPasteAfterCut.
public void testPasteAfterCut() {
cut(myTextView);
DataContext context = mock(DataContext.class);
myModel.getSelectionModel().clear();
myModel.getSelectionModel().toggle(myButton);
assertThat(myTree.isPasteEnabled(context)).isTrue();
assertThat(myTree.isPastePossible(context)).isTrue();
myTree.performPaste(context);
assertThat(toTree()).isEqualTo("<RelativeLayout> [expanded]\n" + " <LinearLayout> [expanded]\n" + " <Button> [selected]\n" + " <TextView>\n" + " <AbsoluteLayout>\n");
}
use of com.intellij.openapi.actionSystem.DataContext in project android by JetBrains.
the class NlComponentTreeTest method testCopyIntoRootWhenNothingIsSelected.
public void testCopyIntoRootWhenNothingIsSelected() {
copy(myTextView);
DataContext context = mock(DataContext.class);
assertThat(myTree.isPasteEnabled(context)).isTrue();
assertThat(myTree.isPastePossible(context)).isTrue();
myTree.performPaste(context);
assertThat(toTree()).isEqualTo("<RelativeLayout> [expanded]\n" + " <TextView>\n" + " <LinearLayout> [expanded]\n" + " <Button>\n" + " <TextView>\n" + " <AbsoluteLayout>\n");
}
Aggregations