Bläddra i källkod

test: unskip 4 skipped tests, comment out 5th skipped, faulty test

sschmid 5 år sedan
förälder
incheckning
4fa617e2a8

+ 5 - 4
src/MusicalScore/Graphical/GraphicalMusicSheet.ts

@@ -790,15 +790,16 @@ export class GraphicalMusicSheet {
         }
         let previousStaffEntryMusicSystem: MusicSystem = undefined;
         if (previousStaffEntry !== undefined) {
-            previousStaffEntryMusicSystem = previousStaffEntry.parentMeasure.ParentStaffLine.ParentMusicSystem;
+            // TODO sometimes one of these ParentStaffLine is undefined, either fix this or handle it here
+            previousStaffEntryMusicSystem = previousStaffEntry.parentMeasure.ParentStaffLine?.ParentMusicSystem;
         } else {
-            previousStaffEntryMusicSystem = nextStaffEntry.parentMeasure.ParentStaffLine.ParentMusicSystem;
+            previousStaffEntryMusicSystem = nextStaffEntry.parentMeasure.ParentStaffLine?.ParentMusicSystem;
         }
         let nextStaffEntryMusicSystem: MusicSystem = undefined;
         if (nextStaffEntry !== undefined) {
-            nextStaffEntryMusicSystem = nextStaffEntry.parentMeasure.ParentStaffLine.ParentMusicSystem;
+            nextStaffEntryMusicSystem = nextStaffEntry.parentMeasure.ParentStaffLine?.ParentMusicSystem;
         } else {
-            nextStaffEntryMusicSystem = previousStaffEntry.parentMeasure.ParentStaffLine.ParentMusicSystem;
+            nextStaffEntryMusicSystem = previousStaffEntry.parentMeasure.ParentStaffLine?.ParentMusicSystem;
         }
         if (previousStaffEntryMusicSystem === nextStaffEntryMusicSystem) {
             currentMusicSystem = previousStaffEntryMusicSystem;

+ 5 - 0
src/MusicalScore/Graphical/MusicSheetDrawer.ts

@@ -69,6 +69,11 @@ export abstract class MusicSheetDrawer {
         this.drawSplitScreenLine();
         if (this.drawingParameters.drawCursors) {
             for (const line of graphicalMusicSheet.Cursors) {
+                if (!line) {
+                    // TODO GraphicalMusicSheet.calculateCursorLineAtTimestamp() can return undefined.
+                    // why does this happen in the VexFlowMusicSheetDrawer_Test? (it("draws cursor..."))
+                    continue;
+                }
                 const psi: BoundingBox = new BoundingBox(line);
                 psi.AbsolutePosition = line.Start;
                 psi.BorderBottom = line.End.y - line.Start.y;

+ 7 - 6
test/MusicalScore/Graphical/VexFlow/VexFlowMeasure_Test.ts

@@ -8,13 +8,13 @@ import {SourceMeasure} from "../../../../src/MusicalScore/VoiceData/SourceMeasur
 import {SourceStaffEntry} from "../../../../src/MusicalScore/VoiceData/SourceStaffEntry";
 import {GraphicalMeasure} from "../../../../src/MusicalScore/Graphical/GraphicalMeasure";
 import {MusicSheetCalculator} from "../../../../src/MusicalScore/Graphical/MusicSheetCalculator";
-import { EngravingRules } from "../../../../src/MusicalScore/Graphical/EngravingRules";
+import {EngravingRules} from "../../../../src/MusicalScore/Graphical/EngravingRules";
 
 /* tslint:disable:no-unused-expression */
 describe("VexFlow Measure", () => {
 
-   it.skip("GraphicalMusicSheet", (done: MochaDone) => {
-      const path: string = "test/data/MuzioClementi_SonatinaOpus36No1_Part1.xml";
+   it("GraphicalMusicSheet", (done: MochaDone) => {
+      const path: string = "MuzioClementi_SonatinaOpus36No1_Part1.xml";
       const score: Document = TestUtils.getScore(path);
       chai.expect(score).to.not.be.undefined;
       const partwise: Element = TestUtils.getPartWiseElement(score);
@@ -27,7 +27,7 @@ describe("VexFlow Measure", () => {
       done();
    });
 
-   it.skip("Simple Measure", (done: MochaDone) => {
+   it("Simple Measure", (done: MochaDone) => {
       const sheet: MusicSheet = new MusicSheet();
       sheet.Rules = new EngravingRules();
       const measure: SourceMeasure = new SourceMeasure(1, sheet.Rules);
@@ -41,7 +41,7 @@ describe("VexFlow Measure", () => {
       done();
    });
 
-   it.skip("Empty Measure", (done: MochaDone) => {
+   it("Empty Measure", (done: MochaDone) => {
       const sheet: MusicSheet = new MusicSheet();
       sheet.Rules = new EngravingRules();
       const measure: SourceMeasure = new SourceMeasure(1, sheet.Rules);
@@ -50,7 +50,8 @@ describe("VexFlow Measure", () => {
       const calc: MusicSheetCalculator = new VexFlowMusicSheetCalculator(sheet.Rules);
       const gms: GraphicalMusicSheet = new GraphicalMusicSheet(sheet, calc);
       chai.expect(gms.MeasureList.length).to.equal(1);
-      chai.expect(gms.MeasureList[0].length).to.equal(0);
+      chai.expect(gms.MeasureList[0].length).to.equal(1);
+      chai.expect(gms.MeasureList[0][0].staffEntries.length).to.equal(0);
       done();
    });
 

+ 21 - 22
test/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetDrawer_Test.ts

@@ -1,15 +1,12 @@
 import {VexFlowMusicSheetDrawer} from "../../../../src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetDrawer";
 import {GraphicalMusicSheet} from "../../../../src/MusicalScore/Graphical/GraphicalMusicSheet";
-import {OutlineAndFillStyleEnum} from "../../../../src/MusicalScore/Graphical/DrawingEnums";
 import {MusicSheet} from "../../../../src/MusicalScore/MusicSheet";
 import {MusicSheetReader} from "../../../../src/MusicalScore/ScoreIO/MusicSheetReader";
 import {VexFlowMusicSheetCalculator} from "../../../../src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator";
 import {TestUtils} from "../../../Util/TestUtils";
 import {IXmlElement} from "../../../../src/Common/FileIO/Xml";
-import {Fraction} from "../../../../src/Common/DataObjects/Fraction";
 import {VexFlowBackend} from "../../../../src/MusicalScore/Graphical/VexFlow/VexFlowBackend";
 import {CanvasVexFlowBackend} from "../../../../src/MusicalScore/Graphical/VexFlow/CanvasVexFlowBackend";
-import {DrawingParameters} from "../../../../src/MusicalScore/Graphical/DrawingParameters";
 
 /* tslint:disable:no-unused-expression */
 describe("VexFlow Music Sheet Drawer", () => {
@@ -34,24 +31,26 @@ describe("VexFlow Music Sheet Drawer", () => {
         done();
     });
 
-    it.skip("draws cursor (as rectangle)", (done: MochaDone) => {
-        const score: Document = TestUtils.getScore("MuzioClementi_SonatinaOpus36No1_Part1.xml");
-        chai.expect(score).to.not.be.undefined;
-        const partwise: Element = TestUtils.getPartWiseElement(score);
-        chai.expect(partwise).to.not.be.undefined;
-        const reader: MusicSheetReader = new MusicSheetReader();
-        const calc: VexFlowMusicSheetCalculator = new VexFlowMusicSheetCalculator(reader.rules);
-        const sheet: MusicSheet = reader.createMusicSheet(new IXmlElement(partwise), "** missing path **");
-        const gms: GraphicalMusicSheet = new GraphicalMusicSheet(sheet, calc);
-        gms.Cursors.push(gms.calculateCursorLineAtTimestamp(new Fraction(0, 4), OutlineAndFillStyleEnum.PlaybackCursor));
+    // Test ignored for now, gms.calculateCursorLineAtTimestamp returns null instead of a GraphicalLine,
+    // and in any case, this test doesn't test that the cursor is actually drawn, there are no expects for that etc.
+    // it.only("draws cursor (as rectangle)", (done: MochaDone) => {
+    //     const score: Document = TestUtils.getScore("MuzioClementi_SonatinaOpus36No1_Part1.xml");
+    //     chai.expect(score).to.not.be.undefined;
+    //     const partwise: Element = TestUtils.getPartWiseElement(score);
+    //     chai.expect(partwise).to.not.be.undefined;
+    //     const reader: MusicSheetReader = new MusicSheetReader();
+    //     const calc: VexFlowMusicSheetCalculator = new VexFlowMusicSheetCalculator(reader.rules);
+    //     const sheet: MusicSheet = reader.createMusicSheet(new IXmlElement(partwise), "** missing path **");
+    //     const gms: GraphicalMusicSheet = new GraphicalMusicSheet(sheet, calc);
+    //     gms.Cursors.push(gms.calculateCursorLineAtTimestamp(new Fraction(0, 4), OutlineAndFillStyleEnum.PlaybackCursor));
 
-        // Create the canvas in the document:
-        const canvas: HTMLCanvasElement = document.createElement("canvas");
-        const backend: VexFlowBackend = new CanvasVexFlowBackend(sheet.Rules);
-        backend.initialize(canvas);
-        const drawer: VexFlowMusicSheetDrawer = new VexFlowMusicSheetDrawer(new DrawingParameters());
-        drawer.Backends.push(backend);
-        drawer.drawSheet(gms);
-        done();
-    });
+    //     // Create the canvas in the document:
+    //     const canvas: HTMLCanvasElement = document.createElement("canvas");
+    //     const backend: VexFlowBackend = new CanvasVexFlowBackend(sheet.Rules);
+    //     backend.initialize(canvas);
+    //     const drawer: VexFlowMusicSheetDrawer = new VexFlowMusicSheetDrawer(new DrawingParameters());
+    //     drawer.Backends.push(backend);
+    //     drawer.drawSheet(gms);
+    //     done();
+    // });
 });

+ 2 - 2
test/MusicalScore/ScoreIO/Key_Test.ts

@@ -21,9 +21,9 @@ describe("MusicXML parser for element 'key'", () => {
 
   describe("for group traditional keys", () => {
 
-    xit("enforces single occurrence of element 'fifths'", (done: MochaDone) => {
+    it("enforces single occurrence of element 'fifths'", (done: MochaDone) => {
       const keyInstruction: KeyInstruction = getIllegalMusicXmlWithTwoFifthsElements().getFirstSourceMeasure().getKeyInstruction(0);
-      // TODO Make sure we detect the multiple fifths and react properly
+      // TODO Make sure we detect the multiple fifths and react properly // [it seems like we do this test passes. ssch]
       chai.expect(keyInstruction.Mode).to.equal(KeyModeEnum.none);
       done();
     });