summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWooyoung Cho2013-08-14 09:54:53 (EDT)
committerChris Jaun2013-08-14 14:26:03 (EDT)
commit6b42c40379f95d971dcbeeae506a4e0df1d11cd5 (patch)
tree3e46dfc0393ee53ba4ad0c7a3e327d27d057e1aa
parent0be79f02381b0624466adf446412577cc126361b (diff)
downloadwebtools.jsdt.tests-6b42c40379f95d971dcbeeae506a4e0df1d11cd5.zip
webtools.jsdt.tests-6b42c40379f95d971dcbeeae506a4e0df1d11cd5.tar.gz
webtools.jsdt.tests-6b42c40379f95d971dcbeeae506a4e0df1d11cd5.tar.bz2
Bugzilla 377241. Content Assist does not work when an object property is
referenced by array-style(obj["objfield"].) syntax even though the property name is specified as a constant string. This commit contains only updates to the test cases. A separate commit contains the code changes.
-rw-r--r--tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java1
-rw-r--r--tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/ArrayStylePropertyAccessTests.java111
-rw-r--r--tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241.js6
-rw-r--r--tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_01.js6
-rw-r--r--tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_02.js6
-rw-r--r--tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_03.js3
6 files changed, 133 insertions, 0 deletions
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java
index 6985ea1..22594b5 100644
--- a/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/AllContentAssistTests.java
@@ -91,6 +91,7 @@ public class AllContentAssistTests extends TestSuite {
all.addTest(AddToNavigatorTests.suite());
all.addTest(Dom5LibraryTests.suite());
all.addTest(NestedWithinParenthesesTests.suite());
+ all.addTest(ArrayStylePropertyAccessTests.suite());
// tests that do editing to the files
all.addTest(GlobalFunctionTests_Edited.suite());
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/ArrayStylePropertyAccessTests.java b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/ArrayStylePropertyAccessTests.java
new file mode 100644
index 0000000..3877b0f
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/src/org/eclipse/wst/jsdt/ui/tests/contentassist/ArrayStylePropertyAccessTests.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *
+ *******************************************************************************/
+package org.eclipse.wst.jsdt.ui.tests.contentassist;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.wst.jsdt.ui.tests.utils.TestProjectSetup;
+
+public class ArrayStylePropertyAccessTests extends TestCase {
+ /**
+ * <p>
+ * This tests name
+ * </p>
+ */
+ private static final String TEST_NAME = "Test Array-style Property Access Content Assist";
+
+ /**
+ * <p>
+ * Test project setup for this test.
+ * </p>
+ */
+ private static TestProjectSetup fTestProjectSetup;
+
+ /**
+ * <p>
+ * Default constructor
+ * <p>
+ * <p>
+ * Use {@link #suite()}
+ * </p>
+ *
+ * @see #suite()
+ */
+ public ArrayStylePropertyAccessTests() {
+ super(TEST_NAME);
+ }
+
+ /**
+ * <p>
+ * Constructor that takes a test name.
+ * </p>
+ * <p>
+ * Use {@link #suite()}
+ * </p>
+ *
+ * @param name
+ * The name this test run should have.
+ *
+ * @see #suite()
+ */
+ public ArrayStylePropertyAccessTests(String name) {
+ super(name);
+ }
+
+ /**
+ * <p>
+ * Use this method to add these tests to a larger test suite so set up and
+ * tear down can be performed
+ * </p>
+ *
+ * @return a {@link TestSetup} that will run all of the tests in this
+ * class with set up and tear down.
+ */
+ public static Test suite() {
+ TestSuite ts = new TestSuite(ArrayStylePropertyAccessTests.class, TEST_NAME);
+
+ fTestProjectSetup = new TestProjectSetup(ts, "ContentAssist", "root", false);
+
+ return fTestProjectSetup;
+ }
+
+ public void testPropertyAccessUsingArrayStyle_377241() throws Exception {
+ // When an object property is referenced by array-style, test if
+ // ContentAssist lists are properly show.
+ String[][] expectedProposals = new String[][]{{"id : Number - foo"}};
+ ContentAssistTestUtilities.runProposalTest(fTestProjectSetup, "test377241.js", 5, 10, expectedProposals);
+ }
+
+ public void testPropertyAccessUsingArrayStyle_377241_01() throws Exception {
+ // When an object property is referenced by array-style, test if
+ // ContentAssist lists are properly show.
+ String[][] expectedProposals = new String[][]{{"id : Number - foo"}};
+ ContentAssistTestUtilities.runProposalTest(fTestProjectSetup,"test377241_01.js", 5, 10, expectedProposals);
+ }
+
+ public void testPropertyAccessUsingArrayStyle_377241_02() throws Exception {
+ // When an object property is referenced by array-style, test if
+ // ContentAssist lists are properly show.
+ String[][] expectedProposals = new String[][]{{"id : Number - foo"}};
+ ContentAssistTestUtilities.runProposalTest(fTestProjectSetup,"test377241_02.js", 5, 10, expectedProposals);
+ }
+
+ public void testPropertyAccessUsingArrayStyle_377241_03() throws Exception {
+ // When an object property is referenced by array-style, test if
+ // ContentAssist lists are properly show.
+ String[][] expectedProposals = new String[][]{{"id : Number - {}","data : String - {}"}};
+ ContentAssistTestUtilities.runProposalTest(fTestProjectSetup,"test377241_03.js", 2, 10, expectedProposals);
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241.js
new file mode 100644
index 0000000..771562f
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241.js
@@ -0,0 +1,6 @@
+function foo() {
+ this.id = 0;
+}
+var obj = {p1:new foo()};
+
+obj["p1"].
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_01.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_01.js
new file mode 100644
index 0000000..c1a6fb3
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_01.js
@@ -0,0 +1,6 @@
+function foo() {
+ this.id = 0;
+}
+var obj = {};
+obj.p2 = new foo();
+obj["p2"].
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_02.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_02.js
new file mode 100644
index 0000000..1e57bcd
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_02.js
@@ -0,0 +1,6 @@
+function foo() {
+ this.id = 0;
+}
+var obj = {};
+obj["p3"] = new foo();
+obj["p3"].
diff --git a/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_03.js b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_03.js
new file mode 100644
index 0000000..629d96a
--- /dev/null
+++ b/tests/org.eclipse.wst.jsdt.ui.tests/testresources/ContentAssist/root/test377241_03.js
@@ -0,0 +1,3 @@
+var obj = {};
+obj.p1 = {id:10, data:"empty"};
+obj["p1"].