/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 2016 IBM Corporation and others.
* 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
private String getEntryElementName(EObject object, Entry<?, ?> entry) {
if (object instanceof MContext) {
for (Entry<String, String> property : ((MContext) object).getProperties().entrySet()) {
- if (property == entry) {
+ if (property.equals(entry)) {
return CONTEXT_PROPERTIES_ATTNAME;
}
}
if (object instanceof MContribution) {
for (Entry<String, String> state : ((MContribution) object).getPersistedState()
.entrySet()) {
- if (state == entry) {
+ if (state.equals(entry)) {
return APPLICATIONELEMENT_PERSISTEDSTATE_ATTNAME;
}
}
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2016 IBM Corporation and others.
* 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
package org.eclipse.e4.ui.tests.reconciler;
import java.util.Collection;
+import java.util.Objects;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
part.getPersistedState().put("testing", userChange);
Object state = reconciler.serialize();
+ assertEquals(!Objects.equals(applicationState, userChange),
+ serializedStateHasChanges(state));
application = createApplication();
window = application.getChildren().get(0);
part.getPersistedState().put("testing", newApplicationState);
Collection<ModelDelta> deltas = constructDeltas(application, state);
+ assertEquals(Objects.equals(applicationState, userChange) ? 0 : 1, deltas.size());
assertEquals(newApplicationState, part.getPersistedState().get(
"testing"));
}
}
+ /**
+ * @param state
+ * @return true if the state object, returned from
+ * {@link ModelReconciler#serialize()} when recording changes,
+ * actually has changes recorded.
+ */
+ protected abstract boolean serializedStateHasChanges(Object state);
+
public void testContribution_PersistedState_NullNullNull() {
testContribution_PersistedState(null, null, null);
}
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2016 IBM Corporation and others.
* 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
return new ModelReconcilingService();
}
+ protected boolean serializedStateHasChanges(Object state) {
+ assertTrue(state instanceof org.w3c.dom.Document);
+ org.w3c.dom.Document doc = (org.w3c.dom.Document) state;
+ assertTrue(doc.hasChildNodes() && doc.getChildNodes().getLength() == 1
+ && "changes".equals(doc.getFirstChild().getNodeName()));
+ return doc.getFirstChild().hasChildNodes();
+ }
}