mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
android lint: typography tests
This commit is contained in:
@@ -2,6 +2,7 @@ package org.jetbrains.android.inspections.lint;
|
||||
|
||||
import com.android.tools.lint.checks.TypographyDetector;
|
||||
import com.android.tools.lint.detector.api.Issue;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -42,7 +43,13 @@ class TypographyQuickFix implements AndroidLintQuickFix {
|
||||
final StringBuilder builder = new StringBuilder(value);
|
||||
|
||||
for (TypographyDetector.ReplaceEdit edit : edits) {
|
||||
builder.replace(edit.offset, edit.offset + edit.length, edit.replaceWith);
|
||||
String with = edit.replaceWith;
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
with = with.replace('\u2013', '~').replace('\u2018', '{').replace('\u2019', '}');
|
||||
}
|
||||
|
||||
builder.replace(edit.offset, edit.offset + edit.length, with);
|
||||
}
|
||||
|
||||
final String newValue = builder.toString();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="s">10–20</string>
|
||||
<string name="s">10~20</string>
|
||||
</resources>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">untitled303</string>
|
||||
<string name="app_name1">aba ‘aba’</string>
|
||||
<string name="app_name1">aba {aba}</string>
|
||||
</resources>
|
||||
|
||||
@@ -140,7 +140,7 @@ public class AndroidLintTest extends AndroidTestCase {
|
||||
"/res/layout/layout.xml", "xml");
|
||||
}
|
||||
|
||||
/*public void testTypographyDashes() throws Exception {
|
||||
public void testTypographyDashes() throws Exception {
|
||||
doTestWithFix(new AndroidLintInspectionToolProvider.AndroidLintTypographyDashesInspection(),
|
||||
AndroidBundle.message("android.lint.inspections.replace.with.suggested.characters"),
|
||||
"/res/values/typography.xml", "xml");
|
||||
@@ -150,7 +150,7 @@ public class AndroidLintTest extends AndroidTestCase {
|
||||
doTestWithFix(new AndroidLintInspectionToolProvider.AndroidLintTypographyQuotesInspection(),
|
||||
AndroidBundle.message("android.lint.inspections.replace.with.suggested.characters"),
|
||||
"/res/values/typography.xml", "xml");
|
||||
}*/
|
||||
}
|
||||
|
||||
private void doTestNoFix(@NotNull AndroidLintInspectionBase inspection, @NotNull String copyTo, @NotNull String extension)
|
||||
throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user