Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2007-03-28 20:44:44 +0000
committerChris Goldthorpe2007-03-28 20:44:44 +0000
commit6a79441369c996f8fcf44fb942ca08fddc0c64f8 (patch)
tree21dfc4ddb68953030b6b1100f9dd09be356d5560 /org.eclipse.ua.tests/intro/org
parentd3951d8dfc14accafb4cb0b4e2bf036c42fd0767 (diff)
downloadeclipse.platform.ua-6a79441369c996f8fcf44fb942ca08fddc0c64f8.tar.gz
eclipse.platform.ua-6a79441369c996f8fcf44fb942ca08fddc0c64f8.tar.xz
eclipse.platform.ua-6a79441369c996f8fcf44fb942ca08fddc0c64f8.zip
Contribution persistence which is the groundwork for Bug 177635 - [Intro] Show intro and highlight new content if new intro content is available.
Diffstat (limited to 'org.eclipse.ua.tests/intro/org')
-rw-r--r--org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/AllIntroTests.java4
-rw-r--r--org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/contentdetect/ContentDetectorTest.java98
2 files changed, 101 insertions, 1 deletions
diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/AllIntroTests.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/AllIntroTests.java
index 2c88ce166..9e70561f3 100644
--- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/AllIntroTests.java
+++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/AllIntroTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2007 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
@@ -13,6 +13,7 @@ package org.eclipse.ua.tests.intro;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.ua.tests.intro.contentdetect.ContentDetectorTest;
import org.eclipse.ua.tests.intro.parser.AllParserTests;
/*
@@ -32,5 +33,6 @@ public class AllIntroTests extends TestSuite {
*/
public AllIntroTests() {
addTest(AllParserTests.suite());
+ addTestSuite(ContentDetectorTest.class);
}
}
diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/contentdetect/ContentDetectorTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/contentdetect/ContentDetectorTest.java
new file mode 100644
index 000000000..6f1f987e0
--- /dev/null
+++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/contentdetect/ContentDetectorTest.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.ua.tests.intro.contentdetect;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ui.internal.intro.universal.contentdetect.ContentDetectHelper;
+import org.eclipse.ui.internal.intro.universal.contentdetect.ContentDetector;
+
+public class ContentDetectorTest extends TestCase {
+
+ public void testContributorCount() {
+ ContentDetectHelper helper = new ContentDetectHelper();
+ helper.saveExtensionCount(4);
+ assertEquals(4, helper.getExtensionCount());
+ assertEquals(4, helper.getExtensionCount());
+ helper.saveExtensionCount(5);
+ helper.saveExtensionCount(6);
+ assertEquals(6, helper.getExtensionCount());
+ }
+
+ public void testContributorSaveNoNames() {
+ ContentDetectHelper helper = new ContentDetectHelper();
+ helper.saveContributors(new HashSet());
+ assertTrue(helper.getContributors().size() == 0);
+ }
+
+ public void testContributorSaveThreeContributors() {
+ ContentDetectHelper helper = new ContentDetectHelper();
+ HashSet contributors = new HashSet();
+ contributors.add("one");
+ contributors.add("two");
+ contributors.add("three");
+ helper.saveContributors(contributors);
+ List savedContributors = helper.getContributors();
+ assertTrue(savedContributors.size() == 3);
+ assertTrue(savedContributors.contains("one"));
+ assertTrue(savedContributors.contains("two"));
+ assertTrue(savedContributors.contains("three"));
+ }
+
+ public void testForNewContent() {
+ ContentDetectHelper helper = new ContentDetectHelper();
+ HashSet contributors = new HashSet();
+ contributors.add("one");
+ contributors.add("two");
+ contributors.add("three");
+ contributors.add("four");
+ List previous = new ArrayList();
+ previous.add("five");
+ previous.add("two");
+ previous.add("one");
+ String[] newContributors = helper.findNewContributors(contributors, previous);
+ Arrays.sort(newContributors);
+ assertTrue(newContributors.length == 2);
+ assertTrue(newContributors[0] == "four");
+ assertTrue(newContributors[1] == "three");
+ }
+
+ public void testNoSavedState() {
+ ContentDetectHelper helper = new ContentDetectHelper();
+ helper.deleteStateFiles();
+ assertTrue(helper.getContributors().isEmpty());
+ assertEquals(ContentDetectHelper.NO_STATE, helper.getExtensionCount());
+ ContentDetector detector = new ContentDetector();
+ assertFalse(detector.isNewContentAvailable());
+ }
+
+ public void testStateChanges() {
+ ContentDetectHelper helper = new ContentDetectHelper();
+ helper.deleteStateFiles();
+ ContentDetector detector = new ContentDetector();
+ assertFalse(detector.isNewContentAvailable());
+ // Calling the detector should save the state
+ int extensionCount = helper.getExtensionCount();
+ assertTrue(extensionCount > 0);
+ assertEquals(extensionCount, helper.getContributors().size());
+ helper.saveExtensionCount(extensionCount + 1);
+ assertFalse(detector.isNewContentAvailable());
+ helper.saveExtensionCount(extensionCount - 1);
+ assertTrue(detector.isNewContentAvailable());
+ }
+
+}

Back to the top