Skip to content

Commit

Permalink
Restore completion filter after testing preference
Browse files Browse the repository at this point in the history
On GitHub actions the org.eclipse.cdt.ui.tests.text.contentassist2
tests are running after ProposalFilterPreferencesTest and
ProposalFilterPreferencesTest was changing the default
filter and not restoring it.

Part of #117
  • Loading branch information
jonahgraham committed Oct 25, 2022
1 parent 98f45c7 commit 178dbfa
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@
*/
public class ProposalFilterPreferencesTest extends TestCase {

private IPreferenceStore store;
private String filterComboStateStringBefore;

@Override
protected void setUp() throws Exception {
super.setUp();
store = CUIPlugin.getDefault().getPreferenceStore();
filterComboStateStringBefore = store.getString(ContentAssistPreference.PROPOSALS_FILTER);
}

@Override
protected void tearDown() throws Exception {
store.setValue(ContentAssistPreference.PROPOSALS_FILTER, filterComboStateStringBefore);
super.tearDown();
}

public void testPreferences() {
// Check that the test filter is among the filter names.
String[] filterNames = ProposalFilterPreferencesUtil.getProposalFilterNames();
Expand All @@ -41,10 +57,8 @@ public void testPreferences() {
assertTrue("Did not find expected filter!", index >= 0);

// Set the preference to the tested filter
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
String filterComboStateString = store.getString(ContentAssistPreference.PROPOSALS_FILTER);
ProposalFilterPreferencesUtil.ComboState state = ProposalFilterPreferencesUtil
.getComboState(filterComboStateString);
.getComboState(filterComboStateStringBefore);
StringBuilder newStateText = new StringBuilder();
newStateText.append(index + 1); // First entry is always the <Default Filter>, index+1 must be selected
for (int i = 0; i < state.items.length; i++) {
Expand Down

0 comments on commit 178dbfa

Please sign in to comment.