Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Kennedy2016-02-12 14:16:03 -0500
committerGerrit Code Review @ Eclipse.org2016-02-16 18:07:21 -0500
commit37236c56a7c204d4f34fab2be5b1f307d1af6e4b (patch)
treeb38a7012858f629a7ee2e29fb235b2e1087e0496 /org.eclipse.mylyn.tasks.ui.tests
parentcc6f1b4b44f00e696f7f5aaecbedab9cd6baa869 (diff)
downloadorg.eclipse.mylyn.tasks-37236c56a7c204d4f34fab2be5b1f307d1af6e4b.tar.gz
org.eclipse.mylyn.tasks-37236c56a7c204d4f34fab2be5b1f307d1af6e4b.tar.xz
org.eclipse.mylyn.tasks-37236c56a7c204d4f34fab2be5b1f307d1af6e4b.zip
487761: Allow credential fields to be toggled
setNeedsRepositoryCredentials() now affects the editability of credentials fields after control creation. Change-Id: I1cc5c8f61f1274dd052c98e0d5ab993504e0dee9 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=487761 Signed-off-by: James Kennedy <james.kennedy@tasktop.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.java77
1 files changed, 77 insertions, 0 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 1a595dc87..6e163cccf 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
@@ -70,6 +70,7 @@ public class RepositorySettingsPageTest {
Combo getServerUrlCombo() {
return serverUrlCombo;
}
+
}
public static class RepositorySettingsPageWithNoCredentials extends TestRepositorySettingsPage {
@@ -206,6 +207,72 @@ public class RepositorySettingsPageTest {
}
@Test
+ public void setNeedsRepositoryCredentialsInitializeFalse() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ page.setNeedsRepositoryCredentials(false);
+ page.createControl(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+
+ assertFalse(page.needsRepositoryCredentials());
+ assertNull(page.repositoryUserNameEditor);
+ assertNull(page.repositoryPasswordEditor);
+ }
+
+ @Test
+ public void setNeedsRepositoryCredentialsInitializeTrue() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ page.setNeedsRepositoryCredentials(true);
+ page.createControl(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+
+ assertTrue(page.needsRepositoryCredentials());
+ assertCredentialsEnabled(page);
+ }
+
+ @Test
+ public void setNeedsRepositoryCredentialsFalse() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ page.setNeedsRepositoryCredentials(true);
+ page.createControl(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ assertCredentialsEnabled(page);
+
+ page.setNeedsRepositoryCredentials(false);
+
+ assertCredentialsDisabled(page);
+ }
+
+ @Test
+ public void setNeedsRepositoryCredentialsTrue() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ page.setNeedsRepositoryCredentials(true);
+ page.createControl(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ page.setNeedsRepositoryCredentials(false);
+ assertCredentialsDisabled(page);
+
+ page.setNeedsRepositoryCredentials(true);
+ assertCredentialsEnabled(page);
+ }
+
+ @Test
+ public void repositoryCredentialsEnabledOnlyIfNeededAndNotAnonymous() throws Exception {
+ TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
+ page.setNeedsRepositoryCredentials(true);
+ page.setNeedsAnonymousLogin(true);
+ page.createControl(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+
+ assertTrue(page.needsRepositoryCredentials());
+ assertTrue(page.isAnonymousAccess());
+ assertCredentialsDisabled(page);
+
+ page.setAnonymous(false);
+ page.setNeedsRepositoryCredentials(false);
+
+ assertCredentialsDisabled(page);
+
+ page.setNeedsRepositoryCredentials(true);
+
+ assertCredentialsEnabled(page);
+ }
+
+ @Test
public void isUrlReadOnly() throws Exception {
TestRepositorySettingsPage page = new TestRepositorySettingsPage(createTaskRepository());
assertFalse(page.isUrlReadOnly());
@@ -235,4 +302,14 @@ public class RepositorySettingsPageTest {
repository.setRepositoryLabel("label");
return repository;
}
+
+ private void assertCredentialsEnabled(TestRepositorySettingsPage page) {
+ assertTrue(page.repositoryUserNameEditor.getTextControl(page.compositeContainer).isEnabled());
+ assertTrue(page.repositoryPasswordEditor.getTextControl(page.compositeContainer).isEnabled());
+ }
+
+ private void assertCredentialsDisabled(TestRepositorySettingsPage page) {
+ assertFalse(page.repositoryUserNameEditor.getTextControl(page.compositeContainer).isEnabled());
+ assertFalse(page.repositoryPasswordEditor.getTextControl(page.compositeContainer).isEnabled());
+ }
}

Back to the top