Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating CogTool's first unit tests #66

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/ant.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions .idea/cogtool-intellij2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/build.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/libraries/lib.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion java/edu/cmu/cs/hcii/cogtool/model/Design.java
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ public static class FrameSetChange extends EventObject
* Initialize the semantic change representing an add or a remove.
*
* @param design the design that was modified
* @param frames the frames added or removed
* @param frameChg the frames added or removed
* @param add a flag indicating whether the change is an add
* or a remove
* @author mlh
Expand Down
27 changes: 27 additions & 0 deletions java/edu/cmu/cs/hcii/cogtool/model/DesignTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package edu.cmu.cs.hcii.cogtool.model;

import org.junit.Test;

import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.*;

public class DesignTest {

private String designName = "My First Design";
Set<DeviceType> deviceTypeSet = new HashSet<DeviceType>();
private Design aDesign = new Design(designName, deviceTypeSet);

@Test
public void getName() {
assertEquals(designName, aDesign.getName());
}

@Test
public void setName() {
String designName = "My Second Design";
aDesign.setName(designName);
assertEquals(designName, aDesign.name);
}
}
2 changes: 1 addition & 1 deletion java/edu/cmu/cs/hcii/cogtool/ui/DesignEditorUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected class FrameNameEditor extends SWTTextEditor
{
public FrameNameEditor()
{
super(view.getEditor().getSWTEditorSubstrate(), CENTER_TEXT);
super(DesignEditorUI.this.view.getEditor().getSWTEditorSubstrate(), CENTER_TEXT);
}

@Override
Expand Down
26 changes: 26 additions & 0 deletions java/edu/cmu/cs/hcii/cogtool/ui/DesignEditorUITest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package edu.cmu.cs.hcii.cogtool.ui;

import edu.cmu.cs.hcii.cogtool.model.Design;
import edu.cmu.cs.hcii.cogtool.model.DeviceType;
import edu.cmu.cs.hcii.cogtool.model.Project;
import org.junit.Test;

import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.*;

public class DesignEditorUITest {

@Test
public void buildWindowMenuLabel() {
Project aProject = new Project("My First Project");

String designName = "My First Design";
Set<DeviceType> deviceTypeSet = new HashSet<DeviceType>();
Design aDesign = new Design(designName, deviceTypeSet);

DesignEditorUI anEditorUI = new DesignEditorUI(aDesign,aProject, null);
assertEquals("Design: " + designName, anEditorUI.buildWindowMenuLabel(aDesign));
}
}
2 changes: 1 addition & 1 deletion java/edu/cmu/cs/hcii/cogtool/ui/FrameEditorUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ protected class WidgetTitleEditor extends SWTTextEditor
{
public WidgetTitleEditor()
{
super(view.getEditor().getSWTEditorSubstrate(), LEFT_JUSTIFY);
super(FrameEditorUI.this.view.getEditor().getSWTEditorSubstrate(), LEFT_JUSTIFY);
}

@Override
Expand Down
4 changes: 0 additions & 4 deletions java/edu/cmu/cs/hcii/cogtool/ui/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ public void setEnabled(CogToolLID id, Boolean availability, boolean enable)
* @param newLabel if not null, the new label to use for the user interface
* widgets associated with the given id that support labels
* @author mlh
* @see ListenerIdentifierMap.getWidgets
*/

public void setEnabled(CogToolLID id,
Expand Down Expand Up @@ -700,7 +699,6 @@ public void setEnabled(CogToolLID id,
* widgets associated with the given id that support labels
* @param selected for all associated widgets that are MenuItems set
* their selection state to this
* @see ListenerIdentifierMap.getWidgets
*/
public void setEnabled(CogToolLID id,
Boolean availability,
Expand Down Expand Up @@ -1250,8 +1248,6 @@ protected boolean doesIDCommitChanges(ListenerIdentifier lid)
* from the appropriate IUndoableEdit from the given undo manager.
*
* @param lid the CogTool command being queried
* @param undoMgr the window's undo manager in case the given LID is
* CogToolLID.Undo or CogToolLID.Redo
* @return whether the given LID is a CogToolLID that
* can cause selection
*/
Expand Down
12 changes: 6 additions & 6 deletions java/edu/cmu/cs/hcii/cogtool/view/ActionPropertySet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ protected void onFocus()
{
super.onFocus();

view.getTransmuter().setLIDEnabledState();
ActionPropertySet.this.view.getTransmuter().setLIDEnabledState();
}

@Override
Expand All @@ -1182,7 +1182,7 @@ protected boolean doChangeAction()
labelSelection = null;
}

if (view.performAction(DesignEditorLID.ChangeDelay)) {
if (ActionPropertySet.this.view.performAction(DesignEditorLID.ChangeDelay)) {
if (labelSelection != null) {
setSelection(labelSelection);
}
Expand All @@ -1208,7 +1208,7 @@ protected void onFocus()
{
super.onFocus();

view.getTransmuter().setLIDEnabledState();
ActionPropertySet.this.view.getTransmuter().setLIDEnabledState();
}

@Override
Expand All @@ -1229,7 +1229,7 @@ protected boolean doChangeAction()
delaySelection = null;
}

if (view.performAction(DesignEditorLID.ChangeDelay)) {
if (ActionPropertySet.this.view.performAction(DesignEditorLID.ChangeDelay)) {
if (delaySelection != null) {
setSelection(delaySelection);
}
Expand Down Expand Up @@ -1340,7 +1340,7 @@ protected void onFocus()
{
super.onFocus();

view.getTransmuter().setLIDEnabledState();
ActionPropertySet.this.view.getTransmuter().setLIDEnabledState();
}

@Override
Expand All @@ -1351,7 +1351,7 @@ protected boolean doChangeAction()
DesignEditorUI.DesignRenameParameters parms =
new DesignEditorUI.DesignRenameParameters(design, designName.getText());

boolean changed = view.performAction(ProjectLID.RenameDesign,
boolean changed = ActionPropertySet.this.view.performAction(ProjectLID.RenameDesign,
parms,
true);

Expand Down
12 changes: 8 additions & 4 deletions java/edu/cmu/cs/hcii/cogtool/view/FramePropertiesPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,17 @@ public class FramePropertiesPane extends Composite
private TreeItemUpdater<FrameElementGroup, FrameElement> eltGroupUpdater;
private TreeItemUpdater<SimpleWidgetGroup, IWidget> implicitGroupUpdater;

protected View view;

public FramePropertiesPane(Composite parent, int style, View view)
{
super(parent, style);

setLayout(new FormLayout());

createWidgets(view);
this.view = view;

createWidgets();
layOutWidgets();
}

Expand Down Expand Up @@ -234,7 +238,7 @@ protected void layOutWidgets()
}
}

protected void createWidgets(final View view)
protected void createWidgets()
{
ListenerIdentifierMap lidMap = view.getLIDMap();

Expand All @@ -249,7 +253,7 @@ protected void onFocus()
{
super.onFocus();

view.getTransmuter().setLIDEnabledState();
FramePropertiesPane.this.view.getTransmuter().setLIDEnabledState();
}

@Override
Expand All @@ -259,7 +263,7 @@ protected boolean doChangeAction()
DesignEditorUI.FrameRenameParameters evt =
new DesignEditorUI.FrameRenameParameters(frame, getText());
boolean changed =
view.performAction(DesignEditorLID.RenameFrame,
FramePropertiesPane.this.view.performAction(DesignEditorLID.RenameFrame,
evt,
true);

Expand Down
6 changes: 3 additions & 3 deletions java/edu/cmu/cs/hcii/cogtool/view/WidgetPropertiesPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public WidgetChangeText(Composite parent,
* If no widgets are selected, suppresses the event.
*
* IE: raise an LID event.
* @param e
* @param focusRule
*/
@Override
public boolean confirm(int focusRule)
Expand Down Expand Up @@ -563,9 +563,9 @@ protected boolean doChangeAction()

FrameEditorUI.SetRemoteLabelTypeParms setTypeParms =
new FrameEditorUI.SetRemoteLabelTypeParms(widgetTypeChoices[selectedType],
view.selection.getSelectedIWidgets()[0]);
WidgetPropertiesPane.this.view.selection.getSelectedIWidgets()[0]);

return view.performAction(FrameEditorLID.SetRemoteLabelType,
return WidgetPropertiesPane.this.view.performAction(FrameEditorLID.SetRemoteLabelType,
setTypeParms,
true);
}
Expand Down