diff options
author | Karen Butzke | 2012-10-25 14:38:30 +0000 |
---|---|---|
committer | Karen Butzke | 2012-10-26 18:10:18 +0000 |
commit | d3b775c951265391f716c7860a84a72252f5ce13 (patch) | |
tree | 0910bae87f01bc8225c59c252c0997fa1d655a61 /common/tests/org.eclipse.jpt.common.ui.tests | |
parent | d95b4a75d98f11ac70121d6d7c5cd05a880ad14c (diff) | |
download | webtools.dali-d3b775c951265391f716c7860a84a72252f5ce13.tar.gz webtools.dali-d3b775c951265391f716c7860a84a72252f5ce13.tar.xz webtools.dali-d3b775c951265391f716c7860a84a72252f5ce13.zip |
added SWTTools.controlExpandedState for Sections
Diffstat (limited to 'common/tests/org.eclipse.jpt.common.ui.tests')
2 files changed, 88 insertions, 0 deletions
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/JptUiUtilTests.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/JptUiUtilTests.java index 4f848cba14..a308ba884e 100644 --- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/JptUiUtilTests.java +++ b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/JptUiUtilTests.java @@ -26,6 +26,7 @@ import org.junit.runners.Suite.SuiteClasses; LabeledLabelTest.class, LabeledControlUpdaterTest.class, PaneVisibilityEnablerTest.class, + SectionExpanderTest.class, }) @RunWith(Suite.class) public final class JptUiUtilTests { diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/SectionExpanderTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/SectionExpanderTest.java new file mode 100644 index 0000000000..4f9646c7a5 --- /dev/null +++ b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/SectionExpanderTest.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2012 Oracle. 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: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.common.ui.tests.internal.util; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.eclipse.jpt.common.ui.internal.util.SWTUtil; +import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools; +import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.ui.forms.widgets.Section; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +@SuppressWarnings("nls") +public final class SectionExpanderTest { + + private Composite parent; + + @Before + public void setUp() { + this.parent = new Composite(SWTUtil.getShell(), SWT.NONE); + this.parent.setLayout(new GridLayout()); + } + + @After + public void tearDown() { + if (this.parent != null) { + this.parent.dispose(); + } + } + + @Test + public void testSwitchState() { + + SimplePropertyValueModel<Boolean> booleanModel = + new SimplePropertyValueModel<Boolean>(Boolean.FALSE); + + Section section = new Section(this.parent, ExpandableComposite.TWISTIE); + + SWTTools.controlExpandedState(booleanModel, section); + + assertFalse( + "The Section should not be expanded", + section.isExpanded() + ); + + // Change state (null) + booleanModel.setValue(null); + + assertFalse( + "The Section should not be expanded", + section.isExpanded() + ); + + // Change state (true) + booleanModel.setValue(Boolean.TRUE); + + assertTrue( + "The Combo should be enabled", + section.isExpanded() + ); + + // Change state (false) + booleanModel.setValue(Boolean.FALSE); + + assertFalse( + "The Combo should not be enabled", + section.isExpanded() + ); + + // Dispose + section.dispose(); + booleanModel.setValue(Boolean.TRUE); + } +} |