Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaxsun McCarthy Huggan2015-08-06 20:40:45 -0400
committerGerrit Code Review @ Eclipse.org2015-08-27 18:26:45 -0400
commitf0671df11387e9369ad681999f538c848d9f9dbb (patch)
tree1de7dd9822a0ebe68186a9bd8e070399bd4a3ac6 /org.eclipse.mylyn.tasks.ui.tests
parent8197112f0f74635fff4ea6014a17f337bb179548 (diff)
downloadorg.eclipse.mylyn.tasks-f0671df11387e9369ad681999f538c848d9f9dbb.tar.gz
org.eclipse.mylyn.tasks-f0671df11387e9369ad681999f538c848d9f9dbb.tar.xz
org.eclipse.mylyn.tasks-f0671df11387e9369ad681999f538c848d9f9dbb.zip
472556: AbstractRepositorySettingsPage exposes API to set brand
* uses this brand instead of reaching up to the new repository wizard when applying settings to a repository * NewRepositoryWizard sets the brand using this API * when editing a repository uses the repository's brand * updates the page's title when brand is updated Change-Id: I3da8e4276b6ed14445e9ae58f18af45d868f356d Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=472556 Signed-off-by: Jaxsun McCarthy Huggan <jaxsunm@gmail.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui.tests')
-rw-r--r--org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java60
1 files changed, 46 insertions, 14 deletions
diff --git a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java
index 6b416ceea..90cf7fb74 100644
--- a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/tasks/ui/wizards/RepositorySettingsPageTest.java
@@ -25,10 +25,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.jface.wizard.Wizard;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
-import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
-import org.eclipse.mylyn.internal.tasks.ui.wizards.NewRepositoryWizard;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.swt.widgets.Composite;
@@ -116,34 +113,69 @@ public class RepositorySettingsPageTest {
@Test
public void applyToNewRepository() {
- NewRepositoryWizard wizard = mock(NewRepositoryWizard.class);
- when(wizard.getBrand()).thenReturn("org.mylyn");
- AbstractRepositorySettingsPage page = createPage(wizard);
TaskRepository repository = createTaskRepository();
+ repository.removeProperty(ITasksCoreConstants.PROPERTY_BRAND_ID);
+ AbstractRepositorySettingsPage page = createPage(null);
+ assertNull(repository.getProperty(ITasksCoreConstants.PROPERTY_BRAND_ID));
+ page.applyTo(repository);
+ assertNull(repository.getProperty(ITasksCoreConstants.PROPERTY_BRAND_ID));
+
+ page.setBrand("org.mylyn");
page.applyTo(repository);
assertEquals("org.mylyn", repository.getProperty(ITasksCoreConstants.PROPERTY_BRAND_ID));
}
@Test
public void applyToExistingRepository() {
- EditRepositoryWizard wizard = mock(EditRepositoryWizard.class);
- AbstractRepositorySettingsPage page = createPage(wizard);
TaskRepository repository = createTaskRepository();
+ repository.setProperty(ITasksCoreConstants.PROPERTY_BRAND_ID, "existing.brand");
+ AbstractRepositorySettingsPage page = createPage(repository);
+ page.setBrand("org.mylyn");
page.applyTo(repository);
- assertNull(repository.getProperty(ITasksCoreConstants.PROPERTY_BRAND_ID));
+ assertEquals("org.mylyn", repository.getProperty(ITasksCoreConstants.PROPERTY_BRAND_ID));
+ }
- repository.setProperty(ITasksCoreConstants.PROPERTY_BRAND_ID, "org.mylyn");
+ @Test
+ public void applyNullBrandToExistingRepository() {
+ TaskRepository repository = createTaskRepository();
+ repository.setProperty(ITasksCoreConstants.PROPERTY_BRAND_ID, "existing.brand");
+ AbstractRepositorySettingsPage page = createPage(repository);
+
+ page.setBrand(null);
page.applyTo(repository);
- assertEquals("org.mylyn", repository.getProperty(ITasksCoreConstants.PROPERTY_BRAND_ID));
+ assertEquals("existing.brand", repository.getProperty(ITasksCoreConstants.PROPERTY_BRAND_ID));
+ }
+
+ @Test
+ public void setsTitleFromBrand() {
+ AbstractRepositorySettingsPage page = createPage(null);
+ assertEquals("Title", page.getTitle());
+ page.setBrand("org.mylyn");
+ assertEquals("Label for org.mylyn", page.getTitle());
+ }
+
+ @Test
+ public void setsTitleFromBrandedRepository() {
+ TaskRepository repository = createTaskRepository();
+ repository.setProperty(ITasksCoreConstants.PROPERTY_BRAND_ID, "org.mylyn");
+ AbstractRepositorySettingsPage page = createPage(repository);
+ assertEquals("Label for org.mylyn", page.getTitle());
+ }
+
+ @Test
+ public void setsTitleFromUnbrandedRepository() {
+ TaskRepository repository = createTaskRepository();
+ repository.removeProperty(ITasksCoreConstants.PROPERTY_BRAND_ID);
+ AbstractRepositorySettingsPage page = createPage(repository);
+ assertEquals("Title", page.getTitle());
}
- protected AbstractRepositorySettingsPage createPage(Wizard wizard) {
- AbstractRepositorySettingsPage page = spy(new RepositorySettingsPageWithNoCredentials(null));
+ private AbstractRepositorySettingsPage createPage(TaskRepository repository) {
+ AbstractRepositorySettingsPage page = spy(new RepositorySettingsPageWithNoCredentials(repository));
doReturn("label").when(page).getRepositoryLabel();
when(page.needsProxy()).thenReturn(false);
- when(page.getWizard()).thenReturn(wizard);
return page;
}

Back to the top