Test Case Results Table - pc2ccs/pc2v9 GitHub Wiki

Pressing the "Execute" button on a Judge's SelectJudgementPane causes the currently selected run (submission) to be compiled and then executed once for each test data file configured in the problem (see PC2V9 Run Execution).

When execution finishes the SelectJudgementPane displays a Test Case Results Table showing the results for each test case (judge's data file).

A Test Case Results Table is a Java JTable contained in a Java JScrollPane contained in a Java JTabbedPane which in turn is contained in a PC2 TestResultsPane inside a PC2 TestResultFrame.

The JTable is initially constructed with an empty 12x7 table backed by an instance of DefaultTableModel. Prior to making the containing TestResultFrame visible a call is made to the TestResultPane's setData() method, which in turn calls the pane's populateGUI() method. populateGUI() in turn fetches all the test case results from the current execution by calling method getCurrentTestCaseResults().

getCurrentTestCaseResults() is also called from methods loadTableWithAllTestCaseResults() and loadTableWithFailedTestCases(). In both those cases (as well as the case of the call from populateGUI()), the current test case results are passed in an array to method getResultsTable(), which returns a JTable containing the results which is then placed inside the JScrollPane. These are the only ways in which the user-viewable test case results table gets populated.

Method getResultsTable() first checks if the TestResultPane's Show Failures Only checkbox is checked, and if so it removes any "passed" or "unexecuted" test cases from the received array. It then constructs a new TestCaseResultsTableModel from the received (possibly updated) TestCaseResults. The TestCaseResultsTableModel contains a row for each test case result. The first column contains a Boolean ("row selected or not"); the second column contains a string containing the test case number. The third column contains a JLabel whose text gives the test case result (e.g. "Pass", "Fail", "No Validator"); the fourth column contains a String giving the execution time of the test case.

The remaining table model columns contain JLabels which are either Strings to be clicked on (e.g. for viewing or comparing files), or are empty if the corresponding file is not available (for example, if the contest problem has no judge's output then the "Judge's Output" JLabel will be an empty String).

getResultsTable() adds the TestResultsPane class (that is, its containing class) as a TableModelListener on the new TestCaseResultsTableModel, so that any changes to the table model will invoke TestResultsPane.tableChanged(). When this method is invoked due to a table model change it checks to see if the change took place in the "Select" column of the table, and if so it invokes method updateCompareSelectedButton() to insure that the "Compare Selected" button is only enabled when there are at least two table rows selected for comparison.

getResultsTable() then constructs a new JTable with the newly-created TestCaseResultsTableModel, sets a variety of options on the JTable (such as selection mode, filling the viewport, and disallowing column reordering), and adds a ListSelectionListener on the table which will enable/disable the "Compare Selected" button as appropriate whenever a table value (such as a row selection checkbox) changes.

getResultsTable() then adds Cell Renderers to each table column. These cell renderers determine the "appearance" of a cell -- for example whether the cell appears as a checkbox, a centered string, or a "clickable link". However, the data which appears in the cell is determined by the Table Model. Further, any action which occurs when a table cell is clicked is determined by what listeners have been attached to the table.

Finally, getResultsTable() checks to see whether the Show Failures Only checkbox is checked, and if not it adds any unexecuted test cases to the end of the table. (Test cases could have been unexecuted, for example, if "Stop on first failed test case" was selected when the problem was created; any test cases after the first failed test case would not have been executed -- but typically the user would like to see them in the table.

getResultsTable() also attaches a MouseListener to the table. When a mouse-click occurs the MouseListener fetches the table row and column in which the mouse was clicked, then checks to make sure the click was in a cell that represents selectable data. If so, it then fetches the string stored in cell and if the string is "View" it invokes method viewFile(row,column); if the string is "Compare" it invokes method compareFiles() passing it a one-element array containing the row number.

⚠️ **GitHub.com Fallback** ⚠️