summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Kaspar2013-12-02 02:42:47 (EST)
committerDoug Schaefer2013-12-03 08:58:10 (EST)
commitdc746352a32ab1b18732db3922d406bcb5170336 (patch)
tree356f8ace4e37677a0f942264104cbb34fa180190
parenteb3b78ec86a861f72c6086bbbcf2e39fec19a2f2 (diff)
downloadorg.eclipse.cdt-dc746352a32ab1b18732db3922d406bcb5170336.zip
org.eclipse.cdt-dc746352a32ab1b18732db3922d406bcb5170336.tar.gz
org.eclipse.cdt-dc746352a32ab1b18732db3922d406bcb5170336.tar.bz2
Bug 422797 - API for retrieving QMake information from Qt projectrefs/changes/45/19145/4
Adding ...cdt.qt.tests/SimpleTests JUnit tests Change-Id: I68d8e56d6b81a65eb1b6823cf7f1df63f00c1a15 Signed-off-by: David Kaspar <dkaspar@blackberry.com> Reviewed-on: https://git.eclipse.org/r/19145 Tested-by: Hudson CI Reviewed-by: Doug Schaefer <dschaefer@qnx.com> IP-Clean: Doug Schaefer <dschaefer@qnx.com>
-rw-r--r--qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF3
-rw-r--r--qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/AllQtTests.java1
-rw-r--r--qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/SimpleTests.java67
3 files changed, 70 insertions, 1 deletions
diff --git a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
index bb85c8e..0d10edd 100644
--- a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
+++ b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
@@ -13,4 +13,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.qt.core,
- org.eclipse.cdt.qt.core.index
+ org.eclipse.cdt.qt.core.index,
+ org.eclipse.cdt.internal.qt.core.index;x-friends:="org.eclipse.cdt.qt.tests"
diff --git a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/AllQtTests.java b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/AllQtTests.java
index a062abd..55a6c6f 100644
--- a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/AllQtTests.java
+++ b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/AllQtTests.java
@@ -15,6 +15,7 @@ public class AllQtTests extends TestSuite {
public static Test suite() throws Exception {
return
new TestSuite(
+ SimpleTests.class,
QObjectTests.class,
QtIndexTests.class);
}
diff --git a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/SimpleTests.java b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/SimpleTests.java
new file mode 100644
index 0000000..f3784f0
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/SimpleTests.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013 QNX Software Systems and others.
+ * 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 org.eclipse.cdt.qt.tests;
+
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.cdt.internal.qt.core.index.QMakeInfo;
+import org.eclipse.cdt.internal.qt.core.index.QMakeParser;
+import org.eclipse.cdt.internal.qt.core.index.QMakeVersion;
+
+public class SimpleTests extends TestCase {
+
+ public void testQMakeVersion() throws Exception {
+ // Make sure null is returned for invalid version strings.
+ assertNull(QMakeVersion.create(null));
+ assertNull(QMakeVersion.create(""));
+ assertNull(QMakeVersion.create("30"));
+ assertNull(QMakeVersion.create("2.a"));
+
+ // Check an expected value, avoid 0 to confirm that all digits are propertly parsed.
+ QMakeVersion two_dot_one = QMakeVersion.create("2.1");
+ assertNotNull(two_dot_one);
+ assertEquals(2, two_dot_one.getMajor());
+ assertEquals(1, two_dot_one.getMinor());
+
+ // Check the common expected value, make sure leading/trailing whitespace is ignored
+ QMakeVersion three_dot_zero = QMakeVersion.create(" 3.0 ");
+ assertNotNull(three_dot_zero);
+ assertEquals(3, three_dot_zero.getMajor());
+ assertEquals(0, three_dot_zero.getMinor());
+ }
+
+ public void testQMakeInfo() throws Exception {
+ StringReader content = new StringReader("A = \\\\\\\"\nB = A\\n\\tB\nC = \"A \\\" B\" \"A \\\" B\"");
+ BufferedReader reader = new BufferedReader(content);
+
+ Map<String, String> result = QMakeParser.parse(QMakeInfo.PATTERN_EVAL_LINE, reader);
+ String A = QMakeParser.qmake3DecodeValue(result.get("A"));
+ assertNotNull(A);
+ assertEquals("\\\"", A);
+
+ String B = QMakeParser.qmake3DecodeValue(result.get("B"));
+ assertNotNull(B);
+ assertEquals("A\n\tB", B);
+
+ List<String> C = QMakeParser.qmake3DecodeValueList(result, "C");
+ assertNotNull(C);
+ assertEquals(2, C.size());
+ assertEquals("A \" B", C.get(0));
+ assertEquals("A \" B", C.get(1));
+
+ List<String> D = QMakeParser.qmake3DecodeValueList(result, "D");
+ assertNotNull(D);
+ assertEquals(0, D.size());
+ }
+
+}