Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Jongman2018-03-30 15:58:59 -0400
committerWim Jongman2018-04-03 14:00:49 -0400
commitc6dc63a33eebe03f3d4e3acd88f16a40197eaa4c (patch)
treed242865a8adcf0364d1b97e2fe58db4ab23c2df9 /org.eclipse.tips.tests/src/org/eclipse/tips
parenta2dfce1d07581309804ed8fb64ee6c5c01d1d492 (diff)
downloadeclipse.platform.ua-c6dc63a33eebe03f3d4e3acd88f16a40197eaa4c.tar.gz
eclipse.platform.ua-c6dc63a33eebe03f3d4e3acd88f16a40197eaa4c.tar.xz
eclipse.platform.ua-c6dc63a33eebe03f3d4e3acd88f16a40197eaa4c.zip
Bug 531792: [Tips] API cleanup
* Moved TipManager to internal * Fixed all arising issues * Added save read tips to preferences Change-Id: Id557ab165f63ecabf87460671d1ec8e7ba5de522 Signed-off-by: Wim Jongman <wim.jongman@remainsoftware.com>
Diffstat (limited to 'org.eclipse.tips.tests/src/org/eclipse/tips')
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java3
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java6
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/core/TipProviderTest.java40
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java3
4 files changed, 30 insertions, 22 deletions
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java
index 83e17480b..85c016b27 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java
@@ -15,7 +15,9 @@ import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.tips.core.internal.TipManager;
+@SuppressWarnings("restriction")
public class TestTipManager extends TipManager {
private boolean fShouldRun = true;
@@ -63,6 +65,7 @@ public class TestTipManager extends TipManager {
@Override
public TipManager open(boolean startUp) {
+ setOpen(true);
return this;
}
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java
index a7363f29d..2ef74005e 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.tips.core.internal.LogUtil;
+import org.eclipse.tips.core.internal.TipManager;
import org.junit.Before;
import org.junit.Test;
@@ -32,6 +33,7 @@ public class TipManagerTest {
@Before
public void testTipManager() {
fManager = new TestTipManager();
+ fManager.open(false);
fProvider1 = new TestTipProvider();
fProvider2 = new TestTipProvider();
}
@@ -166,9 +168,9 @@ public class TipManagerTest {
fProvider1.setTips(Arrays.asList(new TestTip(fProvider1.getID(),"<b>bold</b>", "Tip 1"),
new TestTip(fProvider1.getID(),"<b>bold2</b>", "Tip 2")));
fManager.setAsRead(fProvider1.getCurrentTip());
- assertTrue(fProvider1.getTips(true).size() + "", fProvider1.getTips(true).size() == 1);
+ assertTrue(fProvider1.getTips().size() + "", fProvider1.getTips().size() == 1);
fManager.setServeReadTips(true);
- assertTrue(fProvider1.getTips(true).size() == 2);
+ assertTrue(fProvider1.getTips().size() == 2);
}
@Test
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipProviderTest.java b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipProviderTest.java
index 26eba8ee8..983227280 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipProviderTest.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipProviderTest.java
@@ -20,9 +20,11 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
+import org.eclipse.tips.core.internal.TipManager;
import org.junit.Before;
import org.junit.Test;
+@SuppressWarnings("restriction")
public class TipProviderTest {
private TestTipManager fManager;
@@ -31,6 +33,7 @@ public class TipProviderTest {
@Before
public void testTipProvider() {
fManager = new TestTipManager();
+ fManager.open(false);
fProvider = (TestTipProvider) new TestTipProvider().setManager(fManager);
}
@@ -50,7 +53,6 @@ public class TipProviderTest {
assertTrue(fProvider.getID().equals(fProvider.getClass().getName()));
}
-
@Test
public void testGetImage() {
assertTrue(fProvider.getImage() != null);
@@ -58,19 +60,19 @@ public class TipProviderTest {
@Test
public void testGetTips() {
- assertTrue(fProvider.getTips(false).size() == 0);
- createTestDate();
+ assertTrue(fProvider.getTips(null).size() == 0);
+ createTestData();
fManager.setAsRead(fProvider.getNextTip());
- assertTrue(fProvider.getTips(false).size() == 2);
- assertTrue(fProvider.getTips(false).size() == 2);
- assertTrue(fProvider.getTips(true).size() == 1);
+ assertTrue(fProvider.getTips(null).size() == 2);
+ assertTrue(fProvider.getTips(null).size() == 2);
+ assertTrue(fProvider.getTips().size() == 1);
((TipManager) fProvider.getManager()).setServeReadTips(true);
- assertTrue(fProvider.getTips(false).size() == 2);
+ assertTrue(fProvider.getTips(null).size() == 2);
}
- private void createTestDate() {
- fProvider.setTips(Arrays.asList(new TestTip(fProvider.getID(),"<b>bold</b>", "Tip 1"),
- new TestTip(fProvider.getID(),"<b>bold2</b>", "Tip 2")));
+ private void createTestData() {
+ fProvider.setTips(Arrays.asList(new TestTip(fProvider.getID(), "<b>bold</b>", "Tip 1"),
+ new TestTip(fProvider.getID(), "<b>bold2</b>", "Tip 2")));
}
@Test
@@ -85,7 +87,7 @@ public class TipProviderTest {
@Test
public void testGetNextTip() {
- createTestDate();
+ createTestData();
fManager.setAsRead(fProvider.getNextTip());
assertTrue(fProvider.getNextTip().equals(fProvider.getCurrentTip()));
Tip nextTip = fProvider.getNextTip();
@@ -119,7 +121,7 @@ public class TipProviderTest {
@Test
public void testGetPreviousTip4() {
- createTestDate();
+ createTestData();
assertTrue(fProvider.getPreviousTip() != null);
assertTrue(fProvider.getPreviousTip() != null);
assertTrue(fProvider.getPreviousTip() != null);
@@ -159,15 +161,15 @@ public class TipProviderTest {
TestTipProvider p = new TestTipProvider() {
@Override
public IStatus loadNewTips(IProgressMonitor pMonitor) {
- assertTrue(getTips(false).size() == 0);
- assertTrue(setTips(Arrays.asList(new Tip[] { new TestTip(getID(),"DDD", "XXX") })).getTips(false)
+ assertTrue(getTips(null).size() == 0);
+ assertTrue(setTips(Arrays.asList(new Tip[] { new TestTip(getID(), "DDD", "XXX") })).getTips(null)
.size() == 1);
return Status.OK_STATUS;
}
};
- assertTrue(p.getTips(false).size() == 0);
+ assertTrue(p.getTips(null).size() == 0);
fManager.register(p);
- assertTrue(p.getTips(false).size() == 1);
+ assertTrue(p.getTips(null).size() == 1);
}
@Test
@@ -175,10 +177,10 @@ public class TipProviderTest {
TestTipProvider p = new TestTipProvider() {
@Override
public IStatus loadNewTips(IProgressMonitor pMonitor) {
- assertTrue(getTips(false).size() == 0);
- assertTrue(setTips(Arrays.asList(new Tip[] { new TestTip(getID(),"DDD", "XXX") })).getTips(false)
+ assertTrue(getTips(null).size() == 0);
+ assertTrue(setTips(Arrays.asList(new Tip[] { new TestTip(getID(), "DDD", "XXX") })).getTips(null)
.size() == 1);
- assertTrue(addTips(Arrays.asList(new Tip[] { new TestTip(getID(),"DDD", "XXX") })).getTips(false)
+ assertTrue(addTips(Arrays.asList(new Tip[] { new TestTip(getID(), "DDD", "XXX") })).getTips(null)
.size() == 2);
return Status.OK_STATUS;
}
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java b/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
index b3734a962..20fa208c0 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
@@ -21,14 +21,15 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.tips.core.ITipManager;
import org.eclipse.tips.core.JsonTestProvider;
import org.eclipse.tips.core.Tip;
-import org.eclipse.tips.core.TipManager;
import org.eclipse.tips.core.TipProvider;
+import org.eclipse.tips.core.internal.TipManager;
import org.eclipse.tips.ui.internal.TipDialog;
import org.eclipse.tips.ui.internal.util.ResourceManager;
/**
* Class to manage the tip providers and start the tip of the day UI.
*/
+@SuppressWarnings("restriction")
public class SleakTipManager extends TipManager {
private static SleakTipManager instance = new SleakTipManager();

Back to the top