Skip to content

Commit

Permalink
Fix GUI tests (and remove BasePanelTest)
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Jan 1, 2020
1 parent dfe2d2d commit 7dd7144
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 78 deletions.
18 changes: 15 additions & 3 deletions src/main/java/org/jabref/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,47 @@

public class Globals {

// JabRef version info
/**
* JabRef version info
*/
public static final BuildInfo BUILD_INFO = new BuildInfo();

// Remote listener
public static final RemoteListenerServerLifecycle REMOTE_LISTENER = new RemoteListenerServerLifecycle();

public static final ImportFormatReader IMPORT_FORMAT_READER = new ImportFormatReader();
public static final TaskExecutor TASK_EXECUTOR = new DefaultTaskExecutor();
// In the main program, this field is initialized in JabRefMain.java
// Each test case initializes this field if required

/**
* Each test case initializes this field if required
*/
public static JabRefPreferences prefs;

/**
* This field is initialized upon startup.
* Only GUI code is allowed to access it, logic code should use dependency injection.
*/
public static JournalAbbreviationLoader journalAbbreviationLoader;

/**
* This field is initialized upon startup.
* Only GUI code is allowed to access it, logic code should use dependency injection.
*/
public static ProtectedTermsLoader protectedTermsLoader;

/**
* Manager for the state of the GUI.
*/
public static StateManager stateManager = new StateManager();

public static ExporterFactory exportFactory;
public static CountingUndoManager undoManager = new CountingUndoManager();
public static BibEntryTypesManager entryTypesManager = new BibEntryTypesManager();
public static ClipBoardManager clipboardManager = new ClipBoardManager();

// Key binding preferences
private static KeyBindingRepository keyBindingRepository;

private static DefaultFileUpdateMonitor fileUpdateMonitor;
private static ThemeLoader themeLoader;
private static TelemetryClient telemetryClient;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/help/VersionWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class VersionWorker {
* The version which was previously ignored by the user
*/
private final Version toBeIgnored;

private final DialogService dialogService;
private final TaskExecutor taskExecutor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.push;

import java.util.List;
import java.util.Objects;
import java.util.Optional;

import org.jabref.Globals;
Expand Down Expand Up @@ -31,7 +32,7 @@ public class PushToApplicationAction extends SimpleCommand {
private PushToApplication application;

public PushToApplicationAction(StateManager stateManager, PushToApplicationsManager pushToApplicationsManager, DialogService dialogService) {
this.application = Globals.prefs.getActivePushToApplication(pushToApplicationsManager);
this.application = Objects.requireNonNull(Globals.prefs.getActivePushToApplication(pushToApplicationsManager));
this.stateManager = stateManager;
this.dialogService = dialogService;

Expand All @@ -40,7 +41,7 @@ public PushToApplicationAction(StateManager stateManager, PushToApplicationsMana
}

public void updateApplication(PushToApplication application) {
this.application = application;
this.application = Objects.requireNonNull(application);
}

public Action getActionInformation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public TextFlow getDescription() {
}

textList.add(getCaseSensitiveDescription());
textList.add(TooltipTextUtil.createText("\n\nHint: To search specific fields only, enter for example:\n"));
textList.add(TooltipTextUtil.createText("author=smith and title=electrical"));

TextFlow searchDescription = new TextFlow();
searchDescription.getChildren().setAll(textList);
return searchDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ public void putStringList(String key, List<String> value) {
public List<String> getStringList(String key) {
String names = get(key);
if (names == null) {
return new ArrayList<>();
return Collections.emptyList();
}

StringReader rd = new StringReader(names);
Expand Down
71 changes: 0 additions & 71 deletions src/test/java/org/jabref/gui/BasePanelTest.java

This file was deleted.

19 changes: 18 additions & 1 deletion src/test/java/org/jabref/gui/entryeditor/SourceTabTest.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package org.jabref.gui.entryeditor;

import java.util.Collections;

import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;

import org.jabref.Globals;
import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.keyboard.KeyBindingRepository;
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.bibtex.FieldContentParserPreferences;
import org.jabref.logic.bibtex.LatexFieldFormatterPreferences;
import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.UnknownField;
import org.jabref.model.util.DummyFileUpdateMonitor;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.testutils.category.GUITest;

import org.fxmisc.richtext.CodeArea;
Expand All @@ -25,6 +32,7 @@
import org.testfx.framework.junit5.Start;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@GUITest
@ExtendWith(ApplicationExtension.class)
Expand All @@ -40,7 +48,16 @@ public class SourceTabTest {
public void onStart(Stage stage) {
area = new CodeArea();
area.appendText("some example\n text to go here\n across a couple of \n lines....");
sourceTab = new SourceTab(new BibDatabaseContext(), new CountingUndoManager(), new LatexFieldFormatterPreferences(), mock(ImportFormatPreferences.class), new DummyFileUpdateMonitor(), mock(DialogService.class), mock(StateManager.class));
StateManager stateManager = mock(StateManager.class);
when(stateManager.activeSearchQueryProperty()).thenReturn(OptionalObjectProperty.empty());
Globals.prefs = mock(JabRefPreferences.class);
KeyBindingRepository keyBindingRepository = new KeyBindingRepository(Collections.emptyList(), Collections.emptyList());
when(Globals.prefs.getKeyBindingRepository()).thenReturn(keyBindingRepository);
ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class);
when(importFormatPreferences.getFieldContentParserPreferences())
.thenReturn(mock(FieldContentParserPreferences.class));

sourceTab = new SourceTab(new BibDatabaseContext(), new CountingUndoManager(), new LatexFieldFormatterPreferences(), importFormatPreferences, new DummyFileUpdateMonitor(), mock(DialogService.class), stateManager);
pane = new TabPane(
new Tab("main area", area),
new Tab("other tab", new Label("some text")),
Expand Down

0 comments on commit 7dd7144

Please sign in to comment.