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

Summary view navigation #150

Merged
merged 32 commits into from
Aug 7, 2021
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ddc8806
added navigation buttons:
JKutscha Jul 16, 2021
aee9697
Restructered some tests and added test for summary
Jul 16, 2021
d71a67e
Fix for test of PitclipsePitSummaryViewTest
JKutscha Jul 16, 2021
7e9894f
Added wait condition to PitResultNotifier
JKutscha Jul 18, 2021
54a5cd0
Changed timeouts to fit better
JKutscha Jul 18, 2021
c6f83e6
Unused class which I forgot to delete
JKutscha Jul 18, 2021
bc44bc9
Merge branch 'master' into Summary_View_Navigation
JKutscha Jul 22, 2021
0219999
Merge branch 'master' into Summary_View_Navigation
JKutscha Jul 22, 2021
8569610
Merge branch 'master' into Summary_View_Navigation
JKutscha Jul 24, 2021
e3594ed
Removed bot click events and use reference
JKutscha Jul 24, 2021
d5e24ae
Merge branch 'master' into Summary_View_Navigation
JKutscha Jul 26, 2021
a2ea9c7
Introduced own waiting condition for the browser
JKutscha Jul 27, 2021
f1e8c98
Merge branch 'master' into Summary_View_Navigation
JKutscha Jul 27, 2021
7d68ef8
Updated condition for about:blank in summary view
JKutscha Jul 27, 2021
42d1cdf
Removed navigations to blank page
JKutscha Jul 27, 2021
639aa9b
Added fail, if the summary view can't be gotten
JKutscha Jul 27, 2021
0c93e12
Fixed typo, != instead of ==
JKutscha Jul 27, 2021
e8536ec
Revert back to use SWTBot for button clicks
JKutscha Jul 27, 2021
cf34b41
Merge branch 'master' into Summary_View_Navigation
JKutscha Jul 28, 2021
037d74e
Removed unused methods of PitView
JKutscha Jul 29, 2021
e5721da
Merge branch 'Summary_View_Navigation' of github.com:JKutscha/pitclip…
JKutscha Jul 29, 2021
65f5216
Code review fixes for comments of echebbi
JKutscha Jul 29, 2021
48b4a75
Wait for browser to load page in test instead of constucutor (PitSumm…
JKutscha Jul 29, 2021
07892bb
Added own test for testing while empty view
JKutscha Jul 29, 2021
96252b1
Removed not used fail
JKutscha Jul 29, 2021
ca75d8f
Merge branch 'master' into Summary_View_Navigation
JKutscha Aug 2, 2021
d3ee974
Close view using bot | create buttons and add them
JKutscha Aug 2, 2021
615e174
Merge remote-tracking branch 'origin/master' into Summary_View_Naviga…
Aug 3, 2021
2467ab1
Removed double brwoser creation, merge oversight
Aug 3, 2021
6e6f709
Test fix for codeCoverageReport generated after merge
JKutscha Aug 3, 2021
2421be6
Review fixes
Aug 4, 2021
fd53cc8
Merge branch 'master' into Summary_View_Navigation
JKutscha Aug 4, 2021
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into Summary_View_Naviga…
…tion
Jonas Kutscha committed Aug 3, 2021
commit 615e17476150f66cf830560cc84545bf69dbd751
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright 2021 Lorenzo Bettini and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
package org.pitest.pitclipse.ui.utils;

import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.MessageBox;

/**
* A few utilities for the UI.
*
* @author Lorenzo Bettini
*
*/
public class PitclipseUiUtils {

private PitclipseUiUtils() {
// Only static utility methods
}

/**
* Only performs the operation if the {@link Composite} is not null and not
* disposed.
*
* @param c
*/
public static void setFocusSafely(Composite c) {
if (c != null && !c.isDisposed()) {
c.setFocus();
}
}

/**
* Only performs the operation if the {@link Composite} is not null and not
* disposed.
*
* @param c
*/
public static void disposeSafely(Composite c) {
if (c != null && !c.isDisposed()) {
c.dispose();
}
}

/**
* Executes the {@link Runnable} and in case of {@link SWTError} shows a dialog
* with the specified title and error message, using the specified parent.
*
* @param runnable
* @param parent
* @param title
* @param errorMessage
*/
public static void executeSafely(Runnable runnable, Composite parent,
String title, String errorMessage) {
try {
runnable.run();
} catch (SWTError e) {
if (e.getMessage() != null) {
errorMessage += "\n" + e.getMessage();
}
MessageBox messageBox = new MessageBox(parent.getShell(),
SWT.ICON_ERROR | SWT.OK);
messageBox.setText(title);
messageBox.setMessage(errorMessage);
messageBox.open();
}
}
}
Original file line number Diff line number Diff line change
@@ -21,12 +21,11 @@
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.part.ViewPart;
import org.pitest.pitclipse.ui.utils.PitclipseUiUtils;

/**
* A view displaying the HTML report generated by PIT.
@@ -42,43 +41,44 @@ public class PitView extends ViewPart implements SummaryView {

@Override
public synchronized void createPartControl(Composite parent) {
try {
browser = new Browser(parent, SWT.NONE);
resetBrowser();
browser.addProgressListener(new PitUiUpdatePublisher(browser));
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolBar = actionBars.getToolBarManager();
// create back button
toolBar.add(new Action(BACK_BUTTON_TEXT) {
@Override
public void run() {
browser.back();
}
});
// create home button for navigation
toolBar.add(new Action(HOME_BUTTON_TEXT) {
@Override
public void run() {
if (homeUrlString != null) {
// only set url, if an home is set otherwise NPE
browser.setUrl(homeUrlString);
PitclipseUiUtils.executeSafely(
() -> {
JKutscha marked this conversation as resolved.
Show resolved Hide resolved
browser = new Browser(parent, SWT.NONE);
resetBrowser();
browser.addProgressListener(new PitUiUpdatePublisher(browser));
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolBar = actionBars.getToolBarManager();
// create back button
toolBar.add(new Action(BACK_BUTTON_TEXT) {
@Override
public void run() {
browser.back();
}
});
// create home button for navigation
toolBar.add(new Action(HOME_BUTTON_TEXT) {
@Override
public void run() {
if (homeUrlString != null) {
// only set url, if an home is set otherwise NPE
browser.setUrl(homeUrlString);
}
}
});
// create forward button
toolBar.add(new Action(FORWARD_BUTTON_TEXT) {
@Override
public void run() {
browser.forward();
}
}
});
// create forward button
toolBar.add(new Action(FORWARD_BUTTON_TEXT) {
@Override
public void run() {
browser.forward();
}
});
actionBars.updateActionBars();
} catch (SWTError e) {
MessageBox messageBox = new MessageBox(parent.getShell(), SWT.ICON_ERROR | SWT.OK);
messageBox.setMessage("Browser cannot be initialized.");
messageBox.setText("Exit");
messageBox.open();
}
});
actionBars.updateActionBars();
browser = new Browser(parent, SWT.NONE);
browser.addProgressListener(new PitUiUpdatePublisher(browser));
},
parent,
"Failed to create the Pit Summary view",
"Browser cannot be initialized.");
}

/**
@@ -93,9 +93,7 @@ private void resetBrowser() {

@Override
public void setFocus() {
if (!browser.isDisposed()) {
browser.setFocus();
}
PitclipseUiUtils.setFocusSafely(browser);
}

@Override
@@ -107,4 +105,10 @@ public synchronized void update(File result) {
browser.setUrl(homeUrlString);
}
}

@Override
public void dispose() {
PitclipseUiUtils.disposeSafely(browser);
super.dispose();
}
}
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -67,6 +67,9 @@
**/runner/model/*.java,
**/runner/results/summary/*.java,
</sonar.exclusions>
<sonar.coverage.exclusions>
**/PitclipseUiUtils.java
</sonar.coverage.exclusions>
<sonar.coverage.jacoco.xmlReportPaths>
${basedir}/../../tests/org.pitest.pitclipse.tests.coverage.report/target/site/jacoco-aggregate/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
Original file line number Diff line number Diff line change
@@ -75,6 +75,8 @@ public void deleteProject(String projectName) {
try {
project.delete(true, progressMonitor);
} catch (CoreException e) {
// let's see if we get some more information when it happens
e.printStackTrace();
throw new StepException(e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright 2021 Jonas Kutscha and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
package org.pitest.pitclipse.ui.behaviours.pageobjects;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;

/**
* Class to get the console text.
* @author Jonas Kutscha
*/
public class Console {
private SWTWorkbenchBot bot;

public Console(SWTWorkbenchBot bot) {
this.bot = bot;
}

/**
* Shows the view console and returns its text.
* @return the console text
*/
public String getText() {
final SWTBotView console = bot.viewByPartName("Console");
// need to show, otherwise bot can't get text
console.show();
return console.bot().styledText().getText();
}
}
Original file line number Diff line number Diff line change
@@ -26,13 +26,13 @@ public enum PageObjects {
private final PackageExplorer packageExplorer;
private final WindowsMenu windowsMenu;
private final RunMenu runMenu;
private final PitSummaryView pitSummaryView;
private final PitMutationsView pitMutationsView;
private final BuildProgress buildProgress;
private final AbstractSyntaxTree abstractSyntaxTree;
private final SourceMenu sourceMenu;
private final RefactorMenu refactorMenu;
private final Views views;
private final PitSummaryView pitSummaryView;
private final Console console;

private PageObjects() {
SWTWorkbenchBot bot = new SWTWorkbenchBot();
@@ -47,7 +47,7 @@ private PageObjects() {
abstractSyntaxTree = new AbstractSyntaxTree();
sourceMenu = new SourceMenu(bot);
refactorMenu = new RefactorMenu(bot);
views = new Views(bot);
console = new Console(bot);
}

public FileMenu getFileMenu() {
@@ -70,10 +70,6 @@ public RunMenu getRunMenu() {
return runMenu;
}

public PitSummaryView getPitSummaryView() {
return pitSummaryView;
}

public BuildProgress getBuildProgress() {
return buildProgress;
}
@@ -94,7 +90,11 @@ public PitMutationsView getPitMutationsView() {
return pitMutationsView;
}

public Views views() {
return views;
public Console getConsole() {
return console;
}

public PitSummaryView getPitSummaryView() {
return pitSummaryView;
}
}
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@

package org.pitest.pitclipse.ui.behaviours.pageobjects;

import static org.pitest.pitclipse.ui.behaviours.pageobjects.PageObjects.PAGES;
import static org.pitest.pitclipse.ui.behaviours.pageobjects.SwtBotTreeHelper.expand;

import java.util.List;
@@ -55,7 +54,6 @@ public List<PitMutation> getMutations() {
}

private SWTBotTree mutationTreeRoot() {
PAGES.views().waitForTestsAreRunOnConsole();
SWTBotView mutationsView = bot.viewByTitle("PIT Mutations");
mutationsView.show();
// Make sure the 'PIT Mutations' view is opened
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.