Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 144048 Details for
Bug 217821
[content assist] Code assist BETWEEN 2 different Style rules does not work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
JUnit Patch Updated
defect217821-junit.patch (text/plain), 6.96 KB, created by
Aidyl Kareh
on 2009-08-11 10:23:09 EDT
(
hide
)
Description:
JUnit Patch Updated
Filename:
MIME Type:
Creator:
Aidyl Kareh
Created:
2009-08-11 10:23:09 EDT
Size:
6.96 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.css.ui.tests >Index: src/org/eclipse/wst/css/ui/tests/viewer/TestCSSContentAssist.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/tests/org.eclipse.wst.css.ui.tests/src/org/eclipse/wst/css/ui/tests/viewer/TestCSSContentAssist.java,v >retrieving revision 1.2 >diff -u -r1.2 TestCSSContentAssist.java >--- src/org/eclipse/wst/css/ui/tests/viewer/TestCSSContentAssist.java 3 Aug 2009 14:01:27 -0000 1.2 >+++ src/org/eclipse/wst/css/ui/tests/viewer/TestCSSContentAssist.java 11 Aug 2009 14:22:10 -0000 >@@ -10,7 +10,10 @@ > *******************************************************************************/ > package org.eclipse.wst.css.ui.tests.viewer; > >+import java.io.ByteArrayOutputStream; >+import java.io.FileNotFoundException; > import java.io.IOException; >+import java.io.InputStream; > > import junit.framework.Assert; > import junit.framework.TestCase; >@@ -41,9 +44,11 @@ > > public class TestCSSContentAssist extends TestCase { > >+ private static final String UTF_8 = "UTF-8"; > protected String projectName = null; > protected String fileName = null; > protected String resourcesFolder = null; >+ IProject project = null; > private StructuredTextViewer sourceViewer = null; > protected IStructuredDocument document = null; > private IStructuredModel model; >@@ -55,19 +60,15 @@ > protected void setUp() throws Exception { > > super.setUp(); >- projectName = "CSSContentAssistForMedia"; >- fileName = "mediaexample.css"; >+ projectName = "CSSContentAssist"; > resourcesFolder = "/testresources"; > >- String filePath = setupProject(); >- file = ResourcesPlugin.getWorkspace().getRoot().getFile( >- new Path(filePath)); >- >- if (file != null && !file.exists()) { >- Assert.fail("Unable to locate " + file + "."); >+ if (fileName == null) { >+ fileName = "mediaexample.css"; > } > >- loadFile(); >+ String filePath = setupProject(); >+ loadFile(filePath); > > initializeSourceViewer(); > } >@@ -100,7 +101,13 @@ > sourceViewer.setDocument(document); > } > >- protected void loadFile() throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException { >+ protected void loadFile(String filePath) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException { >+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)); >+ >+ if (file != null && !file.exists()) { >+ Assert.fail("Unable to locate " + file + "."); >+ } >+ > IModelManager modelManager = StructuredModelManager.getModelManager(); > model = modelManager.getModelForEdit(file); > document = model.getStructuredDocument(); >@@ -109,24 +116,51 @@ > protected String setupProject() throws Exception{ > IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(projectName); > >- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); >+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); > try { > project.create(description, new NullProgressMonitor()); > project.open(new NullProgressMonitor()); > } catch (CoreException e) { > > } >- String filePath = project.getFullPath().addTrailingSeparator().append(fileName).toString(); >+ String filePath = getProjectPath(); > > ProjectUtil.copyBundleEntriesIntoWorkspace(resourcesFolder, project.getFullPath().toString()); > > return filePath; > } >+ >+ protected String getProjectPath() >+ { >+ if(project != null) >+ { >+ return project.getFullPath().addTrailingSeparator().append(fileName).toString(); >+ } >+ return null; >+ } > > protected void tearDown() throws Exception { > super.tearDown(); > } > >+ /** >+ * must release model (from edit) after >+ * >+ * @param filename >+ * relative to this class (TestFormatProcessorCSS) >+ */ >+ private IStructuredModel getModelForEdit(final String file) throws IOException { >+ >+ IStructuredModel model = null; >+ IModelManager modelManager = StructuredModelManager.getModelManager(); >+ InputStream inStream = getClass().getResourceAsStream(file); >+ if (inStream == null) >+ throw new FileNotFoundException("Can't file resource stream " + file); >+ final String baseFile = getClass().getResource(file).toString(); >+ model = modelManager.getModelForEdit(baseFile, inStream, null); >+ return model; >+ } >+ > public void testContentAssistInsideMedia() throws Exception { > > try { >@@ -139,4 +173,43 @@ > model.releaseFromEdit(); > } > } >+ >+ public void testContentAssistCompletion() throws Exception { >+ IStructuredModel afterModel = null; >+ try { >+ fileName = "contentAssistCompletion.css"; >+ String filePath = getProjectPath(); >+ loadFile(filePath); >+ initializeSourceViewer(); >+ >+ CSSContentAssistProcessor processor = new CSSContentAssistProcessor(); >+ ICompletionProposal[] proposals = processor >+ .computeCompletionProposals(sourceViewer, 11); >+ assertTrue("No proposals at offset.", proposals.length > 0); >+ ICompletionProposal proposal = proposals[0]; >+ assertEquals("Wrong proposal returned for H1.", "h1", proposal.getDisplayString()); >+ proposal.apply(document); >+ >+ String resultfile = "results/contentAssistCompletion-result.css"; >+ afterModel = getModelForEdit(resultfile); >+ assertNotNull("could not retrieve structured model for : "+ resultfile, afterModel); >+ >+ ByteArrayOutputStream updatedBytes = new ByteArrayOutputStream(); >+ model.save(updatedBytes); >+ >+ ByteArrayOutputStream afterBytes = new ByteArrayOutputStream(); >+ afterModel.save(afterBytes); >+ >+ String updatedContents = new String(updatedBytes.toByteArray(),UTF_8); >+ String expectedContents = new String(afterBytes.toByteArray(), UTF_8); >+ assertTrue("Edited document differs from the expected", updatedContents.equalsIgnoreCase(expectedContents)); >+ >+ } finally { >+ if (model != null) >+ model.releaseFromEdit(); >+ if (afterModel != null) >+ afterModel.releaseFromEdit(); >+ } >+ } >+ > } >Index: testresources/contentAssistCompletion.css >=================================================================== >RCS file: testresources/contentAssistCompletion.css >diff -N testresources/contentAssistCompletion.css >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ testresources/contentAssistCompletion.css 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+H2 { >+ >+} >+ >+H >+ >+H3 { >+ >+} >\ No newline at end of file >Index: src/org/eclipse/wst/css/ui/tests/viewer/results/contentAssistCompletion-result.css >=================================================================== >RCS file: src/org/eclipse/wst/css/ui/tests/viewer/results/contentAssistCompletion-result.css >diff -N src/org/eclipse/wst/css/ui/tests/viewer/results/contentAssistCompletion-result.css >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/css/ui/tests/viewer/results/contentAssistCompletion-result.css 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,11 @@ >+H2 { >+ >+} >+ >+h1 { >+ >+} >+ >+H3 { >+ >+} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 217821
:
143926
|
143927
| 144048