Adding functional tests for import navigation.
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/formatting/CommentReaderRule.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/formatting/CommentReaderRule.java
index 683122b..37be948 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/formatting/CommentReaderRule.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/formatting/CommentReaderRule.java
@@ -55,7 +55,7 @@
return base;
}
- void parseText(String text) {
+ private void parseText(String text) {
IParseResult parseResult = protobufParser.parseText(text);
rootNode = parseResult.getRootNode();
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter_Test.java
index 9d6c459..a855547 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter_Test.java
@@ -170,11 +170,13 @@
private static class TestModule extends AbstractTestModule {
@Override protected void configure() {
- binder().bind(IIndentationInformation.class).toInstance(new IIndentationInformation() {
- @Override public String getIndentString() {
- return " ";
- }
- });
+ binder().bind(IIndentationInformation.class).toInstance(new IndentationInformationStub());
+ }
+ }
+
+ private static class IndentationInformationStub implements IIndentationInformation {
+ @Override public String getIndentString() {
+ return " ";
}
}
}
diff --git a/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/editor/hyperlinking/ImportHyperlinking_Test.java b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/editor/hyperlinking/ImportHyperlinking_Test.java
new file mode 100644
index 0000000..032d708
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/editor/hyperlinking/ImportHyperlinking_Test.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.editor.hyperlinking;
+
+import static org.eclipse.swtbot.swt.finder.keyboard.Keystrokes.F3;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.junit.*;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.eclipse.protobuf.ui.junit.CommentReaderRule;
+import com.google.eclipse.protobuf.ui.swtbot.ProtobufBot;
+
+/**
+ * Tests for "import" hyperlinking.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class ImportHyperlinking_Test {
+ @Rule public CommentReaderRule commentReader = new CommentReaderRule();
+ @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private static ProtobufBot robot;
+
+ @BeforeClass public static void setUpOnce() throws CoreException {
+ robot = new ProtobufBot();
+ robot.resetAll();
+ robot.createGeneralProject("ImportHyperlinkingTest");
+ }
+
+ // import 'google/protobuf/descriptor.proto';
+ @Test public void should_open_file_in_plugIn() throws InterruptedException {
+ String text = commentReader.comments().get(0);
+ SWTBotEclipseEditor editor = robot.createFileWithText("importDescriptor.proto", text);
+ navigateToImportedFile(editor);
+ robot.editorByTitle("descriptor.proto");
+ }
+
+ private void navigateToImportedFile(SWTBotEclipseEditor editor) {
+ editor.navigateTo(0, 10);
+ editor.pressShortcut(F3);
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/junit/CommentReaderRule.java b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/junit/CommentReaderRule.java
new file mode 100644
index 0000000..262e730
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/junit/CommentReaderRule.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.junit;
+
+import static java.util.Collections.*;
+
+import java.util.List;
+
+import org.junit.rules.MethodRule;
+import org.junit.runners.model.*;
+
+import com.google.eclipse.protobuf.junit.core.CommentReader;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class CommentReaderRule implements MethodRule {
+ private final CommentReader commentReader = new CommentReader();
+
+ private List<String> comments = emptyList();
+
+ @Override public Statement apply(Statement base, FrameworkMethod method, Object target) {
+ comments = unmodifiableList(commentReader.commentsIn(method));
+ return base;
+ }
+
+ public List<String> comments() {
+ return comments;
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/swtbot/ProtobufBot.java b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/swtbot/ProtobufBot.java
index a08685b..6c9532c 100644
--- a/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/swtbot/ProtobufBot.java
+++ b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/swtbot/ProtobufBot.java
@@ -51,6 +51,13 @@
button("Finish").click();
}
+ public SWTBotEclipseEditor createFileWithText(String name, String text) {
+ SWTBotEclipseEditor file = createFile(name);
+ file.setText(text);
+ file.save();
+ return file;
+ }
+
public SWTBotEclipseEditor createFile(String name) {
menu("File").menu("New").menu("File").click();
SWTBotShell shell = shell("New File");