import com.intellij.testFramework.fixtures.BasePlatformTestCase;
import com.intellij.util.indexing.FileBasedIndex;
import org.intellij.images.util.ImageInfo;
+import org.jetbrains.annotations.NotNull;
import java.io.IOException;
assertEquals(value, getIndexValue(file));
}
+ public void testIndexingSameImages() throws IOException {
+ String text = "<svg width='300' height='300' xmlns='http://www.w3.org/2000/svg'></svg>";
+ VirtualFile file1 = myFixture.addFileToProject("image1.svg", text).getVirtualFile();
+ VirtualFile file2 = myFixture.addFileToProject("image2.svg", text).getVirtualFile();
+
+ assertEquals(getIndexValue(file1), getIndexValue(file2));
+ assertEquals(300, getIndexValue(file1).width);
+ assertEquals(300, getIndexValue(file2).width);
+
+ VfsUtil.saveText(file1, "<svg width='500' height='300' xmlns='http://www.w3.org/2000/svg'></svg>");
+ assertEquals(500, getIndexValue(file1).width);
+ assertEquals(300, getIndexValue(file2).width);
+ }
+
private long getIndexStamp() {
return FileBasedIndex.getInstance().getIndexModificationStamp(ImageInfoIndex.INDEX_ID, myFixture.getProject());
}
- private ImageInfo getIndexValue(VirtualFile file) {
- return FileBasedIndex.getInstance().getFileData(ImageInfoIndex.INDEX_ID, file, myFixture.getProject()).values().iterator().next();
+ private ImageInfo getIndexValue(@NotNull VirtualFile file) {
+ return ImageInfoIndex.getInfo(file, myFixture.getProject());
}
@Override