Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartStringDoubleClickSelectorTest.java

Issue 121733002: Fix double-clicking in string interpolation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartStringDoubleClickSelectorTest.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartStringDoubleClickSelectorTest.java b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartStringDoubleClickSelectorTest.java
index d83044963d45646128dad3adff07ab0ad46e7345..12b714c019b1a3ff7605c34a34e18d6a83175ee2 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartStringDoubleClickSelectorTest.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartStringDoubleClickSelectorTest.java
@@ -13,24 +13,30 @@
*/
package com.google.dart.tools.ui.internal.text.dart;
-import junit.framework.TestCase;
+import com.google.dart.engine.ast.CompilationUnit;
+import com.google.dart.engine.parser.ParserTestCase;
+import com.google.dart.tools.ui.internal.text.editor.CompilationUnitEditor;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
import org.eclipse.swt.graphics.Point;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-public class DartStringDoubleClickSelectorTest extends TestCase {
+public class DartStringDoubleClickSelectorTest extends ParserTestCase {
private static void assertDoubleClickSelection(String content, String clickPattern,
- String resultContent) {
- ITextViewer textViewer = mock(ITextViewer.class);
+ String resultContent) throws Exception {
+ CompilationUnitEditor.AdaptedSourceViewer textViewer = mock(CompilationUnitEditor.AdaptedSourceViewer.class);
// mock document
IDocument document = new Document(content);
when(textViewer.getDocument()).thenReturn(document);
+ // mock editor
+ CompilationUnitEditor editor = mock(CompilationUnitEditor.class);
+ when(textViewer.getEditor()).thenReturn(editor);
+ CompilationUnit unit = parseCompilationUnit(content);
+ when(editor.getInputUnit()).thenReturn(unit);
// mock double click position
int clickOffset = content.indexOf(clickPattern);
when(textViewer.getSelectedRange()).thenReturn(new Point(clickOffset, 0));
@@ -85,6 +91,21 @@ public class DartStringDoubleClickSelectorTest extends TestCase {
assertDoubleClickSelection(content, clickPattern, resultContent);
}
+ public void test_interpolation() throws Exception {
+ String content = createSource(//
+ "main() {",
+ " String first = 'a';",
+ " String second = 'b';",
+ " String first$second = 'c';",
+ " String s = 'xxx$first$second${first$second.length}yyy';//",
+ " print(s); ",
+ "}");
+ assertDoubleClickSelection(content, "xxx", "xxx$first$second${first$second.length}yyy");
+ assertDoubleClickSelection(content, "xx$", "xxx");
+ assertDoubleClickSelection(content, "yy\'", "yyy");
+ assertDoubleClickSelection(content, "';/", "xxx$first$second${first$second.length}yyy");
+ }
+
public void test_onWord() throws Exception {
String content = "main() { print('aaa bbb'); }";
assertDoubleClickSelection(content, "aa bbb", "aaa");

Powered by Google App Engine
This is Rietveld 408576698